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 URIS_PINNED = ["about:license", "about:about"]; michael@0: const URIS_NORMAL_A = ["about:mozilla"]; michael@0: const URIS_NORMAL_B = ["about:buildconfig"]; michael@0: michael@0: function test() { michael@0: waitForExplicitFinish(); michael@0: michael@0: isnot(Services.prefs.getIntPref("browser.startup.page"), 3, michael@0: "pref to save session must not be set for this test"); michael@0: ok(!Services.prefs.getBoolPref("browser.sessionstore.resume_session_once"), michael@0: "pref to save session once must not be set for this test"); michael@0: michael@0: document.documentElement.setAttribute("windowtype", "navigator:browsertestdummy"); michael@0: michael@0: openWinWithCb(closeFirstWin, URIS_PINNED.concat(URIS_NORMAL_A)); michael@0: } michael@0: michael@0: function closeFirstWin(win) { michael@0: win.gBrowser.pinTab(win.gBrowser.tabs[0]); michael@0: win.gBrowser.pinTab(win.gBrowser.tabs[1]); michael@0: win.BrowserTryToCloseWindow(); michael@0: ok(win.closed, "window closed"); michael@0: michael@0: openWinWithCb(checkSecondWin, URIS_NORMAL_B, URIS_PINNED.concat(URIS_NORMAL_B)); michael@0: } michael@0: michael@0: function checkSecondWin(win) { michael@0: is(win.gBrowser.browsers[0].currentURI.spec, URIS_PINNED[0], "first pinned tab restored"); michael@0: is(win.gBrowser.browsers[1].currentURI.spec, URIS_PINNED[1], "second pinned tab restored"); michael@0: ok(win.gBrowser.tabs[0].pinned, "first pinned tab is still pinned"); michael@0: ok(win.gBrowser.tabs[1].pinned, "second pinned tab is still pinned"); michael@0: win.close(); michael@0: michael@0: // cleanup michael@0: document.documentElement.setAttribute("windowtype", "navigator:browser"); michael@0: finish(); michael@0: } michael@0: michael@0: function openWinWithCb(cb, argURIs, expectedURIs) { michael@0: if (!expectedURIs) michael@0: expectedURIs = argURIs; michael@0: michael@0: var win = openDialog(getBrowserURL(), "_blank", michael@0: "chrome,all,dialog=no", argURIs.join("|")); michael@0: michael@0: win.addEventListener("load", function () { michael@0: win.removeEventListener("load", arguments.callee, false); michael@0: info("the window loaded"); michael@0: michael@0: var expectedLoads = expectedURIs.length; michael@0: michael@0: win.gBrowser.addTabsProgressListener({ michael@0: onStateChange: function (aBrowser, aWebProgress, aRequest, aStateFlags, aStatus) { michael@0: if (aRequest && michael@0: aStateFlags & Ci.nsIWebProgressListener.STATE_STOP && michael@0: aStateFlags & Ci.nsIWebProgressListener.STATE_IS_NETWORK && michael@0: expectedURIs.indexOf(aRequest.QueryInterface(Ci.nsIChannel).originalURI.spec) > -1 && michael@0: --expectedLoads <= 0) { michael@0: win.gBrowser.removeTabsProgressListener(this); michael@0: info("all tabs loaded"); michael@0: is(win.gBrowser.tabs.length, expectedURIs.length, "didn't load any unexpected tabs"); michael@0: executeSoon(function () { michael@0: cb(win); michael@0: }); michael@0: } michael@0: } michael@0: }); michael@0: }, false); michael@0: }