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