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 let state = { windows: [{ tabs: [
18 { entries: [{ url: "http://example.com" }], extData: { "uniq": r() } },
19 { entries: [{ url: "http://example.com" }], extData: { "uniq": r() } },
20 { entries: [{ url: "http://example.com" }], extData: { "uniq": r() } },
21 { entries: [{ url: "http://example.com" }], extData: { "uniq": r() } },
22 { entries: [{ url: "http://example.com" }], extData: { "uniq": r() } },
23 { entries: [{ url: "http://example.com" }], extData: { "uniq": r() } }
24 ] }] };
26 let expectedCounts = [
27 [3, 3, 0],
28 [2, 3, 1],
29 [1, 3, 2],
30 [0, 3, 3],
31 [0, 2, 4],
32 [0, 1, 5]
33 ];
35 let loadCount = 0;
36 gProgressListener.setCallback(function (aBrowser, aNeedRestore, aRestoring, aRestored) {
37 loadCount++;
38 let expected = expectedCounts[loadCount - 1];
40 is(aNeedRestore, expected[0], "load " + loadCount + " - # tabs that need to be restored");
41 is(aRestoring, expected[1], "load " + loadCount + " - # tabs that are restoring");
42 is(aRestored, expected[2], "load " + loadCount + " - # tabs that has been restored");
44 if (loadCount == state.windows[0].tabs.length) {
45 gProgressListener.unsetCallback();
46 executeSoon(next);
47 }
48 });
50 yield ss.setBrowserState(JSON.stringify(state));
51 }