diff options
author | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
---|---|---|
committer | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
commit | 5f8de423f190bbb79a62f804151bc24824fa32d8 (patch) | |
tree | 10027f336435511475e392454359edea8e25895d /browser/components/sessionstore/test/browser_580512.js | |
parent | 49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff) | |
download | UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip |
Add m-esr52 at 52.6.0
Diffstat (limited to 'browser/components/sessionstore/test/browser_580512.js')
-rw-r--r-- | browser/components/sessionstore/test/browser_580512.js | 81 |
1 files changed, 81 insertions, 0 deletions
diff --git a/browser/components/sessionstore/test/browser_580512.js b/browser/components/sessionstore/test/browser_580512.js new file mode 100644 index 000000000..ef048cd37 --- /dev/null +++ b/browser/components/sessionstore/test/browser_580512.js @@ -0,0 +1,81 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +const URIS_PINNED = ["about:license", "about:about"]; +const URIS_NORMAL_A = ["about:mozilla"]; +const URIS_NORMAL_B = ["about:buildconfig"]; + +function test() { + waitForExplicitFinish(); + + isnot(Services.prefs.getIntPref("browser.startup.page"), 3, + "pref to save session must not be set for this test"); + ok(!Services.prefs.getBoolPref("browser.sessionstore.resume_session_once"), + "pref to save session once must not be set for this test"); + + document.documentElement.setAttribute("windowtype", "navigator:browsertestdummy"); + + openWinWithCb(closeFirstWin, URIS_PINNED.concat(URIS_NORMAL_A)); +} + +function closeFirstWin(win) { + win.gBrowser.pinTab(win.gBrowser.tabs[0]); + win.gBrowser.pinTab(win.gBrowser.tabs[1]); + + let winClosed = BrowserTestUtils.windowClosed(win); + // We need to call BrowserTryToCloseWindow in order to trigger + // the machinery that chooses whether or not to save the session + // for the last window. + win.BrowserTryToCloseWindow(); + ok(win.closed, "window closed"); + + winClosed.then(() => { + openWinWithCb(checkSecondWin, URIS_NORMAL_B, URIS_PINNED.concat(URIS_NORMAL_B)); + }); +} + +function checkSecondWin(win) { + is(win.gBrowser.browsers[0].currentURI.spec, URIS_PINNED[0], "first pinned tab restored"); + is(win.gBrowser.browsers[1].currentURI.spec, URIS_PINNED[1], "second pinned tab restored"); + ok(win.gBrowser.tabs[0].pinned, "first pinned tab is still pinned"); + ok(win.gBrowser.tabs[1].pinned, "second pinned tab is still pinned"); + + BrowserTestUtils.closeWindow(win).then(() => { + // cleanup + document.documentElement.setAttribute("windowtype", "navigator:browser"); + finish(); + }); +} + +function openWinWithCb(cb, argURIs, expectedURIs) { + if (!expectedURIs) + expectedURIs = argURIs; + + var win = openDialog(getBrowserURL(), "_blank", + "chrome,all,dialog=no", argURIs.join("|")); + + win.addEventListener("load", function () { + win.removeEventListener("load", arguments.callee, false); + info("the window loaded"); + + var expectedLoads = expectedURIs.length; + + win.gBrowser.addTabsProgressListener({ + onStateChange: function (aBrowser, aWebProgress, aRequest, aStateFlags, aStatus) { + if (aRequest && + aStateFlags & Ci.nsIWebProgressListener.STATE_STOP && + aStateFlags & Ci.nsIWebProgressListener.STATE_IS_NETWORK && + expectedURIs.indexOf(aRequest.QueryInterface(Ci.nsIChannel).originalURI.spec) > -1 && + --expectedLoads <= 0) { + win.gBrowser.removeTabsProgressListener(this); + info("all tabs loaded"); + is(win.gBrowser.tabs.length, expectedURIs.length, "didn't load any unexpected tabs"); + executeSoon(function () { + cb(win); + }); + } + } + }); + }, false); +} |