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.
michael@0 | 1 | /* This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 2 | * License, v. 2.0. If a copy of the MPL was not distributed with this |
michael@0 | 3 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
michael@0 | 4 | |
michael@0 | 5 | const PREF_RESTORE_ON_DEMAND = "browser.sessionstore.restore_on_demand"; |
michael@0 | 6 | const PREF_RESTORE_PINNED_TABS_ON_DEMAND = "browser.sessionstore.restore_pinned_tabs_on_demand"; |
michael@0 | 7 | |
michael@0 | 8 | function test() { |
michael@0 | 9 | TestRunner.run(); |
michael@0 | 10 | } |
michael@0 | 11 | |
michael@0 | 12 | function runTests() { |
michael@0 | 13 | Services.prefs.setBoolPref(PREF_RESTORE_ON_DEMAND, true); |
michael@0 | 14 | Services.prefs.setBoolPref(PREF_RESTORE_PINNED_TABS_ON_DEMAND, true); |
michael@0 | 15 | |
michael@0 | 16 | registerCleanupFunction(function () { |
michael@0 | 17 | Services.prefs.clearUserPref(PREF_RESTORE_ON_DEMAND); |
michael@0 | 18 | Services.prefs.clearUserPref(PREF_RESTORE_PINNED_TABS_ON_DEMAND); |
michael@0 | 19 | }); |
michael@0 | 20 | |
michael@0 | 21 | let state = { windows: [{ tabs: [ |
michael@0 | 22 | { entries: [{ url: "http://example.org/#1" }], extData: { "uniq": r() }, pinned: true }, |
michael@0 | 23 | { entries: [{ url: "http://example.org/#2" }], extData: { "uniq": r() }, pinned: true }, |
michael@0 | 24 | { entries: [{ url: "http://example.org/#3" }], extData: { "uniq": r() }, pinned: true }, |
michael@0 | 25 | { entries: [{ url: "http://example.org/#4" }], extData: { "uniq": r() } }, |
michael@0 | 26 | { entries: [{ url: "http://example.org/#5" }], extData: { "uniq": r() } }, |
michael@0 | 27 | { entries: [{ url: "http://example.org/#6" }], extData: { "uniq": r() } }, |
michael@0 | 28 | { entries: [{ url: "http://example.org/#7" }], extData: { "uniq": r() } }, |
michael@0 | 29 | ], selected: 5 }] }; |
michael@0 | 30 | |
michael@0 | 31 | gProgressListener.setCallback(function (aBrowser, aNeedRestore, aRestoring, aRestored) { |
michael@0 | 32 | // get the tab |
michael@0 | 33 | let tab; |
michael@0 | 34 | for (let i = 0; i < window.gBrowser.tabs.length; i++) { |
michael@0 | 35 | if (!tab && window.gBrowser.tabs[i].linkedBrowser == aBrowser) |
michael@0 | 36 | tab = window.gBrowser.tabs[i]; |
michael@0 | 37 | } |
michael@0 | 38 | |
michael@0 | 39 | // Check that the load only comes from the selected tab. |
michael@0 | 40 | ok(tab.selected, "load came from selected tab"); |
michael@0 | 41 | is(aNeedRestore, 6, "six tabs left to restore"); |
michael@0 | 42 | is(aRestoring, 1, "one tab is restoring"); |
michael@0 | 43 | is(aRestored, 0, "no tabs have been restored, yet"); |
michael@0 | 44 | |
michael@0 | 45 | gProgressListener.unsetCallback(); |
michael@0 | 46 | executeSoon(next); |
michael@0 | 47 | }); |
michael@0 | 48 | |
michael@0 | 49 | yield ss.setBrowserState(JSON.stringify(state)); |
michael@0 | 50 | } |