browser/components/sessionstore/test/browser_586068-apptabs.js

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

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, true);
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.org/#1" }], extData: { "uniq": r() }, pinned: true },
michael@0 19 { entries: [{ url: "http://example.org/#2" }], extData: { "uniq": r() }, pinned: true },
michael@0 20 { entries: [{ url: "http://example.org/#3" }], extData: { "uniq": r() }, pinned: true },
michael@0 21 { entries: [{ url: "http://example.org/#4" }], extData: { "uniq": r() } },
michael@0 22 { entries: [{ url: "http://example.org/#5" }], extData: { "uniq": r() } },
michael@0 23 { entries: [{ url: "http://example.org/#6" }], extData: { "uniq": r() } },
michael@0 24 { entries: [{ url: "http://example.org/#7" }], extData: { "uniq": r() } },
michael@0 25 ], selected: 5 }] };
michael@0 26
michael@0 27 let loadCount = 0;
michael@0 28 gProgressListener.setCallback(function (aBrowser, aNeedRestore, aRestoring, aRestored) {
michael@0 29 loadCount++;
michael@0 30
michael@0 31 // We'll make sure that the loads we get come from pinned tabs or the
michael@0 32 // the selected tab.
michael@0 33
michael@0 34 // get the tab
michael@0 35 let tab;
michael@0 36 for (let i = 0; i < window.gBrowser.tabs.length; i++) {
michael@0 37 if (!tab && window.gBrowser.tabs[i].linkedBrowser == aBrowser)
michael@0 38 tab = window.gBrowser.tabs[i];
michael@0 39 }
michael@0 40
michael@0 41 ok(tab.pinned || tab.selected,
michael@0 42 "load came from pinned or selected tab");
michael@0 43
michael@0 44 // We should get 4 loads: 3 app tabs + 1 normal selected tab
michael@0 45 if (loadCount < 4)
michael@0 46 return;
michael@0 47
michael@0 48 gProgressListener.unsetCallback();
michael@0 49 executeSoon(next);
michael@0 50 });
michael@0 51
michael@0 52 yield ss.setBrowserState(JSON.stringify(state));
michael@0 53 }

mercurial