1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/browser/components/sessionstore/test/browser_601955.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 pinning/unpinning 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(testBug601955_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 testBug601955_1() { 1.25 + // Because pinned tabs are at the front of |gBrowser.tabs|, pinning tabs 1.26 + // re-arranges the |tabs| array. 1.27 + ok(!gBrowser.tabs[0].pinned, "first tab should not be pinned yet"); 1.28 + ok(!gBrowser.tabs[1].pinned, "second tab should not be pinned yet"); 1.29 + 1.30 + waitForSaveState(testBug601955_2); 1.31 + gBrowser.pinTab(gBrowser.tabs[0]); 1.32 +} 1.33 + 1.34 +function testBug601955_2() { 1.35 + let state = JSON.parse(ss.getBrowserState()); 1.36 + ok(state.windows[0].tabs[0].pinned, "first tab should be pinned by now"); 1.37 + ok(!state.windows[0].tabs[1].pinned, "second tab should still not be pinned"); 1.38 + 1.39 + waitForSaveState(testBug601955_3); 1.40 + gBrowser.unpinTab(window.gBrowser.tabs[0]); 1.41 +} 1.42 + 1.43 +function testBug601955_3() { 1.44 + let state = JSON.parse(ss.getBrowserState()); 1.45 + ok(!state.windows[0].tabs[0].pinned, "first tab should not be pinned"); 1.46 + ok(!state.windows[0].tabs[1].pinned, "second tab should not be pinned"); 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 +}