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 | |
michael@0 | 7 | function test() { |
michael@0 | 8 | TestRunner.run(); |
michael@0 | 9 | } |
michael@0 | 10 | |
michael@0 | 11 | function runTests() { |
michael@0 | 12 | Services.prefs.setBoolPref(PREF_RESTORE_ON_DEMAND, false); |
michael@0 | 13 | registerCleanupFunction(function () { |
michael@0 | 14 | Services.prefs.clearUserPref(PREF_RESTORE_ON_DEMAND); |
michael@0 | 15 | }); |
michael@0 | 16 | |
michael@0 | 17 | let state = { windows: [{ tabs: [ |
michael@0 | 18 | { entries: [{ url: "http://example.com" }], extData: { "uniq": r() } }, |
michael@0 | 19 | { entries: [{ url: "http://example.com" }], extData: { "uniq": r() } }, |
michael@0 | 20 | { entries: [{ url: "http://example.com" }], extData: { "uniq": r() } }, |
michael@0 | 21 | { entries: [{ url: "http://example.com" }], extData: { "uniq": r() } }, |
michael@0 | 22 | { entries: [{ url: "http://example.com" }], extData: { "uniq": r() } }, |
michael@0 | 23 | { entries: [{ url: "http://example.com" }], extData: { "uniq": r() } } |
michael@0 | 24 | ] }] }; |
michael@0 | 25 | |
michael@0 | 26 | let expectedCounts = [ |
michael@0 | 27 | [3, 3, 0], |
michael@0 | 28 | [2, 3, 1], |
michael@0 | 29 | [1, 3, 2], |
michael@0 | 30 | [0, 3, 3], |
michael@0 | 31 | [0, 2, 4], |
michael@0 | 32 | [0, 1, 5] |
michael@0 | 33 | ]; |
michael@0 | 34 | |
michael@0 | 35 | let loadCount = 0; |
michael@0 | 36 | gProgressListener.setCallback(function (aBrowser, aNeedRestore, aRestoring, aRestored) { |
michael@0 | 37 | loadCount++; |
michael@0 | 38 | let expected = expectedCounts[loadCount - 1]; |
michael@0 | 39 | |
michael@0 | 40 | is(aNeedRestore, expected[0], "load " + loadCount + " - # tabs that need to be restored"); |
michael@0 | 41 | is(aRestoring, expected[1], "load " + loadCount + " - # tabs that are restoring"); |
michael@0 | 42 | is(aRestored, expected[2], "load " + loadCount + " - # tabs that has been restored"); |
michael@0 | 43 | |
michael@0 | 44 | if (loadCount == state.windows[0].tabs.length) { |
michael@0 | 45 | gProgressListener.unsetCallback(); |
michael@0 | 46 | executeSoon(next); |
michael@0 | 47 | } |
michael@0 | 48 | }); |
michael@0 | 49 | |
michael@0 | 50 | yield ss.setBrowserState(JSON.stringify(state)); |
michael@0 | 51 | } |