notification_openWindow.serviceworker.js (803B)
1 const gRoot = "https://example.com/tests/dom/notification/test/mochitest/"; 2 const gTestURL = gRoot + "test_notification_serviceworker_openWindow.html"; 3 const gClientURL = gRoot + "file_notification_openWindow.html"; 4 5 onmessage = function (event) { 6 if (event.data?.type !== "DONE") { 7 dump(`ERROR: received unexpected message: ${JSON.stringify(event.data)}\n`); 8 } 9 10 event.waitUntil( 11 clients.matchAll({ includeUncontrolled: true }).then(cl => { 12 for (let client of cl) { 13 // The |gClientURL| window closes itself after posting the DONE message, 14 // so we don't need to send it anything here. 15 if (client.url === gTestURL) { 16 client.postMessage(event.data); 17 } 18 } 19 }) 20 ); 21 }; 22 23 onnotificationclick = () => { 24 clients.openWindow(gClientURL); 25 };