Bug 1455296 - Include hidden tabs in the before close dialog r?dao draft
authorMark Striemer <mstriemer@mozilla.com>
Mon, 07 May 2018 12:21:10 -0500
changeset 792175 40ac4f7baf46d52ff4bf105bad903938b99d7f14
parent 792140 139dd5338407becb5bdef2429f41fa758e4b931d
push id109026
push userbmo:mstriemer@mozilla.com
push dateMon, 07 May 2018 19:53:27 +0000
reviewersdao
bugs1455296
milestone61.0a1
Bug 1455296 - Include hidden tabs in the before close dialog r?dao MozReview-Commit-ID: 4qaD7ixhDbJ
browser/base/content/tabbrowser.js
browser/locales/en-US/chrome/browser/tabbrowser.properties
--- a/browser/base/content/tabbrowser.js
+++ b/browser/base/content/tabbrowser.js
@@ -2479,29 +2479,34 @@ window._gBrowser = {
       });
     }
 
     return t;
   },
 
   warnAboutClosingTabs(aCloseTabs, aTab) {
     var tabsToClose;
+    var hiddenTabsToClose = 0;
+    let getHiddenTabCount = (tabs) => Array.from(tabs).reduce((sum, t) => sum + t.hidden, 0);
     switch (aCloseTabs) {
       case this.closingTabsEnum.ALL:
         tabsToClose = this.tabs.length - this._removingTabs.length -
           gBrowser._numPinnedTabs;
+        hiddenTabsToClose = getHiddenTabCount(this.tabs);
         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");
 
-        tabsToClose = this.getTabsToTheEndFrom(aTab).length;
+        let tabs = this.getTabsToTheEndFrom(aTab);
+        tabsToClose = tabs.length;
+        hiddenTabsToClose = getHiddenTabCount(tabs);
         break;
       default:
         throw new Error("Invalid argument: " + aCloseTabs);
     }
 
     if (tabsToClose <= 1)
       return true;
 
@@ -2517,19 +2522,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.hiddenTabName"))
+          .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,19 @@ 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
+tabs.tabName=1 tab;#1 tabs
+tabs.hiddenTabName=1 hidden tab;#1 hidden tabs
+tabs.closeWarningWithHidden=You are about to close %1$S, including %2$S. 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)