|
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 const PREF_RESTORE_ON_DEMAND = "browser.sessionstore.restore_on_demand"; |
|
6 |
|
7 function test() { |
|
8 TestRunner.run(); |
|
9 } |
|
10 |
|
11 function runTests() { |
|
12 Services.prefs.setBoolPref(PREF_RESTORE_ON_DEMAND, true); |
|
13 registerCleanupFunction(function () { |
|
14 Services.prefs.clearUserPref(PREF_RESTORE_ON_DEMAND); |
|
15 }); |
|
16 |
|
17 let state = { windows: [{ tabs: [ |
|
18 { entries: [{ url: "http://example.org/#1" }], extData: { "uniq": r() }, pinned: true }, |
|
19 { entries: [{ url: "http://example.org/#2" }], extData: { "uniq": r() }, pinned: true }, |
|
20 { entries: [{ url: "http://example.org/#3" }], extData: { "uniq": r() }, pinned: true }, |
|
21 { entries: [{ url: "http://example.org/#4" }], extData: { "uniq": r() } }, |
|
22 { entries: [{ url: "http://example.org/#5" }], extData: { "uniq": r() } }, |
|
23 { entries: [{ url: "http://example.org/#6" }], extData: { "uniq": r() } }, |
|
24 { entries: [{ url: "http://example.org/#7" }], extData: { "uniq": r() } }, |
|
25 ], selected: 5 }] }; |
|
26 |
|
27 let loadCount = 0; |
|
28 gProgressListener.setCallback(function (aBrowser, aNeedRestore, aRestoring, aRestored) { |
|
29 loadCount++; |
|
30 |
|
31 // We'll make sure that the loads we get come from pinned tabs or the |
|
32 // the selected tab. |
|
33 |
|
34 // get the tab |
|
35 let tab; |
|
36 for (let i = 0; i < window.gBrowser.tabs.length; i++) { |
|
37 if (!tab && window.gBrowser.tabs[i].linkedBrowser == aBrowser) |
|
38 tab = window.gBrowser.tabs[i]; |
|
39 } |
|
40 |
|
41 ok(tab.pinned || tab.selected, |
|
42 "load came from pinned or selected tab"); |
|
43 |
|
44 // We should get 4 loads: 3 app tabs + 1 normal selected tab |
|
45 if (loadCount < 4) |
|
46 return; |
|
47 |
|
48 gProgressListener.unsetCallback(); |
|
49 executeSoon(next); |
|
50 }); |
|
51 |
|
52 yield ss.setBrowserState(JSON.stringify(state)); |
|
53 } |