Bug 965697 - Fix intermittent browser_sessionHistory.js failures by waiting until the history entry has been replaced. r=smacleod, a=test-only
authorTim Taubert <ttaubert@mozilla.com>
Mon, 07 Jul 2014 14:11:17 -0400
changeset 208816 017a6f2c9952c904dc399215d1f9691867eebde8
parent 208815 677e0185c2b4dd572032a663968b2fe838b87f67
child 208817 33a9fab0bca3cbdd219dba553e8132385fe24a46
push id494
push userraliiev@mozilla.com
push dateMon, 25 Aug 2014 18:42:16 +0000
treeherdermozilla-release@a3cc3e46b571 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssmacleod, test-only
bugs965697
milestone32.0a2
Bug 965697 - Fix intermittent browser_sessionHistory.js failures by waiting until the history entry has been replaced. r=smacleod, a=test-only
browser/components/sessionstore/test/browser_sessionHistory.js
browser/components/sessionstore/test/content.js
--- a/browser/components/sessionstore/test/browser_sessionHistory.js
+++ b/browser/components/sessionstore/test/browser_sessionHistory.js
@@ -9,17 +9,17 @@
 add_task(function test_load_start() {
   // Create a new tab.
   let tab = gBrowser.addTab("about:blank");
   let browser = tab.linkedBrowser;
   yield promiseBrowserLoaded(browser);
 
   // Load a new URI but remove the tab before it has finished loading.
   browser.loadURI("about:mozilla");
-  yield promiseContentMessage(browser, "ss-test:onFrameTreeReset");
+  yield promiseContentMessage(browser, "ss-test:OnHistoryReplaceEntry");
   gBrowser.removeTab(tab);
 
   // Undo close the tab.
   tab = ss.undoCloseTab(window, 0);
   browser = tab.linkedBrowser;
   yield promiseBrowserLoaded(browser);
 
   // Check that the correct URL was restored.
--- a/browser/components/sessionstore/test/content.js
+++ b/browser/components/sessionstore/test/content.js
@@ -2,29 +2,71 @@
  * 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/. */
 
 "use strict";
 
 let Cu = Components.utils;
 let Ci = Components.interfaces;
 
+Cu.import("resource://gre/modules/XPCOMUtils.jsm");
 Cu.import("resource:///modules/sessionstore/FrameTree.jsm", this);
 let gFrameTree = new FrameTree(this);
 
 gFrameTree.addObserver({
   onFrameTreeReset: function () {
     sendAsyncMessage("ss-test:onFrameTreeReset");
   },
 
   onFrameTreeCollected: function () {
     sendAsyncMessage("ss-test:onFrameTreeCollected");
   }
 });
 
+let webNav = docShell.QueryInterface(Ci.nsIWebNavigation);
+webNav.sessionHistory.addSHistoryListener({
+  OnHistoryNewEntry: function () {
+    sendAsyncMessage("ss-test:OnHistoryNewEntry");
+  },
+
+  OnHistoryGoBack: function () {
+    sendAsyncMessage("ss-test:OnHistoryGoBack");
+    return true;
+  },
+
+  OnHistoryGoForward: function () {
+    sendAsyncMessage("ss-test:OnHistoryGoForward");
+    return true;
+  },
+
+  OnHistoryGotoIndex: function () {
+    sendAsyncMessage("ss-test:OnHistoryGotoIndex");
+    return true;
+  },
+
+  OnHistoryPurge: function () {
+    sendAsyncMessage("ss-test:OnHistoryPurge");
+    return true;
+  },
+
+  OnHistoryReload: function () {
+    sendAsyncMessage("ss-test:OnHistoryReload");
+    return true;
+  },
+
+  OnHistoryReplaceEntry: function () {
+    sendAsyncMessage("ss-test:OnHistoryReplaceEntry");
+  },
+
+  QueryInterface: XPCOMUtils.generateQI([
+    Ci.nsISHistoryListener,
+    Ci.nsISupportsWeakReference
+  ])
+});
+
 /**
  * This frame script is only loaded for sessionstore mochitests. It enables us
  * to modify and query docShell data when running with multiple processes.
  */
 
 addEventListener("hashchange", function () {
   sendAsyncMessage("ss-test:hashchange");
 });