Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
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/. */
5 const PREF_RESTORE_ON_DEMAND = "browser.sessionstore.restore_on_demand";
7 function test() {
8 TestRunner.run();
9 }
11 function runTests() {
12 Services.prefs.setBoolPref(PREF_RESTORE_ON_DEMAND, false);
13 registerCleanupFunction(function () {
14 Services.prefs.clearUserPref(PREF_RESTORE_ON_DEMAND);
15 });
17 // We'll use 2 states so that we can make sure calling setWindowState doesn't
18 // wipe out currently restoring data.
19 let state1 = { windows: [{ tabs: [
20 { entries: [{ url: "http://example.com#1" }] },
21 { entries: [{ url: "http://example.com#2" }] },
22 { entries: [{ url: "http://example.com#3" }] },
23 { entries: [{ url: "http://example.com#4" }] },
24 { entries: [{ url: "http://example.com#5" }] },
25 ] }] };
26 let state2 = { windows: [{ tabs: [
27 { entries: [{ url: "http://example.org#1" }] },
28 { entries: [{ url: "http://example.org#2" }] },
29 { entries: [{ url: "http://example.org#3" }] },
30 { entries: [{ url: "http://example.org#4" }] },
31 { entries: [{ url: "http://example.org#5" }] }
32 ] }] };
33 let numTabs = state1.windows[0].tabs.length + state2.windows[0].tabs.length;
35 let loadCount = 0;
36 gProgressListener.setCallback(function (aBrowser, aNeedRestore, aRestoring, aRestored) {
37 // When loadCount == 2, we'll also restore state2 into the window
38 if (++loadCount == 2) {
39 ss.setWindowState(window, JSON.stringify(state2), false);
40 }
42 if (loadCount < numTabs) {
43 return;
44 }
46 // We don't actually care about load order in this test, just that they all
47 // do load.
48 is(loadCount, numTabs, "test_setWindowStateNoOverwrite: all tabs were restored");
49 is(aNeedRestore, 0, "there are no tabs left needing restore");
51 gProgressListener.unsetCallback();
52 executeSoon(next);
53 });
55 yield ss.setWindowState(window, JSON.stringify(state1), true);
56 }