Bug 1132566 - Make test e10s compatible: browser_privatebrowsing_crh.js; r=mossop
authorSteven MacLeod <smacleod@mozilla.com>
Thu, 05 Mar 2015 12:06:20 -0500
changeset 233824 7713401cf0c45506116c354773604df1dcb031f7
parent 233823 3dfae5c35fabcae49902a29f404e5b50c6804acb
child 233825 7a8c47a8aae6a035ebc3c6b354bed00d4f0cedd0
push id28425
push usercbook@mozilla.com
push dateTue, 17 Mar 2015 10:33:06 +0000
treeherdermozilla-central@a194e8023090 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmossop
bugs1132566
milestone39.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 1132566 - Make test e10s compatible: browser_privatebrowsing_crh.js; r=mossop
browser/components/privatebrowsing/test/browser/browser.ini
browser/components/privatebrowsing/test/browser/browser_privatebrowsing_crh.js
--- a/browser/components/privatebrowsing/test/browser/browser.ini
+++ b/browser/components/privatebrowsing/test/browser/browser.ini
@@ -22,17 +22,16 @@ skip-if = true # Bug 1142678 - Loading a
 skip-if = e10s
 [browser_privatebrowsing_aboutSessionRestore.js]
 [browser_privatebrowsing_cache.js]
 [browser_privatebrowsing_certexceptionsui.js]
 [browser_privatebrowsing_concurrent.js]
 [browser_privatebrowsing_cookieacceptdialog.js]
 skip-if = e10s # Bug 1139953 - Accept cookie dialog shown in private window when e10s enabled
 [browser_privatebrowsing_crh.js]
-skip-if = e10s
 [browser_privatebrowsing_downloadLastDir.js]
 skip-if = e10s
 [browser_privatebrowsing_downloadLastDir_c.js]
 skip-if = e10s
 [browser_privatebrowsing_downloadLastDir_toggle.js]
 skip-if = e10s
 [browser_privatebrowsing_geoprompt.js]
 skip-if = e10s
--- a/browser/components/privatebrowsing/test/browser/browser_privatebrowsing_crh.js
+++ b/browser/components/privatebrowsing/test/browser/browser_privatebrowsing_crh.js
@@ -1,59 +1,42 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 // This test makes sure that the Clear Recent History menu item and command 
 // is disabled inside the private browsing mode.
 
-function test() {
-  waitForExplicitFinish();
-
-  function checkDisableOption(aPrivateMode, aWindow, aCallback) {
-    executeSoon(function() {
-      let crhCommand = aWindow.document.getElementById("Tools:Sanitize");
-      ok(crhCommand, "The clear recent history command should exist");
+add_task(function test() {
+  function checkDisableOption(aPrivateMode, aWindow) {
+    let crhCommand = aWindow.document.getElementById("Tools:Sanitize");
+    ok(crhCommand, "The clear recent history command should exist");
 
-      is(PrivateBrowsingUtils.isWindowPrivate(aWindow), aPrivateMode,
-        "PrivateBrowsingUtils should report the correct per-window private browsing status");
-      is(crhCommand.hasAttribute("disabled"), aPrivateMode,
-        "Clear Recent History command should be disabled according to the private browsing mode");
-
-      executeSoon(aCallback);
-    });
+    is(PrivateBrowsingUtils.isWindowPrivate(aWindow), aPrivateMode,
+      "PrivateBrowsingUtils should report the correct per-window private browsing status");
+    is(crhCommand.hasAttribute("disabled"), aPrivateMode,
+      "Clear Recent History command should be disabled according to the private browsing mode");
   };
 
-  let windowsToClose = [];
   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;
-        }
-        aWin.gBrowser.selectedBrowser.removeEventListener("load", onLoad, true);
-        executeSoon(function() aCallback(aWin));
-      }, true);
+  let privateWin = yield BrowserTestUtils.openNewBrowserWindow({private: true});
+  let privateBrowser = privateWin.gBrowser.selectedBrowser;
+  privateBrowser.loadURI(testURI);
+  yield BrowserTestUtils.browserLoaded(privateBrowser);
 
-      aWin.gBrowser.loadURI(testURI);
-    });
-  };
+  info("Test on private window");
+  checkDisableOption(true, privateWin);
+
 
-  registerCleanupFunction(function() {
-    windowsToClose.forEach(function(aWin) {
-      aWin.close();
-    });
-  });
+  let win = yield BrowserTestUtils.openNewBrowserWindow();
+  let browser = win.gBrowser.selectedBrowser;
+  browser.loadURI(testURI);
+  yield BrowserTestUtils.browserLoaded(browser);
 
-  testOnWindow(true, function(aWin) {
-    info("Test on private window");
-    checkDisableOption(true, aWin, function() {
-      testOnWindow(false, function(aPrivWin) {
-        info("Test on public window");
-        checkDisableOption(false, aPrivWin, finish);
-      });
-    });
-  });
-}
+  info("Test on public window");
+  checkDisableOption(false, win);
+
+
+  // Cleanup
+  yield BrowserTestUtils.closeWindow(privateWin);
+  yield BrowserTestUtils.closeWindow(win);
+});