|
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 hiding/showing 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(testBug635418_1); |
|
16 |
|
17 // Assumption: Only one window is open and it has one tab open. |
|
18 gBrowser.addTab("about:mozilla"); |
|
19 } |
|
20 |
|
21 function testBug635418_1() { |
|
22 ok(!gBrowser.tabs[0].hidden, "first tab should not be hidden"); |
|
23 ok(!gBrowser.tabs[1].hidden, "second tab should not be hidden"); |
|
24 |
|
25 waitForSaveState(testBug635418_2); |
|
26 |
|
27 // We can't hide the selected tab, so hide the new one |
|
28 gBrowser.hideTab(gBrowser.tabs[1]); |
|
29 } |
|
30 |
|
31 function testBug635418_2() { |
|
32 let state = JSON.parse(ss.getBrowserState()); |
|
33 ok(!state.windows[0].tabs[0].hidden, "first tab should still not be hidden"); |
|
34 ok(state.windows[0].tabs[1].hidden, "second tab should be hidden by now"); |
|
35 |
|
36 waitForSaveState(testBug635418_3); |
|
37 gBrowser.showTab(gBrowser.tabs[1]); |
|
38 } |
|
39 |
|
40 function testBug635418_3() { |
|
41 let state = JSON.parse(ss.getBrowserState()); |
|
42 ok(!state.windows[0].tabs[0].hidden, "first tab should still still not be hidden"); |
|
43 ok(!state.windows[0].tabs[1].hidden, "second tab should not be hidden again"); |
|
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 } |