1
0
Fork 0
firefox/dom/notification/test/mochitest/notification_openWindow_worker.js
Daniel Baumann 5e9a113729
Adding upstream version 140.0.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
2025-06-25 09:37:52 +02:00

27 lines
825 B
JavaScript

/* eslint-env serviceworker */
const gRoot = "https://example.com/tests/dom/notification/test/mochitest/";
const gTestURL = gRoot + "test_notification_serviceworker_openWindow.html";
const gClientURL = gRoot + "file_notification_openWindow.html";
onmessage = function (event) {
if (event.data !== "DONE") {
dump(`ERROR: received unexpected message: ${JSON.stringify(event.data)}\n`);
}
event.waitUntil(
clients.matchAll({ includeUncontrolled: true }).then(cl => {
for (let client of cl) {
// The |gClientURL| window closes itself after posting the DONE message,
// so we don't need to send it anything here.
if (client.url === gTestURL) {
client.postMessage("DONE");
}
}
})
);
};
onnotificationclick = () => {
clients.openWindow(gClientURL);
};