Bug 1397365: Part 6 - Several dom/workers tests need to wait for the environment to be ready. r?asuth draft
authorZibi Braniecki <zbraniecki@mozilla.com>
Wed, 13 Sep 2017 01:27:17 -0700
changeset 664680 6b7289e0eff418a22910326f93ea7d94bfae5837
parent 664679 2414f024dedd41d4b2eb15ad2a6d315d4c937525
child 664681 c2ed718a9a8accdfda2196f1f81fffd86dbe2f40
push id79760
push userbmo:gandalf@aviary.pl
push dateThu, 14 Sep 2017 08:02:46 +0000
reviewersasuth
bugs1397365
milestone57.0a1
Bug 1397365: Part 6 - Several dom/workers tests need to wait for the environment to be ready. r?asuth MozReview-Commit-ID: 4fZeNh635i1
dom/workers/test/serviceworkers/test_devtools_serviceworker_interception.html
dom/workers/test/serviceworkers/test_privateBrowsing.html
dom/workers/test/test_sharedWorker_privateBrowsing.html
--- a/dom/workers/test/serviceworkers/test_devtools_serviceworker_interception.html
+++ b/dom/workers/test/serviceworkers/test_devtools_serviceworker_interception.html
@@ -26,29 +26,30 @@ const contentPage = workerScope + "hello
 
 function createTestWindow(aURL) {
   var mainwindow = window.QueryInterface(Ci.nsIInterfaceRequestor)
                          .getInterface(Ci.nsIWebNavigation)
                          .QueryInterface(Ci.nsIDocShellTreeItem)
                          .rootTreeItem
                          .QueryInterface(Ci.nsIInterfaceRequestor)
                          .getInterface(Ci.nsIDOMWindow);
-  var win = mainwindow.OpenBrowserWindow(contentPage);
+  var win = mainwindow.OpenBrowserWindow();
 
-  return new Promise(aResolve => {
-    win.addEventListener("DOMContentLoaded", function callback() {
-      if (win.content.location.href != aURL) {
-        win.gBrowser.loadURI(aURL);
-        return;
-      }
-
-      win.removeEventListener("DOMContentLoaded", callback);
-      aResolve(win.content);
-    });
-  });
+  return Promise.resolve()
+    .then(_ => new Promise(aResolve => win.addEventListener("load", aResolve, {once: true})))
+    .then(_ => new Promise(aResolve => {
+      win.addEventListener("DOMContentLoaded", function callback() {
+        if (win.content.location.href != aURL) {
+          win.gBrowser.loadURI(aURL);
+          return;
+        }
+        win.removeEventListener("DOMContentLoaded", callback);
+        aResolve(win.content);
+      });
+    }));
 }
 
 function executeTest(aWindow) {
   var registration;
 
   return Promise.resolve()
     // Should not be intercepted.
     .then(_ => fetchAndCheckTimedChannel(aWindow, false, true, "hello.html"))
--- a/dom/workers/test/serviceworkers/test_privateBrowsing.html
+++ b/dom/workers/test/serviceworkers/test_privateBrowsing.html
@@ -22,20 +22,16 @@ function testOnWindow(aIsPrivate, aCallb
       if (win.content.location.href != contentPage) {
         win.gBrowser.loadURI(contentPage);
         return;
       }
 
       win.removeEventListener("DOMContentLoaded", onInnerLoad, true);
       SimpleTest.executeSoon(function() { aCallback(win); });
     }, true);
-
-    if (!aIsPrivate) {
-      win.gBrowser.loadURI(contentPage);
-    }
   }, {capture: true, once: true});
 }
 
 function setupWindow() {
   mainWindow = window.QueryInterface(Ci.nsIInterfaceRequestor)
                      .getInterface(Ci.nsIWebNavigation)
                      .QueryInterface(Ci.nsIDocShellTreeItem)
                      .rootTreeItem
--- a/dom/workers/test/test_sharedWorker_privateBrowsing.html
+++ b/dom/workers/test/test_sharedWorker_privateBrowsing.html
@@ -20,20 +20,16 @@ function testOnWindow(aIsPrivate, aCallb
       if (win.content.location.href != contentPage) {
         win.gBrowser.loadURI(contentPage);
         return;
       }
 
       win.removeEventListener("DOMContentLoaded", onInnerLoad, true);
       SimpleTest.executeSoon(function() { aCallback(win); });
     }, true);
-
-    if (!aIsPrivate) {
-      win.gBrowser.loadURI(contentPage);
-    }
   }, {capture: true, once: true});
 }
 
 function setupWindow() {
   mainWindow = window.QueryInterface(Ci.nsIInterfaceRequestor)
                      .getInterface(Ci.nsIWebNavigation)
                      .QueryInterface(Ci.nsIDocShellTreeItem)
                      .rootTreeItem