Bug 1397365: Part 6 - Several dom/workers tests need to wait for the environment to be ready. r?asuth
MozReview-Commit-ID: 4fZeNh635i1
--- 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