Bug 1483935 - correctly check all windows for tabs when quitting, r=mconley
authorGijs Kruitbosch <gijskruitbosch@gmail.com>
Mon, 20 Aug 2018 18:27:44 +0000
changeset 487657 00e27ad3f9ff5d5b4265cd99fa19bef10a3f3eb8
parent 487656 9c29ffcfc0520a46bee6a63db1aa48e5ef3c0f80
child 487658 f0da740d9db4f96035297a63976337b65f7711cf
push id9719
push userffxbld-merge
push dateFri, 24 Aug 2018 17:49:46 +0000
treeherdermozilla-beta@719ec98fba77 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmconley
bugs1483935, 1438499, 1475427
milestone63.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1483935 - correctly check all windows for tabs when quitting, r=mconley Bug 1438499 added an optional parameter to warnAboutClosingTabs. In bug 1475427, the arguments to warnAboutClosingTabs changed, and instead of passing a closing tab reference as the second argument, we now need to pass the number of tabs as the first argument. The patch in that bug updated the callsite in nsBrowserGlue.js to add the new argument, but didn't remove the `null` argument that we were passing for the 'extra' tab. Additionally, the change in bug 1475427 bails early from warnAboutClosingTabs if the number of tabs passed is less than 2. That tab count, too, needs to take into account multiple windows and not just the last window iterated over. This patch fixes both of these issues. Differential Revision: https://phabricator.services.mozilla.com/D3807
browser/components/nsBrowserGlue.js
--- a/browser/components/nsBrowserGlue.js
+++ b/browser/components/nsBrowserGlue.js
@@ -1666,18 +1666,20 @@ BrowserGlue.prototype = {
     var windowcount = 0;
     var pagecount = 0;
     for (let win of BrowserWindowTracker.orderedWindows) {
       if (win.closed) {
         continue;
       }
       windowcount++;
       let tabbrowser = win.gBrowser;
-      if (tabbrowser)
-        pagecount += tabbrowser.browsers.length - tabbrowser._numPinnedTabs;
+      if (tabbrowser) {
+        pagecount += tabbrowser.browsers.length - tabbrowser._numPinnedTabs -
+                     tabbrowser._removingTabs.length;
+      }
     }
 
     if (pagecount < 2)
       return;
 
     if (!aQuitType)
       aQuitType = "quit";
 
@@ -1690,29 +1692,28 @@ BrowserGlue.prototype = {
     if (sessionWillBeRestored || !Services.prefs.getBoolPref("browser.warnOnQuit") ||
         !Services.prefs.getBoolPref("browser.tabs.warnOnClose"))
       return;
 
     let win = BrowserWindowTracker.getTopWindow();
 
     // warnAboutClosingTabs checks browser.tabs.warnOnClose and returns if it's
     // ok to close the window. It doesn't actually close the window.
-    let closingTabs = win.gBrowser.tabs.length - win.gBrowser._removingTabs.length;
     if (windowcount == 1) {
       aCancelQuit.data =
-        !win.gBrowser.warnAboutClosingTabs(closingTabs, win.gBrowser.closingTabsEnum.ALL);
+        !win.gBrowser.warnAboutClosingTabs(pagecount, win.gBrowser.closingTabsEnum.ALL);
     } else {
       // More than 1 window. Compose our own message.
       let tabSubstring = gTabbrowserBundle.GetStringFromName("tabs.closeWarningMultipleWindowsTabSnippet");
       tabSubstring = PluralForm.get(pagecount, tabSubstring).replace(/#1/, pagecount);
       let windowString = gTabbrowserBundle.GetStringFromName("tabs.closeWarningMultipleWindows");
       windowString = PluralForm.get(windowcount, windowString).replace(/#1/, windowcount);
       windowString = windowString.replace(/%(?:1$)?S/i, tabSubstring);
       aCancelQuit.data =
-        !win.gBrowser.warnAboutClosingTabs(closingTabs, win.gBrowser.closingTabsEnum.ALL, null, windowString);
+        !win.gBrowser.warnAboutClosingTabs(pagecount, win.gBrowser.closingTabsEnum.ALL, windowString);
     }
   },
 
   _showUpdateNotification: function BG__showUpdateNotification() {
     Services.prefs.clearUserPref("app.update.postupdate");
 
     var um = Cc["@mozilla.org/updates/update-manager;1"].
              getService(Ci.nsIUpdateManager);