michael@0: /* Any copyright is dedicated to the Public Domain. michael@0: http://creativecommons.org/publicdomain/zero/1.0/ */ michael@0: michael@0: let tabState = { michael@0: entries: [{url: "about:robots", children: [{url: "about:mozilla"}]}] michael@0: }; michael@0: michael@0: function test() { michael@0: waitForExplicitFinish(); michael@0: requestLongerTimeout(2); michael@0: michael@0: Services.prefs.setIntPref("browser.sessionstore.interval", 4000); michael@0: registerCleanupFunction(function () { michael@0: Services.prefs.clearUserPref("browser.sessionstore.interval"); michael@0: }); michael@0: michael@0: let tab = gBrowser.addTab("about:blank"); michael@0: michael@0: let browser = tab.linkedBrowser; michael@0: michael@0: waitForTabState(tab, tabState, function() { michael@0: michael@0: let sessionHistory = browser.sessionHistory; michael@0: let entry = sessionHistory.getEntryAtIndex(0, false); michael@0: entry.QueryInterface(Ci.nsISHContainer); michael@0: michael@0: whenChildCount(entry, 1, function () { michael@0: whenChildCount(entry, 2, function () { michael@0: whenBrowserLoaded(browser, function () { michael@0: let sessionHistory = browser.sessionHistory; michael@0: let entry = sessionHistory.getEntryAtIndex(0, false); michael@0: michael@0: whenChildCount(entry, 0, function () { michael@0: // Make sure that we reset the state. michael@0: let blankState = { windows: [{ tabs: [{ entries: [{ url: "about:blank" }] }]}]}; michael@0: waitForBrowserState(blankState, finish); michael@0: }); michael@0: }); michael@0: michael@0: // reload the browser to deprecate the subframes michael@0: browser.reload(); michael@0: }); michael@0: michael@0: // create a dynamic subframe michael@0: let doc = browser.contentDocument; michael@0: let iframe = doc.createElement("iframe"); michael@0: doc.body.appendChild(iframe); michael@0: iframe.setAttribute("src", "about:mozilla"); michael@0: }); michael@0: }); michael@0: } michael@0: michael@0: function whenChildCount(aEntry, aChildCount, aCallback) { michael@0: if (aEntry.childCount == aChildCount) michael@0: aCallback(); michael@0: else michael@0: setTimeout(function () whenChildCount(aEntry, aChildCount, aCallback), 100); michael@0: }