Bug 1132566 - Make test e10s compatible: browser_privatebrowsing_protocolhandler.js; r=mossop
authorSteven MacLeod <smacleod@mozilla.com>
Thu, 05 Mar 2015 17:33:16 -0500
changeset 233838 9da87b37243eadb0832b2eba58f8d2cc766da9e2
parent 233837 dd371585e02896d7ae50e4a5ac3b36e0a2ba6fbf
child 233839 64b04ba6e42421648483c5da19b867c3ef461336
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, 940206
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_protocolhandler.js; r=mossop The modifications should make the test e10s compatible but I have left it disabled as it fails due to Bug 940206.
browser/components/privatebrowsing/test/browser/browser.ini
browser/components/privatebrowsing/test/browser/browser_privatebrowsing_protocolhandler.js
--- a/browser/components/privatebrowsing/test/browser/browser.ini
+++ b/browser/components/privatebrowsing/test/browser/browser.ini
@@ -36,17 +36,17 @@ skip-if = e10s # Bug 1139953 - Accept co
 [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]
 [browser_privatebrowsing_protocolhandler.js]
-skip-if = e10s
+skip-if = e10s # Bug 940206 -  nsIWebContentHandlerRegistrar::registerProtocolHandler doesn't work in e10s
 [browser_privatebrowsing_sidebar.js]
 skip-if = e10s
 [browser_privatebrowsing_theming.js]
 skip-if = e10s
 [browser_privatebrowsing_ui.js]
 skip-if = e10s
 [browser_privatebrowsing_urlbarfocus.js]
 skip-if = e10s
--- a/browser/components/privatebrowsing/test/browser/browser_privatebrowsing_protocolhandler.js
+++ b/browser/components/privatebrowsing/test/browser/browser_privatebrowsing_protocolhandler.js
@@ -1,65 +1,47 @@
 /* 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 web pages can't register protocol handlers
 // inside the private browsing mode.
 
-function test() {
-  // initialization
-  waitForExplicitFinish();
-  let windowsToClose = [];
+add_task(function* test() {
   let notificationValue = "Protocol Registration: testprotocol";
   let testURI = "http://example.com/browser/" +
     "browser/components/privatebrowsing/test/browser/browser_privatebrowsing_protocolhandler_page.html";
 
-  function doTest(aIsPrivateMode, aWindow, aCallback) {
-    aWindow.gBrowser.selectedBrowser.addEventListener("load", function onLoad() {
-      aWindow.gBrowser.selectedBrowser.removeEventListener("load", onLoad, true);
-
-      setTimeout(function() {
-        let notificationBox = aWindow.gBrowser.getNotificationBox();
-        let notification = notificationBox.getNotificationWithValue(notificationValue);
+  let doTest = Task.async(function* (aIsPrivateMode, aWindow) {
+    let tab = aWindow.gBrowser.selectedTab = aWindow.gBrowser.addTab(testURI);
+    yield BrowserTestUtils.browserLoaded(tab.linkedBrowser);
 
-        if (aIsPrivateMode) {
-          // Make sure the notification is correctly displayed without a remember control
-          ok(!notification, "Notification box should not be displayed inside of private browsing mode");
-        } else {
-          // Make sure the notification is correctly displayed with a remember control
-          ok(notification, "Notification box should be displaying outside of private browsing mode");
-        }
+    let promiseFinished = PromiseUtils.defer();
+    setTimeout(function() {
+      let notificationBox = aWindow.gBrowser.getNotificationBox();
+      let notification = notificationBox.getNotificationWithValue(notificationValue);
 
-        aCallback();
-      }, 100); // remember control is added in a setTimeout(0) call
-    }, true);
-
-    aWindow.gBrowser.selectedBrowser.loadURI(testURI);
-  }
+      if (aIsPrivateMode) {
+        // Make sure the notification is correctly displayed without a remember control
+        ok(!notification, "Notification box should not be displayed inside of private browsing mode");
+      } else {
+        // Make sure the notification is correctly displayed with a remember control
+        ok(notification, "Notification box should be displaying outside of private browsing mode");
+      }
 
-  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.
-      executeSoon(function() aCallback(aWin));
-    });
-  };
+      promiseFinished.resolve();
+    }, 100); // remember control is added in a setTimeout(0) call
 
-   // this function is called after calling finish() on the test.
-  registerCleanupFunction(function() {
-    windowsToClose.forEach(function(aWin) {
-      aWin.close();
-    });
+    yield promiseFinished.promise;
   });
 
   // test first when not on private mode
-  testOnWindow({}, function(aWin) {
-    doTest(false, aWin, function() {
-      // then test when on private mode
-      testOnWindow({private: true}, function(aWin) {
-        doTest(true, aWin, finish);
-      });
-    });
-  });
-}
+  let win = yield BrowserTestUtils.openNewBrowserWindow();
+  yield doTest(false, win);
+
+  // then test when on private mode
+  let privateWin = yield BrowserTestUtils.openNewBrowserWindow({private: true});
+  yield doTest(true, privateWin);
+
+  // Cleanup
+  yield BrowserTestUtils.closeWindow(win);
+  yield BrowserTestUtils.closeWindow(privateWin);
+});