tor-browser

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

browser_701377.js (1423B)


      1 /* Any copyright is dedicated to the Public Domain.
      2   http://creativecommons.org/publicdomain/zero/1.0/ */
      3 
      4 var state = {
      5  windows: [
      6    {
      7      tabs: [
      8        {
      9          entries: [
     10            { url: "http://example.com#1", triggeringPrincipal_base64 },
     11          ],
     12        },
     13        {
     14          entries: [
     15            { url: "http://example.com#2", triggeringPrincipal_base64 },
     16          ],
     17          hidden: true,
     18        },
     19      ],
     20    },
     21  ],
     22 };
     23 
     24 function test() {
     25  waitForExplicitFinish();
     26 
     27  newWindowWithState(state, function (aWindow) {
     28    let tab = aWindow.gBrowser.tabs[1];
     29    ok(tab.hidden, "the second tab is hidden");
     30 
     31    let tabShown = false;
     32    let tabShowCallback = () => (tabShown = true);
     33    tab.addEventListener("TabShow", tabShowCallback);
     34 
     35    let tabState = ss.getTabState(tab);
     36    ss.setTabState(tab, tabState);
     37 
     38    tab.removeEventListener("TabShow", tabShowCallback);
     39    ok(tab.hidden && !tabShown, "tab remains hidden");
     40 
     41    finish();
     42  });
     43 }
     44 
     45 // ----------
     46 function newWindowWithState(aState, aCallback) {
     47  let opts = "chrome,all,dialog=no,height=800,width=800";
     48  let win = window.openDialog(AppConstants.BROWSER_CHROME_URL, "_blank", opts);
     49 
     50  registerCleanupFunction(() => BrowserTestUtils.closeWindow(win));
     51 
     52  whenWindowLoaded(win, function onWindowLoaded(aWin) {
     53    ss.setWindowState(aWin, JSON.stringify(aState), true);
     54    executeSoon(() => aCallback(aWin));
     55  });
     56 }