1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/browser/components/sessionstore/test/browser_580512.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,73 @@ 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 URIS_PINNED = ["about:license", "about:about"]; 1.9 +const URIS_NORMAL_A = ["about:mozilla"]; 1.10 +const URIS_NORMAL_B = ["about:buildconfig"]; 1.11 + 1.12 +function test() { 1.13 + waitForExplicitFinish(); 1.14 + 1.15 + isnot(Services.prefs.getIntPref("browser.startup.page"), 3, 1.16 + "pref to save session must not be set for this test"); 1.17 + ok(!Services.prefs.getBoolPref("browser.sessionstore.resume_session_once"), 1.18 + "pref to save session once must not be set for this test"); 1.19 + 1.20 + document.documentElement.setAttribute("windowtype", "navigator:browsertestdummy"); 1.21 + 1.22 + openWinWithCb(closeFirstWin, URIS_PINNED.concat(URIS_NORMAL_A)); 1.23 +} 1.24 + 1.25 +function closeFirstWin(win) { 1.26 + win.gBrowser.pinTab(win.gBrowser.tabs[0]); 1.27 + win.gBrowser.pinTab(win.gBrowser.tabs[1]); 1.28 + win.BrowserTryToCloseWindow(); 1.29 + ok(win.closed, "window closed"); 1.30 + 1.31 + openWinWithCb(checkSecondWin, URIS_NORMAL_B, URIS_PINNED.concat(URIS_NORMAL_B)); 1.32 +} 1.33 + 1.34 +function checkSecondWin(win) { 1.35 + is(win.gBrowser.browsers[0].currentURI.spec, URIS_PINNED[0], "first pinned tab restored"); 1.36 + is(win.gBrowser.browsers[1].currentURI.spec, URIS_PINNED[1], "second pinned tab restored"); 1.37 + ok(win.gBrowser.tabs[0].pinned, "first pinned tab is still pinned"); 1.38 + ok(win.gBrowser.tabs[1].pinned, "second pinned tab is still pinned"); 1.39 + win.close(); 1.40 + 1.41 + // cleanup 1.42 + document.documentElement.setAttribute("windowtype", "navigator:browser"); 1.43 + finish(); 1.44 +} 1.45 + 1.46 +function openWinWithCb(cb, argURIs, expectedURIs) { 1.47 + if (!expectedURIs) 1.48 + expectedURIs = argURIs; 1.49 + 1.50 + var win = openDialog(getBrowserURL(), "_blank", 1.51 + "chrome,all,dialog=no", argURIs.join("|")); 1.52 + 1.53 + win.addEventListener("load", function () { 1.54 + win.removeEventListener("load", arguments.callee, false); 1.55 + info("the window loaded"); 1.56 + 1.57 + var expectedLoads = expectedURIs.length; 1.58 + 1.59 + win.gBrowser.addTabsProgressListener({ 1.60 + onStateChange: function (aBrowser, aWebProgress, aRequest, aStateFlags, aStatus) { 1.61 + if (aRequest && 1.62 + aStateFlags & Ci.nsIWebProgressListener.STATE_STOP && 1.63 + aStateFlags & Ci.nsIWebProgressListener.STATE_IS_NETWORK && 1.64 + expectedURIs.indexOf(aRequest.QueryInterface(Ci.nsIChannel).originalURI.spec) > -1 && 1.65 + --expectedLoads <= 0) { 1.66 + win.gBrowser.removeTabsProgressListener(this); 1.67 + info("all tabs loaded"); 1.68 + is(win.gBrowser.tabs.length, expectedURIs.length, "didn't load any unexpected tabs"); 1.69 + executeSoon(function () { 1.70 + cb(win); 1.71 + }); 1.72 + } 1.73 + } 1.74 + }); 1.75 + }, false); 1.76 +}