browser/components/sessionstore/test/browser_707862.js

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

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

mercurial