michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: const stateBackup = ss.getBrowserState(); michael@0: const testState = { michael@0: windows: [{ michael@0: tabs: [ michael@0: { entries: [{ url: "about:blank" }] }, michael@0: { entries: [{ url: "about:mozilla" }] } michael@0: ] michael@0: }] michael@0: }; michael@0: michael@0: michael@0: function test() { michael@0: /** Test for Bug 618151 - Overwriting state can lead to unrestored tabs **/ michael@0: waitForExplicitFinish(); michael@0: runNextTest(); michael@0: } michael@0: michael@0: // Just a subset of tests from bug 615394 that causes a timeout. michael@0: let tests = [test_setup, test_hang]; michael@0: function runNextTest() { michael@0: // set an empty state & run the next test, or finish michael@0: if (tests.length) { michael@0: // Enumerate windows and close everything but our primary window. We can't michael@0: // use waitForFocus() because apparently it's buggy. See bug 599253. michael@0: var windowsEnum = Services.wm.getEnumerator("navigator:browser"); michael@0: while (windowsEnum.hasMoreElements()) { michael@0: var currentWindow = windowsEnum.getNext(); michael@0: if (currentWindow != window) { michael@0: currentWindow.close(); michael@0: } michael@0: } michael@0: michael@0: let currentTest = tests.shift(); michael@0: info("running " + currentTest.name); michael@0: waitForBrowserState(testState, currentTest); michael@0: } michael@0: else { michael@0: ss.setBrowserState(stateBackup); michael@0: executeSoon(finish); michael@0: } michael@0: } michael@0: michael@0: function test_setup() { michael@0: function onSSTabRestored(aEvent) { michael@0: gBrowser.tabContainer.removeEventListener("SSTabRestored", onSSTabRestored, false); michael@0: runNextTest(); michael@0: } michael@0: michael@0: gBrowser.tabContainer.addEventListener("SSTabRestored", onSSTabRestored, false); michael@0: ss.setTabState(gBrowser.tabs[1], JSON.stringify({ michael@0: entries: [{ url: "http://example.org" }], michael@0: extData: { foo: "bar" } })); michael@0: } michael@0: michael@0: function test_hang() { michael@0: ok(true, "test didn't time out"); michael@0: runNextTest(); michael@0: }