Bug 1047603 - Make SessionStore test browser_423132.js wait for new e10s window tab to be restored. r=ttaubert.
authorMike Conley <mconley@mozilla.com>
Fri, 06 Feb 2015 09:33:41 -0500
changeset 228527 ed3e996b3805c641dbda53c83907f87d3302995a
parent 228526 179ab8bb80aeb209b9c7ce2565defa1395ed9e02
child 228528 e9f7e2678bfb4437ec88669970d20a6f7c8aba07
push id28264
push usercbook@mozilla.com
push dateWed, 11 Feb 2015 13:58:35 +0000
treeherdermozilla-central@38058cb42a0e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersttaubert
bugs1047603
milestone38.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 1047603 - Make SessionStore test browser_423132.js wait for new e10s window tab to be restored. r=ttaubert. Like browser_394759_behaviour.js, this test wasn't accustomed to newly created windows having initially non-remote browsers, and that we need to wait for them to redirect and restore in the content process before we can properly serialize the window and its cookies.
browser/components/sessionstore/test/browser_423132.js
--- a/browser/components/sessionstore/test/browser_423132.js
+++ b/browser/components/sessionstore/test/browser_423132.js
@@ -25,51 +25,60 @@ function test() {
   newWin.addEventListener("load", function (aEvent) {
     newWin.removeEventListener("load", arguments.callee, false);
 
     // Wait for sessionstore to be ready to restore this window
     executeSoon(function() {
       newWin.gBrowser.loadURI(testURL, null, null);
 
       promiseBrowserLoaded(newWin.gBrowser.selectedBrowser).then(() => {
-        // get the sessionstore state for the window
-        TabState.flush(newWin.gBrowser.selectedBrowser);
-        let state = ss.getWindowState(newWin);
+        let ready = () => {
+          // get the sessionstore state for the window
+          TabState.flush(newWin.gBrowser.selectedBrowser);
+          let state = ss.getWindowState(newWin);
 
-        // verify our cookie got set during pageload
-        let e = cs.enumerator;
-        let cookie;
-        let i = 0;
-        while (e.hasMoreElements()) {
-          cookie = e.getNext().QueryInterface(Ci.nsICookie);
-          i++;
-        }
-        is(i, 1, "expected one cookie");
+          // verify our cookie got set during pageload
+          let e = cs.enumerator;
+          let cookie;
+          let i = 0;
+          while (e.hasMoreElements()) {
+            cookie = e.getNext().QueryInterface(Ci.nsICookie);
+            i++;
+          }
+          is(i, 1, "expected one cookie");
 
-        // remove the cookie
-        cs.removeAll();
+          // remove the cookie
+          cs.removeAll();
+
+          // restore the window state
+          ss.setWindowState(newWin, state, true);
 
-        // restore the window state
-        ss.setWindowState(newWin, state, true);
+          // at this point, the cookie should be restored...
+          e = cs.enumerator;
+          let cookie2;
+          while (e.hasMoreElements()) {
+            cookie2 = e.getNext().QueryInterface(Ci.nsICookie);
+            if (cookie.name == cookie2.name)
+              break;
+          }
+          is(cookie.name, cookie2.name, "cookie name successfully restored");
+          is(cookie.value, cookie2.value, "cookie value successfully restored");
+          is(cookie.path, cookie2.path, "cookie path successfully restored");
 
-        // at this point, the cookie should be restored...
-        e = cs.enumerator;
-        let cookie2;
-        while (e.hasMoreElements()) {
-          cookie2 = e.getNext().QueryInterface(Ci.nsICookie);
-          if (cookie.name == cookie2.name)
-            break;
+          // clean up
+          if (gPrefService.prefHasUserValue("browser.sessionstore.interval"))
+            gPrefService.clearUserPref("browser.sessionstore.interval");
+          cs.removeAll();
+          newWin.close();
+          finish();
+        };
+
+        if (newWin.gMultiProcessBrowser) {
+          let tab = newWin.gBrowser.selectedTab;
+          promiseTabRestored(tab).then(ready);
+        } else {
+          ready();
         }
-        is(cookie.name, cookie2.name, "cookie name successfully restored");
-        is(cookie.value, cookie2.value, "cookie value successfully restored");
-        is(cookie.path, cookie2.path, "cookie path successfully restored");
-
-        // clean up
-        if (gPrefService.prefHasUserValue("browser.sessionstore.interval"))
-          gPrefService.clearUserPref("browser.sessionstore.interval");
-        cs.removeAll();
-        newWin.close();
-        finish();
       }, true, testURL);
     });
   }, false);
 }