Bug 950342 - Random failures in toolkit/components/places/tests/browser/browser_visituri_privatebrowsing_perwindowpb.js. r=ehsan, a=test-only
authorOlli Pettay <Olli.Pettay@helsinki.fi>
Thu, 19 Dec 2013 14:54:58 +0200
changeset 167786 436d8d0162d920db835a53dc4ff4b7ceff1360aa
parent 167785 5a6d04f493d18eed0d375e7c5f1d16e9f0a3e0a8
child 167787 47ddb6fbb2ade84aa3cac8f2b3a56b841747086c
push id428
push userbbajaj@mozilla.com
push dateTue, 28 Jan 2014 00:16:25 +0000
treeherdermozilla-release@cd72a7ff3a75 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersehsan, test-only
bugs950342
milestone27.0
Bug 950342 - Random failures in toolkit/components/places/tests/browser/browser_visituri_privatebrowsing_perwindowpb.js. r=ehsan, a=test-only
toolkit/components/places/tests/browser/browser_visituri_privatebrowsing_perwindowpb.js
toolkit/components/places/tests/browser/head.js
--- a/toolkit/components/places/tests/browser/browser_visituri_privatebrowsing_perwindowpb.js
+++ b/toolkit/components/places/tests/browser/browser_visituri_privatebrowsing_perwindowpb.js
@@ -13,16 +13,20 @@ function test() {
     "http://example.com/tests/toolkit/components/places/tests/browser/final.html";
   let observer = null;
   let enumerator = null;
   let currentObserver = null;
   let uri = null;
 
   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) {
         aCallback();
       }
     }, true);
 
     observer = {
--- a/toolkit/components/places/tests/browser/head.js
+++ b/toolkit/components/places/tests/browser/head.js
@@ -335,22 +335,28 @@ function DBConn(aForceNewConnection) {
       Services.obs.removeObserver(DBCloseCallback, aTopic);
       dbConn.asyncClose();
     }, "profile-before-change", false);
   }
 
   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);
 }
 
 /**
  * Asynchronously check a url is visited.
  *
  * @param aURI The URI.
  * @param aExpectedValue The expected value.
  * @return {Promise}