Bug 1132566 - Make test e10s compatible: browser_privatebrowsing_popupblocker.js; r=mconley
authorSteven MacLeod <smacleod@mozilla.com>
Thu, 05 Mar 2015 17:01:56 -0500
changeset 234011 dd371585e02896d7ae50e4a5ac3b36e0a2ba6fbf
parent 234010 9b7f81054f06293a23ed390060c1a787c439a94c
child 234012 9da87b37243eadb0832b2eba58f8d2cc766da9e2
push id57019
push usercbook@mozilla.com
push dateTue, 17 Mar 2015 10:50:22 +0000
treeherdermozilla-inbound@15e49729e473 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmconley
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_popupblocker.js; r=mconley
browser/components/privatebrowsing/test/browser/browser.ini
browser/components/privatebrowsing/test/browser/browser_privatebrowsing_popupblocker.js
--- a/browser/components/privatebrowsing/test/browser/browser.ini
+++ b/browser/components/privatebrowsing/test/browser/browser.ini
@@ -35,17 +35,16 @@ skip-if = e10s # Bug 1139953 - Accept co
 [browser_privatebrowsing_localStorage.js]
 [browser_privatebrowsing_localStorage_before_after.js]
 [browser_privatebrowsing_noSessionRestoreMenuOption.js]
 [browser_privatebrowsing_nonbrowser.js]
 [browser_privatebrowsing_opendir.js]
 [browser_privatebrowsing_placesTitleNoUpdate.js]
 [browser_privatebrowsing_placestitle.js]
 [browser_privatebrowsing_popupblocker.js]
-skip-if = e10s
 [browser_privatebrowsing_protocolhandler.js]
 skip-if = e10s
 [browser_privatebrowsing_sidebar.js]
 skip-if = e10s
 [browser_privatebrowsing_theming.js]
 skip-if = e10s
 [browser_privatebrowsing_ui.js]
 skip-if = e10s
--- a/browser/components/privatebrowsing/test/browser/browser_privatebrowsing_popupblocker.js
+++ b/browser/components/privatebrowsing/test/browser/browser_privatebrowsing_popupblocker.js
@@ -1,23 +1,23 @@
 /* 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 private browsing mode disables the remember option
 // for the popup blocker menu.
-function test() {
-  // initialization
-  waitForExplicitFinish();
-
+add_task(function* test() {
   let testURI = "http://mochi.test:8888/browser/browser/components/privatebrowsing/test/browser/popup.html";
-  let windowsToClose = [];
   let oldPopupPolicy = gPrefService.getBoolPref("dom.disable_open_during_load");
   gPrefService.setBoolPref("dom.disable_open_during_load", true);
 
+  registerCleanupFunction(() => {
+    gPrefService.setBoolPref("dom.disable_open_during_load", oldPopupPolicy);
+  });
+
   function testPopupBlockerMenuItem(aExpectedDisabled, aWindow, aCallback) {
 
     aWindow.gBrowser.addEventListener("DOMUpdatePageReport", function() {
       aWindow.gBrowser.removeEventListener("DOMUpdatePageReport", arguments.callee, false);
 
       executeSoon(function() {
         let notification = aWindow.gBrowser.getNotificationBox().getNotificationWithValue("popup-blocked");
         ok(notification, "The notification box should be displayed");
@@ -46,37 +46,22 @@ function test() {
         notification.querySelector("button").doCommand();
       });
 
     }, false);
 
     aWindow.gBrowser.selectedBrowser.loadURI(testURI);
   }
 
-  function finishTest() {
-    // cleanup
-    gPrefService.setBoolPref("dom.disable_open_during_load", oldPopupPolicy);
-    finish();
-  };
+  let win1 = yield BrowserTestUtils.openNewBrowserWindow();
+  yield new Promise(resolve => testPopupBlockerMenuItem(false, win1, resolve));
 
-  function testOnWindow(options, callback) {
-    let win = whenNewWindowLoaded(options, callback);
-    windowsToClose.push(win);
-  };
+  let win2 = yield BrowserTestUtils.openNewBrowserWindow({private: true});
+  yield new Promise(resolve => testPopupBlockerMenuItem(true, win2, resolve));
 
-  registerCleanupFunction(function() {
-    windowsToClose.forEach(function(win) {
-      win.close();
-    });
-  });
+  let win3 = yield BrowserTestUtils.openNewBrowserWindow();
+  yield new Promise(resolve => testPopupBlockerMenuItem(false, win3, resolve));
 
-  testOnWindow({}, function(win) {
-    testPopupBlockerMenuItem(false, win, function() {
-      testOnWindow({private: true}, function(win) {
-        testPopupBlockerMenuItem(true, win, function() {
-          testOnWindow({}, function(win) {
-            testPopupBlockerMenuItem(false, win, finishTest);
-          })
-        });
-      })
-    });
-  });
-}
+  // Cleanup
+  yield BrowserTestUtils.closeWindow(win1);
+  yield BrowserTestUtils.closeWindow(win2);
+  yield BrowserTestUtils.closeWindow(win3);
+});