tor-browser

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

browser_618151.js (1980B)


      1 /* This Source Code Form is subject to the terms of the Mozilla Public
      2 * License, v. 2.0. If a copy of the MPL was not distributed with this
      3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
      4 
      5 const stateBackup = ss.getBrowserState();
      6 const testState = {
      7  windows: [
      8    {
      9      tabs: [
     10        { entries: [{ url: "about:blank", triggeringPrincipal_base64 }] },
     11        { entries: [{ url: "about:mozilla", triggeringPrincipal_base64 }] },
     12      ],
     13    },
     14  ],
     15 };
     16 
     17 function test() {
     18  /** Test for Bug 618151 - Overwriting state can lead to unrestored tabs */
     19  waitForExplicitFinish();
     20  runNextTest();
     21 }
     22 
     23 // Just a subset of tests from bug 615394 that causes a timeout.
     24 var tests = [test_setup, test_hang];
     25 function runNextTest() {
     26  // set an empty state & run the next test, or finish
     27  if (tests.length) {
     28    // Enumerate windows and close everything but our primary window. We can't
     29    // use waitForFocus() because apparently it's buggy. See bug 599253.
     30    let closeWinPromises = [];
     31    for (let currentWindow of Services.wm.getEnumerator("navigator:browser")) {
     32      if (currentWindow != window) {
     33        closeWinPromises.push(BrowserTestUtils.closeWindow(currentWindow));
     34      }
     35    }
     36 
     37    Promise.all(closeWinPromises).then(() => {
     38      let currentTest = tests.shift();
     39      info("running " + currentTest.name);
     40      waitForBrowserState(testState, currentTest);
     41    });
     42  } else {
     43    ss.setBrowserState(stateBackup);
     44    executeSoon(finish);
     45  }
     46 }
     47 
     48 function test_setup() {
     49  function onSSTabRestored() {
     50    gBrowser.tabContainer.removeEventListener("SSTabRestored", onSSTabRestored);
     51    runNextTest();
     52  }
     53 
     54  gBrowser.tabContainer.addEventListener("SSTabRestored", onSSTabRestored);
     55  ss.setTabState(
     56    gBrowser.tabs[1],
     57    JSON.stringify({
     58      entries: [{ url: "http://example.org", triggeringPrincipal_base64 }],
     59      extData: { foo: "bar" },
     60    })
     61  );
     62 }
     63 
     64 function test_hang() {
     65  ok(true, "test didn't time out");
     66  runNextTest();
     67 }