browser/components/sessionstore/test/browser_618151.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 stateBackup = ss.getBrowserState();
michael@0 6 const testState = {
michael@0 7 windows: [{
michael@0 8 tabs: [
michael@0 9 { entries: [{ url: "about:blank" }] },
michael@0 10 { entries: [{ url: "about:mozilla" }] }
michael@0 11 ]
michael@0 12 }]
michael@0 13 };
michael@0 14
michael@0 15
michael@0 16 function test() {
michael@0 17 /** Test for Bug 618151 - Overwriting state can lead to unrestored tabs **/
michael@0 18 waitForExplicitFinish();
michael@0 19 runNextTest();
michael@0 20 }
michael@0 21
michael@0 22 // Just a subset of tests from bug 615394 that causes a timeout.
michael@0 23 let tests = [test_setup, test_hang];
michael@0 24 function runNextTest() {
michael@0 25 // set an empty state & run the next test, or finish
michael@0 26 if (tests.length) {
michael@0 27 // Enumerate windows and close everything but our primary window. We can't
michael@0 28 // use waitForFocus() because apparently it's buggy. See bug 599253.
michael@0 29 var windowsEnum = Services.wm.getEnumerator("navigator:browser");
michael@0 30 while (windowsEnum.hasMoreElements()) {
michael@0 31 var currentWindow = windowsEnum.getNext();
michael@0 32 if (currentWindow != window) {
michael@0 33 currentWindow.close();
michael@0 34 }
michael@0 35 }
michael@0 36
michael@0 37 let currentTest = tests.shift();
michael@0 38 info("running " + currentTest.name);
michael@0 39 waitForBrowserState(testState, currentTest);
michael@0 40 }
michael@0 41 else {
michael@0 42 ss.setBrowserState(stateBackup);
michael@0 43 executeSoon(finish);
michael@0 44 }
michael@0 45 }
michael@0 46
michael@0 47 function test_setup() {
michael@0 48 function onSSTabRestored(aEvent) {
michael@0 49 gBrowser.tabContainer.removeEventListener("SSTabRestored", onSSTabRestored, false);
michael@0 50 runNextTest();
michael@0 51 }
michael@0 52
michael@0 53 gBrowser.tabContainer.addEventListener("SSTabRestored", onSSTabRestored, false);
michael@0 54 ss.setTabState(gBrowser.tabs[1], JSON.stringify({
michael@0 55 entries: [{ url: "http://example.org" }],
michael@0 56 extData: { foo: "bar" } }));
michael@0 57 }
michael@0 58
michael@0 59 function test_hang() {
michael@0 60 ok(true, "test didn't time out");
michael@0 61 runNextTest();
michael@0 62 }

mercurial