diff --git a/toolkit/components/places/tests/browser/browser_visituri_privatebrowsing_perwindowpb.js b/toolkit/components/places/tests/browser/browser_visituri_privatebrowsing_perwindowpb.js index 18742bdf015b..5c135e879c45 100644 --- a/toolkit/components/places/tests/browser/browser_visituri_privatebrowsing_perwindowpb.js +++ b/toolkit/components/places/tests/browser/browser_visituri_privatebrowsing_perwindowpb.js @@ -18,6 +18,10 @@ function test() { function doTest(aIsPrivateMode, aWindow, aTestURI, aCallback) { aWindow.gBrowser.selectedBrowser.addEventListener("load", function onLoad() { + if (aWindow.gBrowser.selectedBrowser.contentWindow.location != aTestURI) { + aWindow.gBrowser.selectedBrowser.contentWindow.location = aTestURI; + return; + } aWindow.gBrowser.selectedBrowser.removeEventListener("load", onLoad, true); if (aCallback) { diff --git a/toolkit/components/places/tests/browser/head.js b/toolkit/components/places/tests/browser/head.js index a0dbd8325876..c381f4f62962 100644 --- a/toolkit/components/places/tests/browser/head.js +++ b/toolkit/components/places/tests/browser/head.js @@ -340,12 +340,18 @@ function DBConn(aForceNewConnection) { return gDBConn.connectionReady ? gDBConn : null; } +function whenDelayedStartupFinished(aWindow, aCallback) { + Services.obs.addObserver(function observer(aSubject, aTopic) { + if (aWindow == aSubject) { + Services.obs.removeObserver(observer, aTopic); + executeSoon(function() { aCallback(aWindow); }); + } + }, "browser-delayed-startup-finished", false); +} + function whenNewWindowLoaded(aOptions, aCallback) { let win = OpenBrowserWindow(aOptions); - win.addEventListener("load", function onLoad() { - win.removeEventListener("load", onLoad, false); - aCallback(win); - }, false); + whenDelayedStartupFinished(win, aCallback); } /**