icon-fetch.tentative.https.window.js (1012B)
1 // META: script=/resources/testdriver.js 2 // META: script=/resources/testdriver-vendor.js 3 // META: script=/service-workers/service-worker/resources/test-helpers.sub.js 4 // META: script=resources/helpers.js 5 6 let registration; 7 8 promise_setup(async () => { 9 await trySettingPermission("granted"); 10 registration = await prepareActiveServiceWorker("icon-fetch-sw.js"); 11 await new Promise(r => navigator.serviceWorker.addEventListener("controllerchange", r, { once: true })); 12 }); 13 14 promise_test(async t => { 15 const iconUrl = new URL("resources/icon.png", location.href).toString(); 16 17 const { promise, resolve } = Promise.withResolvers(); 18 navigator.serviceWorker.addEventListener("message", async ev => { 19 if (ev.data.url === iconUrl) { 20 resolve(); 21 } 22 }, { signal: t.signal }); 23 24 await registration.showNotification("new Notification", { 25 icon: iconUrl 26 }); 27 t.add_cleanup(closeAllNotifications); 28 29 await promise; 30 }, "Icon fetch should cause a corresponding fetch event in the service worker");