tor-browser

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

browser_615394-SSWindowState_events_duplicateTab.js (2036B)


      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 testState = {
      6  windows: [
      7    {
      8      tabs: [
      9        { entries: [{ url: "about:blank", triggeringPrincipal_base64 }] },
     10        { entries: [{ url: "about:robots", triggeringPrincipal_base64 }] },
     11      ],
     12    },
     13  ],
     14 };
     15 
     16 function test() {
     17  /** Test for Bug 615394 - Session Restore should notify when it is beginning and ending a restore */
     18  waitForExplicitFinish();
     19 
     20  waitForBrowserState(testState, test_duplicateTab);
     21 }
     22 
     23 function test_duplicateTab() {
     24  let tab = gBrowser.tabs[1];
     25  let busyEventCount = 0;
     26  let readyEventCount = 0;
     27  let newTab;
     28 
     29  // We'll look to make sure this value is on the duplicated tab
     30  ss.setCustomTabValue(tab, "foo", "bar");
     31 
     32  function onSSWindowStateBusy() {
     33    busyEventCount++;
     34  }
     35 
     36  function onSSWindowStateReady() {
     37    newTab = gBrowser.tabs[2];
     38    readyEventCount++;
     39    is(ss.getCustomTabValue(newTab, "foo"), "bar");
     40    ss.setCustomTabValue(newTab, "baz", "qux");
     41  }
     42 
     43  function onSSTabRestoring(aEvent) {
     44    if (aEvent.target == newTab) {
     45      is(busyEventCount, 1);
     46      is(readyEventCount, 1);
     47      is(ss.getCustomTabValue(newTab, "baz"), "qux");
     48      is(newTab.linkedBrowser.currentURI.spec, "about:robots");
     49 
     50      window.removeEventListener("SSWindowStateBusy", onSSWindowStateBusy);
     51      window.removeEventListener("SSWindowStateReady", onSSWindowStateReady);
     52      gBrowser.tabContainer.removeEventListener(
     53        "SSTabRestoring",
     54        onSSTabRestoring
     55      );
     56 
     57      gBrowser.removeTab(tab);
     58      gBrowser.removeTab(newTab);
     59      finish();
     60    }
     61  }
     62 
     63  window.addEventListener("SSWindowStateBusy", onSSWindowStateBusy);
     64  window.addEventListener("SSWindowStateReady", onSSWindowStateReady);
     65  gBrowser.tabContainer.addEventListener("SSTabRestoring", onSSTabRestoring);
     66 
     67  gBrowser._insertBrowser(tab);
     68  newTab = ss.duplicateTab(window, tab);
     69 }