tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

browser_707862.js (1962B)


      1 /* Any copyright is dedicated to the Public Domain.
      2   http://creativecommons.org/publicdomain/zero/1.0/ */
      3 /* eslint-disable mozilla/no-arbitrary-setTimeout */
      4 
      5 const tabState = {
      6  entries: [
      7    {
      8      url: "about:robots",
      9      triggeringPrincipal_base64,
     10      children: [{ url: "about:mozilla", triggeringPrincipal_base64 }],
     11    },
     12  ],
     13 };
     14 
     15 const blankState = {
     16  windows: [
     17    {
     18      tabs: [
     19        {
     20          entries: [{ url: "about:blank", triggeringPrincipal_base64 }],
     21        },
     22      ],
     23    },
     24  ],
     25 };
     26 
     27 add_task(async function test() {
     28  Services.prefs.setIntPref("browser.sessionstore.interval", 4000);
     29  registerCleanupFunction(function () {
     30    Services.prefs.clearUserPref("browser.sessionstore.interval");
     31  });
     32 
     33  let tab = BrowserTestUtils.addTab(gBrowser, "about:blank");
     34  let browser = tab.linkedBrowser;
     35  await BrowserTestUtils.browserLoaded(browser, false, "about:blank");
     36 
     37  await promiseTabState(tab, tabState);
     38  let sessionHistory = browser.browsingContext.sessionHistory;
     39  let entry = sessionHistory.getEntryAtIndex(0);
     40 
     41  await whenChildCount(entry, 1);
     42 
     43  // Create a dynamic subframe.
     44  let doc = browser.contentDocument;
     45  let iframe = doc.createElement("iframe");
     46  iframe.setAttribute("src", "about:mozilla");
     47  doc.body.appendChild(iframe);
     48 
     49  await whenChildCount(entry, 2);
     50 
     51  // Force reload the browser to deprecate the subframes.
     52  browser.reloadWithFlags(Ci.nsIWebNavigation.LOAD_FLAGS_BYPASS_CACHE);
     53 
     54  await BrowserTestUtils.browserLoaded(browser, false, "about:robots");
     55  let newSessionHistory = browser.browsingContext.sessionHistory;
     56  let newEntry = newSessionHistory.getEntryAtIndex(0);
     57 
     58  await whenChildCount(newEntry, 0);
     59  // Make sure that we reset the state.
     60  waitForBrowserState(blankState, finish);
     61 
     62  ok(true, "test passed");
     63 });
     64 
     65 function whenChildCount(aEntry, aChildCount) {
     66  return TestUtils.waitForCondition(
     67    () => aEntry.childCount == aChildCount,
     68    "wait for child count"
     69  );
     70 }