Bug 791670 - part 2 - fix browser_bug763468_perwindowpb.js test; r=ehsan
authorTim Taubert <ttaubert@mozilla.com>
Tue, 04 Jun 2013 22:20:44 +0200
changeset 133965 bbac98ae1fea
parent 133964 94e5027d22a4
child 133966 7f370b2b1317
push id24779
push userttaubert@mozilla.com
push dateWed, 05 Jun 2013 07:13:54 +0000
treeherdermozilla-central@8f9ba85eb61c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersehsan
bugs791670
milestone24.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 791670 - part 2 - fix browser_bug763468_perwindowpb.js test; r=ehsan
browser/base/content/test/browser_bug763468_perwindowpb.js
browser/base/content/test/head.js
--- a/browser/base/content/test/browser_bug763468_perwindowpb.js
+++ b/browser/base/content/test/browser_bug763468_perwindowpb.js
@@ -8,33 +8,31 @@ function test() {
   waitForExplicitFinish();
   let windowsToClose = [];
   let newTab;
   let newTabPrefName = "browser.newtab.url";
   let newTabURL;
   let mode;
 
   function doTest(aIsPrivateMode, aWindow, aCallback) {
-    aWindow.BrowserOpenTab();
-    aWindow.gBrowser.selectedTab.linkedBrowser.addEventListener("load", function onLoad() {
-      aWindow.gBrowser.selectedTab.linkedBrowser.removeEventListener("load", onLoad, true);
+    whenNewTabLoaded(aWindow, function () {
       if (aIsPrivateMode) {
         mode = "per window private browsing";
         newTabURL = "about:privatebrowsing";
       } else {
         mode = "normal";
         newTabURL = Services.prefs.getCharPref(newTabPrefName) || "about:blank";
       }
 
       is(aWindow.gBrowser.currentURI.spec, newTabURL,
         "URL of NewTab should be " + newTabURL + " in " + mode +  " mode");
 
       aWindow.gBrowser.removeTab(aWindow.gBrowser.selectedTab);
       aCallback()
-    }, true);
+    });
   };
 
   function testOnWindow(aOptions, aCallback) {
     whenNewWindowLoaded(aOptions, function(aWin) {
       windowsToClose.push(aWin);
       // execute should only be called when need, like when you are opening
       // web pages on the test. If calling executeSoon() is not necesary, then
       // call whenNewWindowLoaded() instead of testOnWindow() on your test.
--- a/browser/base/content/test/head.js
+++ b/browser/base/content/test/head.js
@@ -192,16 +192,31 @@ function promiseIsURIVisited(aURI, aExpe
   let deferred = Promise.defer();
   PlacesUtils.asyncHistory.isURIVisited(aURI, function(aURI, aIsVisited) {
     deferred.resolve(aIsVisited);
   });
 
   return deferred.promise;
 }
 
+function whenNewTabLoaded(aWindow, aCallback) {
+  aWindow.BrowserOpenTab();
+
+  let browser = aWindow.gBrowser.selectedBrowser;
+  if (browser.contentDocument.readyState === "complete") {
+    aCallback();
+    return;
+  }
+
+  browser.addEventListener("load", function onLoad() {
+    browser.removeEventListener("load", onLoad, true);
+    aCallback();
+  }, true);
+}
+
 function addVisits(aPlaceInfo, aCallback) {
   let places = [];
   if (aPlaceInfo instanceof Ci.nsIURI) {
     places.push({ uri: aPlaceInfo });
   } else if (Array.isArray(aPlaceInfo)) {
     places = places.concat(aPlaceInfo);
   } else {
     places.push(aPlaceInfo);