Bug 1622749 - Run test_notification_openWindow.html with all possible values of browser.link.open_newwindow. r=nika, a=RyanVM
authorKashav Madan <kmadan@mozilla.com>
Tue, 14 Apr 2020 19:53:57 +0000
changeset 585540 a3482e46d0b6af349252648d0221ae262ef38886
parent 585539 2bb367f73d58f5b925741f296412321fc4d44f4f
child 585541 9d27f85c23cb252ee9a832582cde377f0b3ff77c
push id13004
push userryanvm@gmail.com
push dateWed, 15 Apr 2020 20:35:43 +0000
treeherdermozilla-beta@9d27f85c23cb [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersnika, RyanVM
bugs1622749
milestone76.0
Bug 1622749 - Run test_notification_openWindow.html with all possible values of browser.link.open_newwindow. r=nika, a=RyanVM Differential Revision: https://phabricator.services.mozilla.com/D67896
dom/serviceworkers/test/test_notification_openWindow.html
--- a/dom/serviceworkers/test/test_notification_openWindow.html
+++ b/dom/serviceworkers/test/test_notification_openWindow.html
@@ -24,47 +24,58 @@ add_task(async function setup() {
     ["dom.serviceWorkers.disable_open_click_delay", 1000],
     ["dom.serviceWorkers.idle_timeout", 299999],
     ["dom.serviceWorkers.idle_extended_timeout", 299999]
   ]});
 
   MockServices.register();
   SimpleTest.requestFlakyTimeout("Mock alert service dispatches show and click events.");
   SimpleTest.registerCleanupFunction(() => {
-    MockServices.unregister()
+    MockServices.unregister();
   });
 });
 
 add_task(async function test() {
   info("Registering service worker.");
   let swr = await navigator.serviceWorker.register("notification_openWindow_worker.js");
   await waitForState(swr.installing, "activated");
 
   SimpleTest.registerCleanupFunction(async () => {
     await swr.unregister();
     navigator.serviceWorker.onmessage = null;
   });
 
-  // The onclicknotification handler uses Clients.openWindow() to open a new
-  // window. This newly created window will attempt to open another window with
-  // Window.open() and some arbitrary URL. We crash before the second window
-  // finishes loading.
-  info("Showing notification.");
-  await swr.showNotification("notification");
+  for (let prefValue of [
+    SpecialPowers.Ci.nsIBrowserDOMWindow.OPEN_CURRENTWINDOW,
+    SpecialPowers.Ci.nsIBrowserDOMWindow.OPEN_NEWWINDOW,
+    SpecialPowers.Ci.nsIBrowserDOMWindow.OPEN_NEWTAB,
+  ]) {
+    info(`Setting browser.link.open_newwindow to ${prefValue}.`);
+    await SpecialPowers.pushPrefEnv({
+      set: [["browser.link.open_newwindow", prefValue]],
+    });
 
-  info("Waiting for \"DONE\" from worker.");
-  await new Promise(resolve => {
-    navigator.serviceWorker.onmessage = event => {
-      if (event.data !== "DONE") {
-        ok(false, `Unexpected message from service worker: ${JSON.stringify(event.data)}`);
+    // The onclicknotification handler uses Clients.openWindow() to open a new
+    // window. This newly created window will attempt to open another window with
+    // Window.open() and some arbitrary URL. We crash before the second window
+    // finishes loading.
+    info("Showing notification.");
+    await swr.showNotification("notification");
+
+    info("Waiting for \"DONE\" from worker.");
+    await new Promise(resolve => {
+      navigator.serviceWorker.onmessage = event => {
+        if (event.data !== "DONE") {
+          ok(false, `Unexpected message from service worker: ${JSON.stringify(event.data)}`);
+        }
+        resolve();
       }
-      resolve();
-    }
-  });
+    });
 
-  // If we make it here, then we didn't crash.
-  ok(true, "Didn't crash!");
+    // If we make it here, then we didn't crash.
+    ok(true, "Didn't crash!");
+  }
 });
 
 </script>
 </pre>
 </body>
 </html>