| |
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 pinning/unpinning a tab, on its own, eventually triggers a |
| |
6 // session store. |
| |
7 |
| |
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); |
| |
13 |
| |
14 // Loading a tab causes a save state and this is meant to catch that event. |
| |
15 waitForSaveState(testBug601955_1); |
| |
16 |
| |
17 // Assumption: Only one window is open and it has one tab open. |
| |
18 gBrowser.addTab("about:mozilla"); |
| |
19 } |
| |
20 |
| |
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"); |
| |
26 |
| |
27 waitForSaveState(testBug601955_2); |
| |
28 gBrowser.pinTab(gBrowser.tabs[0]); |
| |
29 } |
| |
30 |
| |
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"); |
| |
35 |
| |
36 waitForSaveState(testBug601955_3); |
| |
37 gBrowser.unpinTab(window.gBrowser.tabs[0]); |
| |
38 } |
| |
39 |
| |
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"); |
| |
44 |
| |
45 done(); |
| |
46 } |
| |
47 |
| |
48 function done() { |
| |
49 gBrowser.removeTab(window.gBrowser.tabs[1]); |
| |
50 |
| |
51 Services.prefs.clearUserPref("browser.sessionstore.interval"); |
| |
52 |
| |
53 executeSoon(finish); |
| |
54 } |