Automatic update from web-platform-tests Fix content-index WPT tests on WebLayer WebLayer does not implement getIconSizes and therefore does not check if icons are actually valid as they are never fetched. This is the same as on Chrome desktop platforms. Only Chrome on Android and Content Shell do currently download and verify content-index icons. This now makes the WPT pass for both scenarios for Chromium based browsers. Other browsers can add their own logic once they support the content-index API. Bug: 1177892 Change-Id: I06b908363e9e83b0d9207a5835e55214f1f01528 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2874562 Reviewed-by: Michael Moss <mmoss@chromium.org> Reviewed-by: Peter Beverloo <peter@chromium.org> Reviewed-by: Rayan Kanso <rayankans@chromium.org> Commit-Queue: Richard Knoll <knollr@chromium.org> Cr-Commit-Position: refs/heads/master@{#881785} -- wpt-commits: 13e6cb4144546d7fb4065f17f103d2fcbe982323 wpt-pr: 28906
58 lines
1.8 KiB
JavaScript
58 lines
1.8 KiB
JavaScript
'use strict';
|
|
|
|
const swUrl = 'resources/sw.js';
|
|
const scope = 'resources/';
|
|
|
|
async function expectTypeError(promise) {
|
|
try {
|
|
await promise;
|
|
assert_unreached('Promise should have rejected');
|
|
} catch (e) {
|
|
assert_equals(e.name, 'TypeError');
|
|
}
|
|
}
|
|
|
|
function createDescription({id = 'id', title = 'title', description = 'description',
|
|
category = 'homepage', iconUrl = '/images/green-256x256.png',
|
|
url = scope, includeIcons = true}) {
|
|
return {id, title, description, category, icons: includeIcons ? [{src: iconUrl}] : [], url};
|
|
}
|
|
|
|
// Creates a Promise test for |func| given the |description|. The |func| will be
|
|
// executed with the `index` object of an activated Service Worker Registration.
|
|
function contentIndexTest(func, description) {
|
|
promise_test(async t => {
|
|
const registration = await service_worker_unregister_and_register(t, swUrl, scope);
|
|
await wait_for_state(t, registration.installing, 'activated');
|
|
return func(t, registration.index);
|
|
}, description);
|
|
}
|
|
|
|
async function waitForMessageFromServiceWorker() {
|
|
return await new Promise(resolve => {
|
|
const listener = event => {
|
|
navigator.serviceWorker.removeEventListener('message', listener);
|
|
resolve(event.data);
|
|
};
|
|
|
|
navigator.serviceWorker.addEventListener('message', listener);
|
|
});
|
|
}
|
|
|
|
// Returns a promise if the chromium based browser fetches icons for
|
|
// content-index.
|
|
async function fetchesIconsChromium() {
|
|
const {fetchesIcons} =
|
|
await import('/resources/chromium/content-index-helpers.js');
|
|
return fetchesIcons();
|
|
}
|
|
|
|
// Returns a promise if the browser fetches icons for content-index and should
|
|
// therefore validate them.
|
|
async function fetchesIcons() {
|
|
if (isChromiumBased) {
|
|
return fetchesIconsChromium();
|
|
}
|
|
return false;
|
|
}
|