Bug 1455296 - Include hidden tab count in the confirm close dialog r?dao
MozReview-Commit-ID: 4qaD7ixhDbJ
--- a/browser/base/content/tabbrowser.js
+++ b/browser/base/content/tabbrowser.js
@@ -2515,20 +2515,22 @@ window._gBrowser = {
this._notifyPinnedStatus(t);
}
return t;
},
warnAboutClosingTabs(aCloseTabs, aTab) {
var tabsToClose;
+ var hiddenTabsToClose = 0;
switch (aCloseTabs) {
case this.closingTabsEnum.ALL:
tabsToClose = this.tabs.length - this._removingTabs.length -
gBrowser._numPinnedTabs;
+ hiddenTabsToClose = Array.from(this.tabs).reduce((sum, t) => sum + t.hidden, 0);
break;
case this.closingTabsEnum.OTHER:
tabsToClose = this.visibleTabs.length - 1 - gBrowser._numPinnedTabs;
break;
case this.closingTabsEnum.TO_END:
if (!aTab)
throw new Error("Required argument missing: aTab");
@@ -2553,19 +2555,31 @@ window._gBrowser = {
var warnOnClose = { value: true };
// focus the window before prompting.
// this will raise any minimized window, which will
// make it obvious which window the prompt is for and will
// solve the problem of windows "obscuring" the prompt.
// see bug #350299 for more details
window.focus();
- var warningMessage =
- PluralForm.get(tabsToClose, gTabBrowserBundle.GetStringFromName("tabs.closeWarningMultiple"))
- .replace("#1", tabsToClose);
+ var warningMessage;
+ if (hiddenTabsToClose > 0) {
+ let tabsMessage = PluralForm.get(
+ tabsToClose, gTabBrowserBundle.GetStringFromName("tabs.tabName"))
+ .replace("#1", tabsToClose);
+ let hiddenTabsMessage = PluralForm.get(
+ hiddenTabsToClose, gTabBrowserBundle.GetStringFromName("tabs.tabName"))
+ .replace("#1", hiddenTabsToClose);
+ warningMessage = gTabBrowserBundle.formatStringFromName(
+ "tabs.closeWarningWithHidden", [tabsMessage, hiddenTabsMessage], 2);
+ } else {
+ warningMessage = PluralForm.get(
+ tabsToClose, gTabBrowserBundle.GetStringFromName("tabs.closeWarningMultiple"))
+ .replace("#1", tabsToClose);
+ }
var buttonPressed =
ps.confirmEx(window,
gTabBrowserBundle.GetStringFromName("tabs.closeWarningTitle"),
warningMessage,
(ps.BUTTON_TITLE_IS_STRING * ps.BUTTON_POS_0) +
(ps.BUTTON_TITLE_CANCEL * ps.BUTTON_POS_1),
gTabBrowserBundle.GetStringFromName("tabs.closeButtonMultiple"),
null, null,
--- a/browser/locales/en-US/chrome/browser/tabbrowser.properties
+++ b/browser/locales/en-US/chrome/browser/tabbrowser.properties
@@ -10,16 +10,24 @@ tabs.closeWarningTitle=Confirm close
# LOCALIZATION NOTE (tabs.closeWarningMultiple):
# Semicolon-separated list of plural forms. See:
# http://developer.mozilla.org/en/docs/Localization_and_Plurals
# The singular form is not considered since this string is used only for
# multiple tabs.
tabs.closeWarningMultiple=;You are about to close #1 tabs. Are you sure you want to continue?
tabs.closeButtonMultiple=Close tabs
tabs.closeWarningPromptMe=Warn me when I attempt to close multiple tabs
+# LOCALIZATION NOTE (tabs.tabName)
+# This string is injected into other strings that reference tab counts. Namely
+# tabs.closeWarningWithHidden which would be like "You are about to close 5 tabs...".
+tabs.tabName=1 tab;#1 tabs
+# LOCALIZATION NOTE (tabs.closeWarningWithHidden):
+# %1$S and %2$s will be strings like "5 tabs". These are generated with the
+# tabs.tabName string.
+tabs.closeWarningWithHidden=You are about to close %1$S, including %2$S hidden by an extension. Are you sure you want to continue?
tabs.closeTab.tooltip=Close tab
# LOCALIZATION NOTE (tabs.closeSelectedTab.tooltip):
# %S is the keyboard shortcut for closing the current tab
tabs.closeSelectedTab.tooltip=Close tab (%S)
# LOCALIZATION NOTE (tabs.muteAudio.tooltip):
# %S is the keyboard shortcut for "Mute tab"
tabs.muteAudio.tooltip=Mute tab (%S)