1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/browser/components/sessionstore/test/browser_586068-cascade.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,51 @@ 1.4 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.5 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.6 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.7 + 1.8 +const PREF_RESTORE_ON_DEMAND = "browser.sessionstore.restore_on_demand"; 1.9 + 1.10 +function test() { 1.11 + TestRunner.run(); 1.12 +} 1.13 + 1.14 +function runTests() { 1.15 + Services.prefs.setBoolPref(PREF_RESTORE_ON_DEMAND, false); 1.16 + registerCleanupFunction(function () { 1.17 + Services.prefs.clearUserPref(PREF_RESTORE_ON_DEMAND); 1.18 + }); 1.19 + 1.20 + let state = { windows: [{ tabs: [ 1.21 + { entries: [{ url: "http://example.com" }], extData: { "uniq": r() } }, 1.22 + { entries: [{ url: "http://example.com" }], extData: { "uniq": r() } }, 1.23 + { entries: [{ url: "http://example.com" }], extData: { "uniq": r() } }, 1.24 + { entries: [{ url: "http://example.com" }], extData: { "uniq": r() } }, 1.25 + { entries: [{ url: "http://example.com" }], extData: { "uniq": r() } }, 1.26 + { entries: [{ url: "http://example.com" }], extData: { "uniq": r() } } 1.27 + ] }] }; 1.28 + 1.29 + let expectedCounts = [ 1.30 + [3, 3, 0], 1.31 + [2, 3, 1], 1.32 + [1, 3, 2], 1.33 + [0, 3, 3], 1.34 + [0, 2, 4], 1.35 + [0, 1, 5] 1.36 + ]; 1.37 + 1.38 + let loadCount = 0; 1.39 + gProgressListener.setCallback(function (aBrowser, aNeedRestore, aRestoring, aRestored) { 1.40 + loadCount++; 1.41 + let expected = expectedCounts[loadCount - 1]; 1.42 + 1.43 + is(aNeedRestore, expected[0], "load " + loadCount + " - # tabs that need to be restored"); 1.44 + is(aRestoring, expected[1], "load " + loadCount + " - # tabs that are restoring"); 1.45 + is(aRestored, expected[2], "load " + loadCount + " - # tabs that has been restored"); 1.46 + 1.47 + if (loadCount == state.windows[0].tabs.length) { 1.48 + gProgressListener.unsetCallback(); 1.49 + executeSoon(next); 1.50 + } 1.51 + }); 1.52 + 1.53 + yield ss.setBrowserState(JSON.stringify(state)); 1.54 +}