Bug 1132566 - Make test e10s compatible: browser_privatebrowsing_localStorage.js; r=billm
authorSteven MacLeod <smacleod@mozilla.com>
Thu, 05 Mar 2015 13:43:38 -0500
changeset 233830 36478f270e8809213c1996b643e90771ef081e44
parent 233829 bd4ad6d4d52aa12a082ac5cb422d9d9b5486f74d
child 233831 f20eb0510848f08755ae71adae73c0eabc0ca761
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)
reviewersbillm
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_localStorage.js; r=billm
browser/components/privatebrowsing/test/browser/browser.ini
browser/components/privatebrowsing/test/browser/browser_privatebrowsing_localStorage.js
--- a/browser/components/privatebrowsing/test/browser/browser.ini
+++ b/browser/components/privatebrowsing/test/browser/browser.ini
@@ -28,17 +28,16 @@ skip-if = e10s
 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]
 [browser_privatebrowsing_lastpbcontextexited.js]
 [browser_privatebrowsing_localStorage.js]
-skip-if = e10s
 [browser_privatebrowsing_localStorage_before_after.js]
 skip-if = e10s
 [browser_privatebrowsing_noSessionRestoreMenuOption.js]
 skip-if = e10s
 [browser_privatebrowsing_nonbrowser.js]
 skip-if = e10s
 [browser_privatebrowsing_opendir.js]
 skip-if = e10s
--- a/browser/components/privatebrowsing/test/browser/browser_privatebrowsing_localStorage.js
+++ b/browser/components/privatebrowsing/test/browser/browser_privatebrowsing_localStorage.js
@@ -1,54 +1,25 @@
 /* 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/. */
 
-function test() {
+ add_task(function test() {
   requestLongerTimeout(2);
-  waitForExplicitFinish();
-
   const page1 = 'http://mochi.test:8888/browser/browser/components/privatebrowsing/test/browser/' +
                 'browser_privatebrowsing_localStorage_page1.html'
 
-  function checkLocalStorage(aWindow, aCallback) {
-    executeSoon(function() {
-      let tab = aWindow.gBrowser.selectedTab = aWindow.gBrowser.addTab();
-      let browser = aWindow.gBrowser.selectedBrowser;
-      browser.addEventListener('load', function() {
-        if (browser.contentWindow.location != page1) {
-          browser.loadURI(page1);
-          return;
-        }
-        browser.removeEventListener('load', arguments.callee, true);
-        let tab2 = aWindow.gBrowser.selectedTab = aWindow.gBrowser.addTab();
-        browser.contentWindow.location = 'http://mochi.test:8888/browser/browser/components/privatebrowsing/test/browser/' +
-                         'browser_privatebrowsing_localStorage_page2.html';
-        browser.addEventListener('load', function() {
-          browser.removeEventListener('load', arguments.callee, true);
-          is(browser.contentWindow.document.title, '2', "localStorage should contain 2 items");
-          aCallback();
-        }, true);
-      }, true);
-    });
-  }
+  let win = yield BrowserTestUtils.openNewBrowserWindow({private: true});
+
+  let tab = win.gBrowser.selectedTab = win.gBrowser.addTab(page1);
+  let browser = win.gBrowser.selectedBrowser;
+  yield BrowserTestUtils.browserLoaded(browser);
 
-  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);
-  };
+  browser.loadURI(
+    'http://mochi.test:8888/browser/browser/components/privatebrowsing/test/browser/' +
+    'browser_privatebrowsing_localStorage_page2.html');
+  yield BrowserTestUtils.browserLoaded(browser);
 
-  registerCleanupFunction(function() {
-    windowsToClose.forEach(function(win) {
-      win.close();
-    });
-  });
+  is(browser.contentTitle, '2', "localStorage should contain 2 items");
 
-  testOnWindow({private: true}, function(win) {
-    checkLocalStorage(win, finish);
-  });
-
-}
+  // Cleanup
+  yield BrowserTestUtils.closeWindow(win);
+ });