Bug 844561 - Avoid prompting about closing private windows unnecessarily. r=ehsan

This commit is contained in:
Josh Matthews 2013-02-27 13:06:46 -05:00
Родитель 37f9634b1b
Коммит 54ba5e82d4
3 изменённых файлов: 20 добавлений и 5 удалений

Просмотреть файл

@ -6403,20 +6403,20 @@ function warnAboutClosingWindow() {
// Figure out if there's at least one other browser window around.
let e = Services.wm.getEnumerator("navigator:browser");
let otherPBWindowExists = false;
let warnAboutClosingTabs = false;
let nonPopupPresent = false;
while (e.hasMoreElements()) {
let win = e.getNext();
if (win != window) {
if (isPBWindow && PrivateBrowsingUtils.isWindowPrivate(win))
otherPBWindowExists = true;
if (win.toolbar.visible)
warnAboutClosingTabs = true;
nonPopupPresent = true;
// If the current window is not in private browsing mode we don't need to
// look for other pb windows, we can leave the loop when finding the
// first non-popup window. If however the current window is in private
// browsing mode then we need at least one other pb and one non-popup
// window to break out early.
if ((!isPBWindow || otherPBWindowExists) && warnAboutClosingTabs)
if ((!isPBWindow || otherPBWindowExists) && nonPopupPresent)
break;
}
}
@ -6431,7 +6431,8 @@ function warnAboutClosingWindow() {
if (exitingCanceled.data)
return false;
}
if (warnAboutClosingTabs)
if (!isPBWindow && nonPopupPresent)
return gBrowser.warnAboutClosingTabs(true);
let os = Services.obs;
@ -6449,7 +6450,7 @@ function warnAboutClosingWindow() {
// OS X doesn't quit the application when the last window is closed, but keeps
// the session alive. Hence don't prompt users to save tabs, but warn about
// closing multiple tabs.
return gBrowser.warnAboutClosingTabs(true);
return isPBWindow || gBrowser.warnAboutClosingTabs(true);
#else
return true;
#endif

Просмотреть файл

@ -313,6 +313,7 @@ _BROWSER_FILES = \
feed_tab.html \
browser_pluginCrashCommentAndURL.js \
pluginCrashCommentAndURL.html \
browser_private_no_prompt.js \
$(NULL)
# Disable test on Windows due to frequent failures (bug 841341)

Просмотреть файл

@ -0,0 +1,13 @@
function test() {
waitForExplicitFinish();
var privateWin = OpenBrowserWindow({private: true});
privateWin.addEventListener("load", function onload() {
privateWin.removeEventListener("load", onload, false);
ok(true, "Load listener called");
privateWin.BrowserOpenTab();
privateWin.BrowserTryToCloseWindow();
ok(true, "didn't prompt");
finish();
}, false);
}