mirror of
https://github.com/HeyPuter/firefox.git
synced 2026-11-25 15:43:10 -10:00
In bug 1313933, we removed the session store black magic that RDM used to do in order to hide the container tab. Unfortunately, that fix appears to have been imperfect. Session store has a fallback path that can still record the current URL, causing the container URL to be recorded anyway, even though we asked nicely to please not do that. In this change, we try a fresh approach of wedging the session history listener for the container tab so it can't record anything. This avoids the racy approach that was used before bug 1313933 while still appearing to block the container URL from being recorded. MozReview-Commit-ID: JZTYzMAvaEM
65 lines
2.3 KiB
JavaScript
65 lines
2.3 KiB
JavaScript
/* 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);
|
|
});
|