summaryrefslogtreecommitdiffstats
path: root/dom/serviceworkers/test/notification_openWindow_worker.js
diff options
context:
space:
mode:
Diffstat (limited to 'dom/serviceworkers/test/notification_openWindow_worker.js')
-rw-r--r--dom/serviceworkers/test/notification_openWindow_worker.js25
1 files changed, 25 insertions, 0 deletions
diff --git a/dom/serviceworkers/test/notification_openWindow_worker.js b/dom/serviceworkers/test/notification_openWindow_worker.js
new file mode 100644
index 0000000000..890f70f795
--- /dev/null
+++ b/dom/serviceworkers/test/notification_openWindow_worker.js
@@ -0,0 +1,25 @@
+const gRoot = "http://mochi.test:8888/tests/dom/serviceworkers/test/";
+const gTestURL = gRoot + "test_notification_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 = function (event) {
+ clients.openWindow(gClientURL);
+};