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, true);
13 registerCleanupFunction(function () {
14 Services.prefs.clearUserPref(PREF_RESTORE_ON_DEMAND);
15 });
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 }] };
27 let loadCount = 0;
28 gProgressListener.setCallback(function (aBrowser, aNeedRestore, aRestoring, aRestored) {
29 loadCount++;
31 // We'll make sure that the loads we get come from pinned tabs or the
32 // the selected tab.
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 }
41 ok(tab.pinned || tab.selected,
42 "load came from pinned or selected tab");
44 // We should get 4 loads: 3 app tabs + 1 normal selected tab
45 if (loadCount < 4)
46 return;
48 gProgressListener.unsetCallback();
49 executeSoon(next);
50 });
52 yield ss.setBrowserState(JSON.stringify(state));
53 }