tor-browser

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

browser_635418.js (1788B)


      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 // This tests that hiding/showing a tab, on its own, eventually triggers a
      6 // session store.
      7 
      8 function test() {
      9  waitForExplicitFinish();
     10 
     11  // We speed up the interval between session saves to ensure that the test
     12  // runs quickly.
     13  Services.prefs.setIntPref("browser.sessionstore.interval", 2000);
     14 
     15  // Loading a tab causes a save state and this is meant to catch that event.
     16  waitForSaveState(testBug635418_1);
     17 
     18  // Assumption: Only one window is open and it has one tab open.
     19  BrowserTestUtils.addTab(gBrowser, "about:mozilla");
     20 }
     21 
     22 function testBug635418_1() {
     23  ok(!gBrowser.tabs[0].hidden, "first tab should not be hidden");
     24  ok(!gBrowser.tabs[1].hidden, "second tab should not be hidden");
     25 
     26  waitForSaveState(testBug635418_2);
     27 
     28  // We can't hide the selected tab, so hide the new one
     29  gBrowser.hideTab(gBrowser.tabs[1]);
     30 }
     31 
     32 function testBug635418_2() {
     33  let state = JSON.parse(ss.getBrowserState());
     34  ok(!state.windows[0].tabs[0].hidden, "first tab should still not be hidden");
     35  ok(state.windows[0].tabs[1].hidden, "second tab should be hidden by now");
     36 
     37  waitForSaveState(testBug635418_3);
     38  gBrowser.showTab(gBrowser.tabs[1]);
     39 }
     40 
     41 function testBug635418_3() {
     42  let state = JSON.parse(ss.getBrowserState());
     43  ok(
     44    !state.windows[0].tabs[0].hidden,
     45    "first tab should still still not be hidden"
     46  );
     47  ok(!state.windows[0].tabs[1].hidden, "second tab should not be hidden again");
     48 
     49  done();
     50 }
     51 
     52 function done() {
     53  gBrowser.removeTab(window.gBrowser.tabs[1]);
     54 
     55  Services.prefs.clearUserPref("browser.sessionstore.interval");
     56 
     57  executeSoon(finish);
     58 }