Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
michael@0 | 1 | /* This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 2 | * License, v. 2.0. If a copy of the MPL was not distributed with this |
michael@0 | 3 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
michael@0 | 4 | |
michael@0 | 5 | // This tests that pinning/unpinning a tab, on its own, eventually triggers a |
michael@0 | 6 | // session store. |
michael@0 | 7 | |
michael@0 | 8 | function test() { |
michael@0 | 9 | waitForExplicitFinish(); |
michael@0 | 10 | // We speed up the interval between session saves to ensure that the test |
michael@0 | 11 | // runs quickly. |
michael@0 | 12 | Services.prefs.setIntPref("browser.sessionstore.interval", 2000); |
michael@0 | 13 | |
michael@0 | 14 | // Loading a tab causes a save state and this is meant to catch that event. |
michael@0 | 15 | waitForSaveState(testBug601955_1); |
michael@0 | 16 | |
michael@0 | 17 | // Assumption: Only one window is open and it has one tab open. |
michael@0 | 18 | gBrowser.addTab("about:mozilla"); |
michael@0 | 19 | } |
michael@0 | 20 | |
michael@0 | 21 | function testBug601955_1() { |
michael@0 | 22 | // Because pinned tabs are at the front of |gBrowser.tabs|, pinning tabs |
michael@0 | 23 | // re-arranges the |tabs| array. |
michael@0 | 24 | ok(!gBrowser.tabs[0].pinned, "first tab should not be pinned yet"); |
michael@0 | 25 | ok(!gBrowser.tabs[1].pinned, "second tab should not be pinned yet"); |
michael@0 | 26 | |
michael@0 | 27 | waitForSaveState(testBug601955_2); |
michael@0 | 28 | gBrowser.pinTab(gBrowser.tabs[0]); |
michael@0 | 29 | } |
michael@0 | 30 | |
michael@0 | 31 | function testBug601955_2() { |
michael@0 | 32 | let state = JSON.parse(ss.getBrowserState()); |
michael@0 | 33 | ok(state.windows[0].tabs[0].pinned, "first tab should be pinned by now"); |
michael@0 | 34 | ok(!state.windows[0].tabs[1].pinned, "second tab should still not be pinned"); |
michael@0 | 35 | |
michael@0 | 36 | waitForSaveState(testBug601955_3); |
michael@0 | 37 | gBrowser.unpinTab(window.gBrowser.tabs[0]); |
michael@0 | 38 | } |
michael@0 | 39 | |
michael@0 | 40 | function testBug601955_3() { |
michael@0 | 41 | let state = JSON.parse(ss.getBrowserState()); |
michael@0 | 42 | ok(!state.windows[0].tabs[0].pinned, "first tab should not be pinned"); |
michael@0 | 43 | ok(!state.windows[0].tabs[1].pinned, "second tab should not be pinned"); |
michael@0 | 44 | |
michael@0 | 45 | done(); |
michael@0 | 46 | } |
michael@0 | 47 | |
michael@0 | 48 | function done() { |
michael@0 | 49 | gBrowser.removeTab(window.gBrowser.tabs[1]); |
michael@0 | 50 | |
michael@0 | 51 | Services.prefs.clearUserPref("browser.sessionstore.interval"); |
michael@0 | 52 | |
michael@0 | 53 | executeSoon(finish); |
michael@0 | 54 | } |