browser/components/sessionstore/test/browser_635418.js

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/browser/components/sessionstore/test/browser_635418.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,54 @@
     1.4 +/* This Source Code Form is subject to the terms of the Mozilla Public
     1.5 + * License, v. 2.0. If a copy of the MPL was not distributed with this
     1.6 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.7 +
     1.8 +// This tests that hiding/showing a tab, on its own, eventually triggers a
     1.9 +// session store.
    1.10 +
    1.11 +function test() {
    1.12 +  waitForExplicitFinish();
    1.13 +  // We speed up the interval between session saves to ensure that the test
    1.14 +  // runs quickly.
    1.15 +  Services.prefs.setIntPref("browser.sessionstore.interval", 2000);
    1.16 +
    1.17 +  // Loading a tab causes a save state and this is meant to catch that event.
    1.18 +  waitForSaveState(testBug635418_1);
    1.19 +
    1.20 +  // Assumption: Only one window is open and it has one tab open.
    1.21 +  gBrowser.addTab("about:mozilla");
    1.22 +}
    1.23 +
    1.24 +function testBug635418_1() {
    1.25 +  ok(!gBrowser.tabs[0].hidden, "first tab should not be hidden");
    1.26 +  ok(!gBrowser.tabs[1].hidden, "second tab should not be hidden");
    1.27 +
    1.28 +  waitForSaveState(testBug635418_2);
    1.29 +
    1.30 +  // We can't hide the selected tab, so hide the new one
    1.31 +  gBrowser.hideTab(gBrowser.tabs[1]);
    1.32 +}
    1.33 +
    1.34 +function testBug635418_2() {
    1.35 +  let state = JSON.parse(ss.getBrowserState());
    1.36 +  ok(!state.windows[0].tabs[0].hidden, "first tab should still not be hidden");
    1.37 +  ok(state.windows[0].tabs[1].hidden, "second tab should be hidden by now");
    1.38 +
    1.39 +  waitForSaveState(testBug635418_3);
    1.40 +  gBrowser.showTab(gBrowser.tabs[1]);
    1.41 +}
    1.42 +
    1.43 +function testBug635418_3() {
    1.44 +  let state = JSON.parse(ss.getBrowserState());
    1.45 +  ok(!state.windows[0].tabs[0].hidden, "first tab should still still not be hidden");
    1.46 +  ok(!state.windows[0].tabs[1].hidden, "second tab should not be hidden again");
    1.47 +
    1.48 +  done();
    1.49 +}
    1.50 +
    1.51 +function done() {
    1.52 +  gBrowser.removeTab(window.gBrowser.tabs[1]);
    1.53 +
    1.54 +  Services.prefs.clearUserPref("browser.sessionstore.interval");
    1.55 +
    1.56 +  executeSoon(finish);
    1.57 +}

mercurial