Backed out changeset a9bdcbca4218 (bug 1352814) for various RDM test failures.
authorRyan VanderMeulen <ryanvm@gmail.com>
Mon, 24 Apr 2017 16:56:51 -0400
changeset 393686 953ebf1c32152dca8b633aa8d5a3fe3e684a56c5
parent 393685 29dc135a663736818cc4106c2f4dfb35b08682ae
child 393687 ca3c6131b6eadf753445b3cd7a54e29b41ab11aa
push id7231
push userryanvm@gmail.com
push dateMon, 24 Apr 2017 20:56:58 +0000
treeherdermozilla-beta@953ebf1c3215 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs1352814
milestone54.0
backs outa9bdcbca4218cac28516e3a0e5385ff5202143a3
Backed out changeset a9bdcbca4218 (bug 1352814) for various RDM test failures.
devtools/client/responsive.html/browser/swap.js
devtools/client/responsive.html/browser/tunnel.js
devtools/client/responsive.html/test/browser/browser.ini
devtools/client/responsive.html/test/browser/browser_hide_container.js
devtools/client/responsive.html/test/browser/browser_navigation.js
devtools/client/responsive.html/test/browser/browser_page_state.js
devtools/client/responsive.html/test/browser/head.js
--- a/devtools/client/responsive.html/browser/swap.js
+++ b/devtools/client/responsive.html/browser/swap.js
@@ -64,29 +64,16 @@ function swapToInnerBrowser({ tab, conta
 
       // 1. Create a temporary, hidden tab to load the tool UI.
       let containerTab = gBrowser.addTab("about:blank", {
         skipAnimation: true,
         forceNotRemote: true,
       });
       gBrowser.hideTab(containerTab);
       let containerBrowser = containerTab.linkedBrowser;
-      // Even though we load the `containerURL` with `LOAD_FLAGS_BYPASS_HISTORY` below,
-      // `SessionHistory.jsm` has a fallback path for tabs with no history which
-      // fabricates a history entry by reading the current URL, and this can cause the
-      // container URL to be recorded in the session store.  To avoid this, we send a
-      // bogus `epoch` value to our container tab, which causes all future history
-      // messages to be ignored.  (Actual navigations are still correctly recorded because
-      // this only affects the container frame, not the content.)  A better fix would be
-      // to just not load the `content-sessionStore.js` frame script at all in the
-      // container tab, but it's loaded for all tab browsers, so this seems a bit harder
-      // to achieve in a nice way.
-      containerBrowser.messageManager.sendAsyncMessage("SessionStore:flush", {
-        epoch: -1,
-      });
       // Prevent the `containerURL` from ending up in the tab's history.
       containerBrowser.loadURIWithFlags(containerURL, {
         flags: Ci.nsIWebNavigation.LOAD_FLAGS_BYPASS_HISTORY,
       });
 
       // Copy tab listener state flags to container tab.  Each tab gets its own tab
       // listener and state flags which cache document loading progress.  The state flags
       // are checked when switching tabs to update the browser UI.  The later step of
--- a/devtools/client/responsive.html/browser/tunnel.js
+++ b/devtools/client/responsive.html/browser/tunnel.js
@@ -7,18 +7,16 @@
 const { Ci } = require("chrome");
 const Services = require("Services");
 const { Task } = require("devtools/shared/task");
 const { BrowserElementWebNavigation } = require("./web-navigation");
 const { getStack } = require("devtools/shared/platform/stack");
 
 // A symbol used to hold onto the frame loader from the outer browser while tunneling.
 const FRAME_LOADER = Symbol("devtools/responsive/frame-loader");
-// Export for use in tests.
-exports.OUTER_FRAME_LOADER_SYMBOL = FRAME_LOADER;
 
 function debug(msg) {
   // console.log(msg);
 }
 
 /**
  * Properties swapped between browsers by browser.xml's `swapDocShells`.  See also the
  * list at /devtools/client/responsive.html/docs/browser-swap.md.
--- a/devtools/client/responsive.html/test/browser/browser.ini
+++ b/devtools/client/responsive.html/test/browser/browser.ini
@@ -20,17 +20,16 @@ support-files =
 [browser_device_custom.js]
 [browser_device_modal_error.js]
 [browser_device_modal_exit.js]
 [browser_device_modal_submit.js]
 [browser_device_width.js]
 [browser_dpr_change.js]
 [browser_exit_button.js]
 [browser_frame_script_active.js]
-[browser_hide_container.js]
 [browser_menu_item_01.js]
 [browser_menu_item_02.js]
 [browser_mouse_resize.js]
 [browser_navigation.js]
 [browser_network_throttling.js]
 [browser_page_state.js]
 [browser_permission_doorhanger.js]
 [browser_resize_cmd.js]
deleted file mode 100644
--- a/devtools/client/responsive.html/test/browser/browser_hide_container.js
+++ /dev/null
@@ -1,64 +0,0 @@
-/* Any copyright is dedicated to the Public Domain.
-   http://creativecommons.org/publicdomain/zero/1.0/ */
-
-"use strict";
-
-// Ensure that the RDM container tab URL is not recorded in session history.
-
-const TEST_URL = "http://example.com/";
-const CONTAINER_URL = "chrome://devtools/content/responsive.html/index.xhtml";
-
-const { TabStateFlusher } =
-  Cu.import("resource:///modules/sessionstore/TabStateFlusher.jsm", {});
-const SessionStore =
-  Cc["@mozilla.org/browser/sessionstore;1"].getService(Ci.nsISessionStore);
-const { OUTER_FRAME_LOADER_SYMBOL } =
-  require("devtools/client/responsive.html/browser/tunnel");
-
-function flushContainerTabState(tab) {
-  let browser = tab.linkedBrowser;
-  let outerBrowser = {
-    permanentKey: browser.permanentKey,
-    messageManager: browser[OUTER_FRAME_LOADER_SYMBOL].messageManager,
-  };
-  // Try to flush the tab, but if that hangs for a while, resolve anyway.
-  // During this test, we actually expect this to hang because the container tab
-  // doesn't have the right epoch value to reply to the flush correctly.
-  return new Promise(resolve => {
-    TabStateFlusher.flush(outerBrowser).then(resolve);
-    waitForTime(10000).then(resolve);
-  });
-}
-
-add_task(function* () {
-  // Load test URL
-  let tab = yield addTab(TEST_URL);
-  let browser = tab.linkedBrowser;
-
-  // Check session history state
-  let history = yield getSessionHistory(browser);
-  is(history.index - 1, 0, "At page 0 in history");
-  is(history.entries.length, 1, "1 page in history");
-  is(history.entries[0].url, TEST_URL, "Page 0 URL matches");
-
-  // Open RDM
-  yield openRDM(tab);
-
-  // Checking session history directly in content does show the container URL
-  // that we're trying to hide...
-  history = yield getSessionHistory(browser);
-  is(history.index - 1, 0, "At page 0 in history");
-  is(history.entries.length, 1, "1 page in history");
-  is(history.entries[0].url, CONTAINER_URL, "Page 0 URL matches");
-
-  // However, checking the recorded tab state for the outer browser shows the
-  // container URL has been ignored correctly.
-  yield flushContainerTabState(tab);
-  let tabState = JSON.parse(SessionStore.getTabState(tab));
-  is(tabState.index - 1, 0, "At page 0 in history");
-  is(tabState.entries.length, 1, "1 page in history");
-  is(tabState.entries[0].url, TEST_URL, "Page 0 URL matches");
-
-  yield closeRDM(tab);
-  yield removeTab(tab);
-});
--- a/devtools/client/responsive.html/test/browser/browser_navigation.js
+++ b/devtools/client/responsive.html/test/browser/browser_navigation.js
@@ -17,32 +17,32 @@ add_task(function* () {
   // 2. DUMMY_2_URL
   let tab = yield addTab(DUMMY_1_URL);
   let browser = tab.linkedBrowser;
   yield load(browser, TEST_URL);
   yield load(browser, DUMMY_2_URL);
 
   // Check session history state
   let history = yield getSessionHistory(browser);
-  is(history.index - 1, 2, "At page 2 in history");
+  is(history.index, 2, "At page 2 in history");
   is(history.entries.length, 3, "3 pages in history");
-  is(history.entries[0].url, DUMMY_1_URL, "Page 0 URL matches");
-  is(history.entries[1].url, TEST_URL, "Page 1 URL matches");
-  is(history.entries[2].url, DUMMY_2_URL, "Page 2 URL matches");
+  is(history.entries[0].uri, DUMMY_1_URL, "Page 0 URL matches");
+  is(history.entries[1].uri, TEST_URL, "Page 1 URL matches");
+  is(history.entries[2].uri, DUMMY_2_URL, "Page 2 URL matches");
 
   // Go back one so we're at the test page
   yield back(browser);
 
   // Check session history state
   history = yield getSessionHistory(browser);
-  is(history.index - 1, 1, "At page 1 in history");
+  is(history.index, 1, "At page 1 in history");
   is(history.entries.length, 3, "3 pages in history");
-  is(history.entries[0].url, DUMMY_1_URL, "Page 0 URL matches");
-  is(history.entries[1].url, TEST_URL, "Page 1 URL matches");
-  is(history.entries[2].url, DUMMY_2_URL, "Page 2 URL matches");
+  is(history.entries[0].uri, DUMMY_1_URL, "Page 0 URL matches");
+  is(history.entries[1].uri, TEST_URL, "Page 1 URL matches");
+  is(history.entries[2].uri, DUMMY_2_URL, "Page 2 URL matches");
 
   yield openRDM(tab);
 
   ok(browser.webNavigation.canGoBack, "Going back is allowed");
   ok(browser.webNavigation.canGoForward, "Going forward is allowed");
   is(browser.documentURI.spec, TEST_URL, "documentURI matches page 1");
   is(browser.contentTitle, "Page State Test", "contentTitle matches page 1");
 
@@ -84,15 +84,15 @@ add_task(function* () {
   is(browser.documentURI.spec, DUMMY_3_URL, "documentURI matches page 3");
   is(browser.contentTitle, "mochitest index /browser/devtools/",
      "contentTitle matches page 3");
 
   yield closeRDM(tab);
 
   // Check session history state
   history = yield getSessionHistory(browser);
-  is(history.index - 1, 1, "At page 1 in history");
+  is(history.index, 1, "At page 1 in history");
   is(history.entries.length, 2, "2 pages in history");
-  is(history.entries[0].url, DUMMY_1_URL, "Page 0 URL matches");
-  is(history.entries[1].url, DUMMY_3_URL, "Page 1 URL matches");
+  is(history.entries[0].uri, DUMMY_1_URL, "Page 0 URL matches");
+  is(history.entries[1].uri, DUMMY_3_URL, "Page 1 URL matches");
 
   yield removeTab(tab);
 });
--- a/devtools/client/responsive.html/test/browser/browser_page_state.js
+++ b/devtools/client/responsive.html/test/browser/browser_page_state.js
@@ -17,32 +17,32 @@ add_task(function* () {
   // 2. DUMMY_2_URL
   let tab = yield addTab(DUMMY_1_URL);
   let browser = tab.linkedBrowser;
   yield load(browser, TEST_URL);
   yield load(browser, DUMMY_2_URL);
 
   // Check session history state
   let history = yield getSessionHistory(browser);
-  is(history.index - 1, 2, "At page 2 in history");
+  is(history.index, 2, "At page 2 in history");
   is(history.entries.length, 3, "3 pages in history");
-  is(history.entries[0].url, DUMMY_1_URL, "Page 0 URL matches");
-  is(history.entries[1].url, TEST_URL, "Page 1 URL matches");
-  is(history.entries[2].url, DUMMY_2_URL, "Page 2 URL matches");
+  is(history.entries[0].uri, DUMMY_1_URL, "Page 0 URL matches");
+  is(history.entries[1].uri, TEST_URL, "Page 1 URL matches");
+  is(history.entries[2].uri, DUMMY_2_URL, "Page 2 URL matches");
 
   // Go back one so we're at the test page
   yield back(browser);
 
   // Check session history state
   history = yield getSessionHistory(browser);
-  is(history.index - 1, 1, "At page 1 in history");
+  is(history.index, 1, "At page 1 in history");
   is(history.entries.length, 3, "3 pages in history");
-  is(history.entries[0].url, DUMMY_1_URL, "Page 0 URL matches");
-  is(history.entries[1].url, TEST_URL, "Page 1 URL matches");
-  is(history.entries[2].url, DUMMY_2_URL, "Page 2 URL matches");
+  is(history.entries[0].uri, DUMMY_1_URL, "Page 0 URL matches");
+  is(history.entries[1].uri, TEST_URL, "Page 1 URL matches");
+  is(history.entries[2].uri, DUMMY_2_URL, "Page 2 URL matches");
 
   // Click on content to set an altered state that would be lost on reload
   yield BrowserTestUtils.synthesizeMouseAtCenter("body", {}, browser);
 
   let { ui } = yield openRDM(tab);
 
   // Check color inside the viewport
   let color = yield spawnViewportTask(ui, {}, function* () {
@@ -61,16 +61,16 @@ add_task(function* () {
     return content.getComputedStyle(content.document.body)
                   .getPropertyValue("background-color");
   });
   is(color, "rgb(0, 128, 0)",
      "Content is still modified from click in browser tab");
 
   // Check session history state
   history = yield getSessionHistory(browser);
-  is(history.index - 1, 1, "At page 1 in history");
+  is(history.index, 1, "At page 1 in history");
   is(history.entries.length, 3, "3 pages in history");
-  is(history.entries[0].url, DUMMY_1_URL, "Page 0 URL matches");
-  is(history.entries[1].url, TEST_URL, "Page 1 URL matches");
-  is(history.entries[2].url, DUMMY_2_URL, "Page 2 URL matches");
+  is(history.entries[0].uri, DUMMY_1_URL, "Page 0 URL matches");
+  is(history.entries[1].uri, TEST_URL, "Page 1 URL matches");
+  is(history.entries[2].uri, DUMMY_2_URL, "Page 2 URL matches");
 
   yield removeTab(tab);
 });
--- a/devtools/client/responsive.html/test/browser/head.js
+++ b/devtools/client/responsive.html/test/browser/head.js
@@ -270,20 +270,33 @@ const selectDPR = (ui, value) =>
 const selectNetworkThrottling = (ui, value) => Promise.all([
   once(ui, "network-throttling-changed"),
   changeSelectValue(ui, "#global-network-throttling-selector", value)
 ]);
 
 function getSessionHistory(browser) {
   return ContentTask.spawn(browser, {}, function* () {
     /* eslint-disable no-undef */
-    let { utils: Cu } = Components;
-    const { SessionHistory } =
-      Cu.import("resource://gre/modules/sessionstore/SessionHistory.jsm", {});
-    return SessionHistory.collect(docShell);
+    let { interfaces: Ci } = Components;
+    let webNav = docShell.QueryInterface(Ci.nsIWebNavigation);
+    let sessionHistory = webNav.sessionHistory;
+    let result = {
+      index: sessionHistory.index,
+      entries: []
+    };
+
+    for (let i = 0; i < sessionHistory.count; i++) {
+      let entry = sessionHistory.getEntryAtIndex(i, false);
+      result.entries.push({
+        uri: entry.URI.spec,
+        title: entry.title
+      });
+    }
+
+    return result;
     /* eslint-enable no-undef */
   });
 }
 
 function getContentSize(ui) {
   return spawnViewportTask(ui, {}, () => ({
     width: content.screen.width,
     height: content.screen.height