browser/components/sessionstore/test/browser_586068-apptabs_ondemand.js

changeset 0
6474c204b198
equal deleted inserted replaced
-1:000000000000 0:181cf1bb19bd
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 const PREF_RESTORE_PINNED_TABS_ON_DEMAND = "browser.sessionstore.restore_pinned_tabs_on_demand";
7
8 function test() {
9 TestRunner.run();
10 }
11
12 function runTests() {
13 Services.prefs.setBoolPref(PREF_RESTORE_ON_DEMAND, true);
14 Services.prefs.setBoolPref(PREF_RESTORE_PINNED_TABS_ON_DEMAND, true);
15
16 registerCleanupFunction(function () {
17 Services.prefs.clearUserPref(PREF_RESTORE_ON_DEMAND);
18 Services.prefs.clearUserPref(PREF_RESTORE_PINNED_TABS_ON_DEMAND);
19 });
20
21 let state = { windows: [{ tabs: [
22 { entries: [{ url: "http://example.org/#1" }], extData: { "uniq": r() }, pinned: true },
23 { entries: [{ url: "http://example.org/#2" }], extData: { "uniq": r() }, pinned: true },
24 { entries: [{ url: "http://example.org/#3" }], extData: { "uniq": r() }, pinned: true },
25 { entries: [{ url: "http://example.org/#4" }], extData: { "uniq": r() } },
26 { entries: [{ url: "http://example.org/#5" }], extData: { "uniq": r() } },
27 { entries: [{ url: "http://example.org/#6" }], extData: { "uniq": r() } },
28 { entries: [{ url: "http://example.org/#7" }], extData: { "uniq": r() } },
29 ], selected: 5 }] };
30
31 gProgressListener.setCallback(function (aBrowser, aNeedRestore, aRestoring, aRestored) {
32 // get the tab
33 let tab;
34 for (let i = 0; i < window.gBrowser.tabs.length; i++) {
35 if (!tab && window.gBrowser.tabs[i].linkedBrowser == aBrowser)
36 tab = window.gBrowser.tabs[i];
37 }
38
39 // Check that the load only comes from the selected tab.
40 ok(tab.selected, "load came from selected tab");
41 is(aNeedRestore, 6, "six tabs left to restore");
42 is(aRestoring, 1, "one tab is restoring");
43 is(aRestored, 0, "no tabs have been restored, yet");
44
45 gProgressListener.unsetCallback();
46 executeSoon(next);
47 });
48
49 yield ss.setBrowserState(JSON.stringify(state));
50 }

mercurial