Source code
Revision control
Copy as Markdown
Other Tools
Test Info: Warnings
- This test has a WPT meta file that expects 1 subtest issues.
- This WPT test may be referenced by the following Test IDs:
- /notifications/icon-fetch.tentative.https.window.html - WPT Dashboard Interop Dashboard
// META: script=/resources/testdriver.js
// META: script=/resources/testdriver-vendor.js
// META: script=/service-workers/service-worker/resources/test-helpers.sub.js
// META: script=resources/helpers.js
let registration;
promise_setup(async () => {
await trySettingPermission("granted");
registration = await prepareActiveServiceWorker("icon-fetch-sw.js");
await new Promise(r => navigator.serviceWorker.addEventListener("controllerchange", r, { once: true }));
});
promise_test(async t => {
const iconUrl = new URL("resources/icon.png", location.href).toString();
const { promise, resolve } = Promise.withResolvers();
navigator.serviceWorker.addEventListener("message", async ev => {
if (ev.data.url === iconUrl) {
resolve();
}
}, { signal: t.signal });
await registration.showNotification("new Notification", {
icon: iconUrl
});
t.add_cleanup(closeAllNotifications);
await promise;
}, "Icon fetch should cause a corresponding fetch event in the service worker");