Bug 1132566 - Make test e10s compatible: browser_privatebrowsing_geoprompt.js; r=mconley
authorSteven MacLeod <smacleod@mozilla.com>
Thu, 05 Mar 2015 13:30:26 -0500
changeset 233828 bc7ca394c5cfad24bb99956de5022b19424e7b19
parent 233827 6e8d12dd69f2a6f1754ba51d9200ae7cbbce859f
child 233829 bd4ad6d4d52aa12a082ac5cb422d9d9b5486f74d
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)
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_geoprompt.js; r=mconley
browser/components/privatebrowsing/test/browser/browser.ini
browser/components/privatebrowsing/test/browser/browser_privatebrowsing_geoprompt.js
--- a/browser/components/privatebrowsing/test/browser/browser.ini
+++ b/browser/components/privatebrowsing/test/browser/browser.ini
@@ -26,17 +26,16 @@ skip-if = e10s
 [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]
 [browser_privatebrowsing_downloadLastDir.js]
 [browser_privatebrowsing_downloadLastDir_c.js]
 [browser_privatebrowsing_downloadLastDir_toggle.js]
 [browser_privatebrowsing_geoprompt.js]
-skip-if = e10s
 [browser_privatebrowsing_lastpbcontextexited.js]
 skip-if = e10s
 [browser_privatebrowsing_localStorage.js]
 skip-if = e10s
 [browser_privatebrowsing_localStorage_before_after.js]
 skip-if = e10s
 [browser_privatebrowsing_noSessionRestoreMenuOption.js]
 skip-if = e10s
--- a/browser/components/privatebrowsing/test/browser/browser_privatebrowsing_geoprompt.js
+++ b/browser/components/privatebrowsing/test/browser/browser_privatebrowsing_geoprompt.js
@@ -1,69 +1,54 @@
 /* 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 geolocation prompt does not show a remember
 // control inside the private browsing mode.
 
-function test() {
+add_task(function* test() {
   const testPageURL = "http://mochi.test:8888/browser/" +
     "browser/components/privatebrowsing/test/browser/browser_privatebrowsing_geoprompt_page.html";
-  waitForExplicitFinish();
 
-    function checkGeolocation(aPrivateMode, aWindow, aCallback) {
-    executeSoon(function() {
-      aWindow.gBrowser.selectedTab = aWindow.gBrowser.addTab();
-      aWindow.gBrowser.selectedBrowser.addEventListener("load", function () {
-        if (aWindow.content.location != testPageURL) {
-          aWindow.content.location = testPageURL;
-          return;
-        }
-        aWindow.gBrowser.selectedBrowser.removeEventListener("load", arguments.callee, true);
+  function checkGeolocation(aPrivateMode, aWindow) {
+    return Task.spawn(function* () {
+      aWindow.gBrowser.selectedTab = aWindow.gBrowser.addTab(testPageURL);
+      yield BrowserTestUtils.browserLoaded(aWindow.gBrowser.selectedBrowser);
+
+      let notification = aWindow.PopupNotifications.getNotification("geolocation");
 
-        function runTest() {
-          let notification = aWindow.PopupNotifications.getNotification("geolocation");
-          if (!notification) {
-            // Wait until the notification is available
-            executeSoon(runTest);
-            return;
-          }
-          if (aPrivateMode) {
-            // Make sure the notification is correctly displayed without a remember control
-            is(notification.secondaryActions.length, 0, "Secondary actions shouldn't exist (always/never remember)");
-          } else {
-            ok(notification.secondaryActions.length > 1, "Secondary actions should exist (always/never remember)");
-          }
-          notification.remove();
+      // Wait until the notification is available.
+      while (!notification){
+        yield new Promise(resolve => { executeSoon(resolve); });
+        let notification = aWindow.PopupNotifications.getNotification("geolocation");
+      }
 
-          aWindow.gBrowser.removeCurrentTab();
-          aCallback();
-        }
-        runTest();
-      }, true);
+      if (aPrivateMode) {
+        // Make sure the notification is correctly displayed without a remember control
+        is(notification.secondaryActions.length, 0, "Secondary actions shouldn't exist (always/never remember)");
+      } else {
+        ok(notification.secondaryActions.length > 1, "Secondary actions should exist (always/never remember)");
+      }
+      notification.remove();
+
+      aWindow.gBrowser.removeCurrentTab();
     });
   };
 
-  let windowsToClose = [];
-  function testOnWindow(options, callback) {
-    let win = OpenBrowserWindow(options);
-    win.addEventListener("load", function onLoad() {
-      win.removeEventListener("load", onLoad, false);
-      windowsToClose.push(win);
-      callback(win);
-    }, false);
-  };
+  let win = yield BrowserTestUtils.openNewBrowserWindow();
+  let browser = win.gBrowser.selectedBrowser;
+  browser.loadURI(testPageURL);
+  yield BrowserTestUtils.browserLoaded(browser);
+
+  yield checkGeolocation(false, win);
 
-  registerCleanupFunction(function() {
-    windowsToClose.forEach(function(win) {
-      win.close();
-    });
-  });
+  let privateWin = yield BrowserTestUtils.openNewBrowserWindow({private: true});
+  let privateBrowser = privateWin.gBrowser.selectedBrowser;
+  privateBrowser.loadURI(testPageURL);
+  yield BrowserTestUtils.browserLoaded(privateBrowser);
 
-  testOnWindow({private: false}, function(win) {
-    checkGeolocation(false, win, function() {
-      testOnWindow({private: true}, function(win) {
-        checkGeolocation(true, win, finish);
-      });
-    });
-  });
-}
+  yield checkGeolocation(true, privateWin);
+
+  // Cleanup
+  yield BrowserTestUtils.closeWindow(win);
+  yield BrowserTestUtils.closeWindow(privateWin);
+});