Bug 822284 - Intermittent browser_privatebrowsing_cookieacceptdialog.js, browser_privatebrowsing_crh.js; r=ehsan
authorAndres Hernandez <andres@appcoast.com>
Fri, 01 Feb 2013 15:05:29 -0600
changeset 130537 4466d3ff8ada315e689120977012702733af932e
parent 130536 2962a3ff97dad7b1468a3b54c0bb474853f61585
child 130538 b4673ca3faccef843e496fc464f270838aa732c3
push id2323
push userbbajaj@mozilla.com
push dateMon, 01 Apr 2013 19:47:02 +0000
treeherdermozilla-beta@7712be144d91 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersehsan
bugs822284
milestone21.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 822284 - Intermittent browser_privatebrowsing_cookieacceptdialog.js, browser_privatebrowsing_crh.js; r=ehsan
browser/components/privatebrowsing/test/browser/perwindow/browser_privatebrowsing_cookieacceptdialog.js
browser/components/privatebrowsing/test/browser/perwindow/browser_privatebrowsing_crh.js
--- a/browser/components/privatebrowsing/test/browser/perwindow/browser_privatebrowsing_cookieacceptdialog.js
+++ b/browser/components/privatebrowsing/test/browser/perwindow/browser_privatebrowsing_cookieacceptdialog.js
@@ -3,18 +3,19 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 // This test makes sure that private browsing mode disables the "remember"
 // option in the cookie accept dialog.
 
 function test() {
   // initialization
   const TEST_URL = "http://mochi.test:8888/browser/browser/components/" +
-                   "privatebrowsing/test/browser/perwindow/" + 
+                   "privatebrowsing/test/browser/perwindow/" +
                    "browser_privatebrowsing_cookieacceptdialog.html";
+  const BLANK_URL = "http://mochi.test:8888/";
   let cp = Cc["@mozilla.org/embedcomp/cookieprompt-service;1"].
            getService(Ci.nsICookiePromptService);
 
   waitForExplicitFinish();
 
   function checkRememberOption(expectedDisabled, aWindow, callback) {
     function observer(aSubject, aTopic, aData) {
       if (aTopic != "domwindowopened")
@@ -32,18 +33,17 @@ function test() {
 
           if (expectedDisabled)
             is(remember.getAttribute("disabled"), "true",
                "The checkbox should be disabled");
           else
             ok(!remember.hasAttribute("disabled"),
                "The checkbox should not be disabled");
 
-          win.close();
-          executeSoon(callback);
+          waitForWindowClose(win, callback);
         });
       }, false);
     }
     Services.ww.registerNotification(observer);
 
     let remember = {};
     const time = (new Date("Jan 1, 2030")).getTime() / 1000;
     let cookie = {
@@ -105,17 +105,26 @@ function test() {
 
     selectedBrowser.loadURI(TEST_URL);
   }
 
   let windowsToClose = [];
   function testOnWindow(aIsPrivate, aCallback) {
     whenNewWindowLoaded({private: aIsPrivate}, function(aWin) {
       windowsToClose.push(aWin);
-      aCallback(aWin);
+      let selectedBrowser = aWin.gBrowser.selectedBrowser;
+      selectedBrowser.addEventListener("load", function onLoad() {
+        if (aWin.content.location.href != BLANK_URL) {
+          selectedBrowser.loadURI(BLANK_URL);
+          return;
+        }
+        selectedBrowser.removeEventListener("load", onLoad, true);
+        aCallback(aWin);
+      }, true);
+      selectedBrowser.loadURI(BLANK_URL);
     });
   }
 
   registerCleanupFunction(function() {
     Services.prefs.clearUserPref("network.cookie.lifetimePolicy");
     windowsToClose.forEach(function(win) {
       win.close();
     });
--- a/browser/components/privatebrowsing/test/browser/perwindow/browser_privatebrowsing_crh.js
+++ b/browser/components/privatebrowsing/test/browser/perwindow/browser_privatebrowsing_crh.js
@@ -18,17 +18,17 @@ function test() {
       is(crhCommand.hasAttribute("disabled"), aPrivateMode,
         "Clear Recent History command should be disabled according to the private browsing mode");
 
       executeSoon(aCallback);
     });
   };
 
   let windowsToClose = [];
-  let testURI = "about:blank";
+  let testURI = "http://mochi.test:8888/";
 
   function testOnWindow(aIsPrivate, aCallback) {
     whenNewWindowLoaded({private: aIsPrivate}, function(aWin) {
       windowsToClose.push(aWin);
       aWin.gBrowser.selectedBrowser.addEventListener("load", function onLoad() {
         if (aWin.content.location.href != testURI) {
           aWin.gBrowser.loadURI(testURI);
           return;