Thu, 22 Jan 2015 13:21:57 +0100
Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6
michael@0 | 1 | /* Any copyright is dedicated to the Public Domain. |
michael@0 | 2 | http://creativecommons.org/publicdomain/zero/1.0/ */ |
michael@0 | 3 | |
michael@0 | 4 | let tabState = { |
michael@0 | 5 | entries: [{url: "about:robots", children: [{url: "about:mozilla"}]}] |
michael@0 | 6 | }; |
michael@0 | 7 | |
michael@0 | 8 | function test() { |
michael@0 | 9 | waitForExplicitFinish(); |
michael@0 | 10 | requestLongerTimeout(2); |
michael@0 | 11 | |
michael@0 | 12 | Services.prefs.setIntPref("browser.sessionstore.interval", 4000); |
michael@0 | 13 | registerCleanupFunction(function () { |
michael@0 | 14 | Services.prefs.clearUserPref("browser.sessionstore.interval"); |
michael@0 | 15 | }); |
michael@0 | 16 | |
michael@0 | 17 | let tab = gBrowser.addTab("about:blank"); |
michael@0 | 18 | |
michael@0 | 19 | let browser = tab.linkedBrowser; |
michael@0 | 20 | |
michael@0 | 21 | waitForTabState(tab, tabState, function () { |
michael@0 | 22 | |
michael@0 | 23 | let sessionHistory = browser.sessionHistory; |
michael@0 | 24 | let entry = sessionHistory.getEntryAtIndex(0, false); |
michael@0 | 25 | entry.QueryInterface(Ci.nsISHContainer); |
michael@0 | 26 | |
michael@0 | 27 | whenChildCount(entry, 1, function () { |
michael@0 | 28 | whenChildCount(entry, 2, function () { |
michael@0 | 29 | whenBrowserLoaded(browser, function () { |
michael@0 | 30 | SyncHandlers.get(browser).flush(); |
michael@0 | 31 | let {entries} = JSON.parse(ss.getTabState(tab)); |
michael@0 | 32 | is(entries.length, 1, "tab has one history entry"); |
michael@0 | 33 | ok(!entries[0].children, "history entry has no subframes"); |
michael@0 | 34 | |
michael@0 | 35 | // Make sure that we reset the state. |
michael@0 | 36 | let blankState = { windows: [{ tabs: [{ entries: [{ url: "about:blank" }] }]}]}; |
michael@0 | 37 | waitForBrowserState(blankState, finish); |
michael@0 | 38 | }); |
michael@0 | 39 | |
michael@0 | 40 | // reload the browser to deprecate the subframes |
michael@0 | 41 | browser.reload(); |
michael@0 | 42 | }); |
michael@0 | 43 | |
michael@0 | 44 | // create a dynamic subframe |
michael@0 | 45 | let doc = browser.contentDocument; |
michael@0 | 46 | let iframe = doc.createElement("iframe"); |
michael@0 | 47 | doc.body.appendChild(iframe); |
michael@0 | 48 | iframe.setAttribute("src", "about:mozilla"); |
michael@0 | 49 | }); |
michael@0 | 50 | }); |
michael@0 | 51 | } |
michael@0 | 52 | |
michael@0 | 53 | function whenChildCount(aEntry, aChildCount, aCallback) { |
michael@0 | 54 | if (aEntry.childCount == aChildCount) |
michael@0 | 55 | aCallback(); |
michael@0 | 56 | else |
michael@0 | 57 | setTimeout(function () whenChildCount(aEntry, aChildCount, aCallback), 100); |
michael@0 | 58 | } |