gecko/browser/components/sessionstore/test/browser_705597.js
Paul O’Shannessy d01afd64c7 Bug 743882 - Fix session restore tests for compartment-per-global [r=dietrich, r=ttaubert]
--HG--
extra : rebase_source : e7da9ad0458aaf76614888a9567e112541039332
2012-04-25 10:11:03 -04:00

58 lines
1.8 KiB
JavaScript

/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
let tabState = {
entries: [{url: "about:home", children: [{url: "about:mozilla"}]}]
};
function test() {
waitForExplicitFinish();
requestLongerTimeout(2);
Services.prefs.setIntPref("browser.sessionstore.interval", 4000);
registerCleanupFunction(function () {
Services.prefs.clearUserPref("browser.sessionstore.interval");
});
let tab = gBrowser.addTab("about:blank");
let browser = tab.linkedBrowser;
waitForTabState(tab, tabState, function () {
let sessionHistory = browser.sessionHistory;
let entry = sessionHistory.getEntryAtIndex(0, false);
entry.QueryInterface(Ci.nsISHContainer);
whenChildCount(entry, 1, function () {
whenChildCount(entry, 2, function () {
whenBrowserLoaded(browser, function () {
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" }] }]}]};
waitForBrowserState(blankState, finish);
});
// reload the browser to deprecate the subframes
browser.reload();
});
// 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(function () whenChildCount(aEntry, aChildCount, aCallback), 100);
}