fune/browser/components/sessionstore/test/browser_705597.js
Nicholas Nethercote 8cb0711355 Bug 1485279 - Merge nsISHContainer into nsISHEntry. r=qdot
nsSHEntry is the only class that instantiates those two interfaces, so the
separation is not useful. This lets us remove numerous pointless QIs.

--HG--
extra : rebase_source : 570b7ade669fb89a789184198bec9da186c5f1d3
2018-08-22 19:20:56 +10:00

62 lines
2.1 KiB
JavaScript

/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
/* eslint-disable mozilla/no-arbitrary-setTimeout */
var tabState = {
entries: [{
url: "about:robots",
triggeringPrincipal_base64,
children: [{url: "about:mozilla", triggeringPrincipal_base64}]}]
};
function test() {
waitForExplicitFinish();
requestLongerTimeout(2);
Services.prefs.setIntPref("browser.sessionstore.interval", 4000);
registerCleanupFunction(function() {
Services.prefs.clearUserPref("browser.sessionstore.interval");
});
let tab = BrowserTestUtils.addTab(gBrowser, "about:blank");
let browser = tab.linkedBrowser;
promiseTabState(tab, tabState).then(() => {
let sessionHistory = browser.sessionHistory;
let entry = sessionHistory.legacySHistory.getEntryAtIndex(0, false);
whenChildCount(entry, 1, function() {
whenChildCount(entry, 2, function() {
promiseBrowserLoaded(browser).then(() => {
return TabStateFlusher.flush(browser);
}).then(() => {
let {entries} = JSON.parse(ss.getTabState(tab));
is(entries.length, 1, "tab has one history entry");
ok(!entries[0].children, "history entry has no subframes");
// Make sure that we reset the state.
let blankState = { windows: [{ tabs: [{ entries: [{ url: "about:blank",
triggeringPrincipal_base64}] }]}]};
waitForBrowserState(blankState, finish);
});
// Force reload the browser to deprecate the subframes.
browser.reloadWithFlags(Ci.nsIWebNavigation.LOAD_FLAGS_BYPASS_CACHE);
});
// Create a dynamic subframe.
let doc = browser.contentDocument;
let iframe = doc.createElement("iframe");
doc.body.appendChild(iframe);
iframe.setAttribute("src", "about:mozilla");
});
});
}
function whenChildCount(aEntry, aChildCount, aCallback) {
if (aEntry.childCount == aChildCount)
aCallback();
else
setTimeout(() => whenChildCount(aEntry, aChildCount, aCallback), 100);
}