Bug 1319596 - Wait for first historychange when starting RDM. r=ochameau
☠☠ backed out by e61a652b3f58 ☠ ☠
authorJ. Ryan Stinnett <jryans@gmail.com>
Wed, 23 Nov 2016 16:35:17 -0600
changeset 324203 fe57f5f7b49d41f66f63427770a74891beb84f9b
parent 324202 950cb3cf22f0dc1cbcbd1fa300c03082c6024e01
child 324204 13406705508aea5243e69b42ab097c1e5948d1cf
push id24
push usermaklebus@msu.edu
push dateTue, 20 Dec 2016 03:11:33 +0000
reviewersochameau
bugs1319596, 1310771
milestone53.0a1
Bug 1319596 - Wait for first historychange when starting RDM. r=ochameau In bug 1310771, the session store process for gathering data from content was changed so that the key "historychange" is used instead of "history". Kept the check for "history" as well, since other places in session store still test for it. In addition, an RDM test is added to verify that a closed RDM tab is restored to the content page with RDM closed. MozReview-Commit-ID: 4wCjINTDUH8
devtools/client/responsive.html/browser/tunnel.js
devtools/client/responsive.html/test/browser/browser.ini
devtools/client/responsive.html/test/browser/browser_tab_restore.js
--- a/devtools/client/responsive.html/browser/tunnel.js
+++ b/devtools/client/responsive.html/browser/tunnel.js
@@ -307,17 +307,18 @@ function copyPermanentKey(outer, inner) 
   // outer browser (that we're hiding the inner browser within) as part of its history.
   // We want SessionStore's view of the history for our tab to only have the page content
   // of the inner browser, so we want to hide this message from SessionStore, but we have
   // no direct mechanism to do so.  As a workaround, we wait until the one errant message
   // has gone by, and then we copy the permanentKey after that, since the permanentKey is
   // what SessionStore uses to identify each browser.
   let outerMM = outer[FRAME_LOADER].messageManager;
   let onHistoryEntry = message => {
-    let history = message.data.data.history;
+    let data = message.data.data;
+    let history = data.history || data.historychange;
     if (!history || !history.entries) {
       // Wait for a message that contains history data
       return;
     }
     outerMM.removeMessageListener("SessionStore:update", onHistoryEntry);
     debug("Got session update for outer browser");
     DevToolsUtils.executeSoon(() => {
       debug("Copy inner permanentKey to outer browser");
--- a/devtools/client/responsive.html/test/browser/browser.ini
+++ b/devtools/client/responsive.html/test/browser/browser.ini
@@ -29,15 +29,16 @@ support-files =
 [browser_mouse_resize.js]
 [browser_navigation.js]
 [browser_network_throttling.js]
 [browser_page_state.js]
 [browser_permission_doorhanger.js]
 [browser_resize_cmd.js]
 [browser_screenshot_button.js]
 [browser_tab_close.js]
+[browser_tab_restore.js]
 [browser_tab_remoteness_change.js]
 [browser_toolbox_computed_view.js]
 [browser_toolbox_rule_view.js]
 [browser_toolbox_swap_browsers.js]
 [browser_touch_simulation.js]
 [browser_viewport_basics.js]
 [browser_window_close.js]
new file mode 100644
--- /dev/null
+++ b/devtools/client/responsive.html/test/browser/browser_tab_restore.js
@@ -0,0 +1,30 @@
+/* Any copyright is dedicated to the Public Domain.
+   http://creativecommons.org/publicdomain/zero/1.0/ */
+
+"use strict";
+
+// Verify RDM tab reopens to content (with RDM closed) when restoring the tab.
+
+const TEST_URL = "http://example.com/";
+
+const ss = Cc["@mozilla.org/browser/sessionstore;1"].getService(Ci.nsISessionStore);
+const { TabStateFlusher } = Cu.import("resource:///modules/sessionstore/TabStateFlusher.jsm", {});
+
+add_task(function* () {
+  // Open tab, start RDM, close tab
+  let tab = yield addTab(TEST_URL);
+  // Ensure tab state is flushed to session store before closing (so it can be restored)
+  yield TabStateFlusher.flush(tab.linkedBrowser);
+  let { ui } = yield openRDM(tab);
+  yield removeTab(tab);
+  is(ui.destroyed, true, "RDM closed");
+
+  // Restore tab
+  tab = ss.undoCloseTab(window, 0);
+  yield once(tab, "SSTabRestored");
+
+  // Check location
+  is(tab.linkedBrowser.documentURI.spec, TEST_URL, "Restored tab location to test page");
+
+  yield removeTab(tab);
+});