browser/components/sessionstore/test/browser_705597.js

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/browser/components/sessionstore/test/browser_705597.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,58 @@
     1.4 +/* Any copyright is dedicated to the Public Domain.
     1.5 +   http://creativecommons.org/publicdomain/zero/1.0/ */
     1.6 +
     1.7 +let tabState = {
     1.8 +  entries: [{url: "about:robots", children: [{url: "about:mozilla"}]}]
     1.9 +};
    1.10 +
    1.11 +function test() {
    1.12 +  waitForExplicitFinish();
    1.13 +  requestLongerTimeout(2);
    1.14 +
    1.15 +  Services.prefs.setIntPref("browser.sessionstore.interval", 4000);
    1.16 +  registerCleanupFunction(function () {
    1.17 +    Services.prefs.clearUserPref("browser.sessionstore.interval");
    1.18 +  });
    1.19 +
    1.20 +  let tab = gBrowser.addTab("about:blank");
    1.21 +
    1.22 +  let browser = tab.linkedBrowser;
    1.23 +
    1.24 +  waitForTabState(tab, tabState, function () {
    1.25 +
    1.26 +    let sessionHistory = browser.sessionHistory;
    1.27 +    let entry = sessionHistory.getEntryAtIndex(0, false);
    1.28 +    entry.QueryInterface(Ci.nsISHContainer);
    1.29 +
    1.30 +    whenChildCount(entry, 1, function () {
    1.31 +      whenChildCount(entry, 2, function () {
    1.32 +        whenBrowserLoaded(browser, function () {
    1.33 +          SyncHandlers.get(browser).flush();
    1.34 +          let {entries} = JSON.parse(ss.getTabState(tab));
    1.35 +          is(entries.length, 1, "tab has one history entry");
    1.36 +          ok(!entries[0].children, "history entry has no subframes");
    1.37 +
    1.38 +          // Make sure that we reset the state.
    1.39 +          let blankState = { windows: [{ tabs: [{ entries: [{ url: "about:blank" }] }]}]};
    1.40 +          waitForBrowserState(blankState, finish);
    1.41 +        });
    1.42 +
    1.43 +        // reload the browser to deprecate the subframes
    1.44 +        browser.reload();
    1.45 +      });
    1.46 +
    1.47 +      // create a dynamic subframe
    1.48 +      let doc = browser.contentDocument;
    1.49 +      let iframe = doc.createElement("iframe");
    1.50 +      doc.body.appendChild(iframe);
    1.51 +      iframe.setAttribute("src", "about:mozilla");
    1.52 +    });
    1.53 +  });
    1.54 +}
    1.55 +
    1.56 +function whenChildCount(aEntry, aChildCount, aCallback) {
    1.57 +  if (aEntry.childCount == aChildCount)
    1.58 +    aCallback();
    1.59 +  else
    1.60 +    setTimeout(function () whenChildCount(aEntry, aChildCount, aCallback), 100);
    1.61 +}

mercurial