Bug 1318867 - Listen for a LocationChange event after changing processes before flushing SessionStore, r=mikedeboer
authorMichael Layzell <michael@thelayzells.com>
Wed, 23 Nov 2016 17:08:17 -0500
changeset 324264 2e372790cc3595e78a624224ee05959e2c0817fe
parent 324263 bd1c7797c866664052fd18dfb8c7abd2ecce3a30
child 324265 c4669804cc496d815bc7438a19d3ef23459abc2f
push id24
push usermaklebus@msu.edu
push dateTue, 20 Dec 2016 03:11:33 +0000
reviewersmikedeboer
bugs1318867
milestone53.0a1
Bug 1318867 - Listen for a LocationChange event after changing processes before flushing SessionStore, r=mikedeboer MozReview-Commit-ID: GidwIVWEy2s
browser/components/sessionstore/test/browser_grouped_session_store.js
--- a/browser/components/sessionstore/test/browser_grouped_session_store.js
+++ b/browser/components/sessionstore/test/browser_grouped_session_store.js
@@ -21,28 +21,37 @@ add_task(function* () {
     is(history.entries.length, length, "Lengths match");
     for (let i = 0; i < length; ++i) {
       is(history.entries[i].url, URIs[i], "URI at index " + i + " matches");
     }
     is(history.index, index, "Index matches");
     yield ContentTask.spawn(browser, [index, length], function* ([index, length]) {
       let webNav = content.window.QueryInterface(Ci.nsIInterfaceRequestor)
             .getInterface(Ci.nsIWebNavigation);
+      is(webNav.sessionHistory.globalIndexOffset + webNav.sessionHistory.index,
+         index - 1, "In content index matches");
       is(webNav.canGoForward, index < length, "canGoForward is correct");
       is(webNav.canGoBack, index > 1, "canGoBack is correct");
     });
   }
 
-  // Wait for a process change and then fulfil the promise.
+  // Wait for a process change, followed by a locationchange event, and then
+  // fulfil the promise.
   function awaitProcessChange(browser) {
     return new Promise(resolve => {
+      let locChangeListener = {
+        onLocationChange: () => {
+          gBrowser.removeProgressListener(locChangeListener);
+          resolve();
+        },
+      };
+
       browser.addEventListener("BrowserChangedProcess", function bcp(e) {
         browser.removeEventListener("BrowserChangedProcess", bcp);
-        ok(true, "The browser changed process!");
-        resolve();
+        gBrowser.addProgressListener(locChangeListener);
       });
     });
   }
 
   // Order of events:
   // Load [0], load [1], prerender [2], load [2], load [3]
   // Back [2], Back [1], Forward [2], Back [0], Forward [3]
   // Prerender [4], Back [0], Forward [2], Load [3'], Back [0].