browser/components/sessionstore/test/browser_601955.js

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

     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/. */
     5 // This tests that pinning/unpinning a tab, on its own, eventually triggers a
     6 // session store.
     8 function test() {
     9   waitForExplicitFinish();
    10   // We speed up the interval between session saves to ensure that the test
    11   // runs quickly.
    12   Services.prefs.setIntPref("browser.sessionstore.interval", 2000);
    14   // Loading a tab causes a save state and this is meant to catch that event.
    15   waitForSaveState(testBug601955_1);
    17   // Assumption: Only one window is open and it has one tab open.
    18   gBrowser.addTab("about:mozilla");
    19 }
    21 function testBug601955_1() {
    22   // Because pinned tabs are at the front of |gBrowser.tabs|, pinning tabs
    23   // re-arranges the |tabs| array.
    24   ok(!gBrowser.tabs[0].pinned, "first tab should not be pinned yet");
    25   ok(!gBrowser.tabs[1].pinned, "second tab should not be pinned yet");
    27   waitForSaveState(testBug601955_2);
    28   gBrowser.pinTab(gBrowser.tabs[0]);
    29 }
    31 function testBug601955_2() {
    32   let state = JSON.parse(ss.getBrowserState());
    33   ok(state.windows[0].tabs[0].pinned, "first tab should be pinned by now");
    34   ok(!state.windows[0].tabs[1].pinned, "second tab should still not be pinned");
    36   waitForSaveState(testBug601955_3);
    37   gBrowser.unpinTab(window.gBrowser.tabs[0]);
    38 }
    40 function testBug601955_3() {
    41   let state = JSON.parse(ss.getBrowserState());
    42   ok(!state.windows[0].tabs[0].pinned, "first tab should not be pinned");
    43   ok(!state.windows[0].tabs[1].pinned, "second tab should not be pinned");
    45   done();
    46 }
    48 function done() {
    49   gBrowser.removeTab(window.gBrowser.tabs[1]);
    51   Services.prefs.clearUserPref("browser.sessionstore.interval");
    53   executeSoon(finish);
    54 }

mercurial