Bug 867505 - Intermittent test_bug536567_perwindowpb.html. r=ehsan, a=test-only
authorOlli Pettay <Olli.Pettay@helsinki.fi>
Thu, 19 Dec 2013 15:02:08 +0200
changeset 167787 47ddb6fbb2ade84aa3cac8f2b3a56b841747086c
parent 167786 436d8d0162d920db835a53dc4ff4b7ceff1360aa
child 167788 dbac310ca22503ff7ccfcf1e98205ea06c1c4696
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
bugs867505
milestone27.0
Bug 867505 - Intermittent test_bug536567_perwindowpb.html. r=ehsan, a=test-only
layout/forms/test/test_bug536567_perwindowpb.html
--- a/layout/forms/test/test_bug536567_perwindowpb.html
+++ b/layout/forms/test/test_bug536567_perwindowpb.html
@@ -134,33 +134,41 @@ function endTest() {
 
 var mainWindow =
   window.QueryInterface(Ci.nsIInterfaceRequestor).
     getInterface(Ci.nsIWebNavigation).QueryInterface(Ci.nsIDocShellTreeItem).
     rootTreeItem.QueryInterface(Ci.nsIInterfaceRequestor).
     getInterface(Ci.nsIDOMWindow);
 var contentPage = "http://mochi.test:8888/chrome/layout/forms/test/bug536567_iframe.html";
 
+function whenDelayedStartupFinished(aWindow, aCallback) {
+  Services.obs.addObserver(function observer(aSubject, aTopic) {
+    if (aWindow == aSubject) {
+      Services.obs.removeObserver(observer, aTopic);
+      setTimeout(aCallback, 0);
+    }
+  }, "browser-delayed-startup-finished", false);
+}
+
 function testOnWindow(aIsPrivate, aCallback) {
   var win = mainWindow.OpenBrowserWindow({private: aIsPrivate});
-  win.addEventListener("load", function onLoad() {
-    win.removeEventListener("load", onLoad, false);
+  whenDelayedStartupFinished(win, function() {
     win.addEventListener("DOMContentLoaded", function onInnerLoad() {
-      if (win.content.location.href == "about:privatebrowsing") {
+      if (win.content.location.href != contentPage) {
         win.gBrowser.loadURI(contentPage);
         return;
       }
       win.removeEventListener("DOMContentLoaded", onInnerLoad, true);
       win.gBrowser.selectedBrowser.focus();
       SimpleTest.info("DOMContentLoaded's window: " + win.location + " vs. " + window.location);
       win.setTimeout(function() { aCallback(win); }, 0);
     }, true);
     SimpleTest.info("load's window: " + win.location + " vs. " + window.location);
     win.setTimeout(function() { win.gBrowser.loadURI(contentPage); }, 0);
-  }, true);
+  });
 }
 
 MockFilePicker.showCallback = function(filepicker) {
   var test = tests[testIndex];
   var returned = -1;
   for (var i = 0; i < dirs.length; i++) {
     if (dirs[i].path == MockFilePicker.displayDirectory.path) {
       returned = i;