browser/components/sessionstore/test/browser_707862.js

changeset 0
6474c204b198
equal deleted inserted replaced
-1:000000000000 0:ecb3ba17e98f
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 let sessionHistory = browser.sessionHistory;
31 let entry = sessionHistory.getEntryAtIndex(0, false);
32
33 whenChildCount(entry, 0, function () {
34 // Make sure that we reset the state.
35 let blankState = { windows: [{ tabs: [{ entries: [{ url: "about:blank" }] }]}]};
36 waitForBrowserState(blankState, finish);
37 });
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 }

mercurial