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

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Gijs Kruitbosch 2018-08-20 18:27:44 +00:00
Родитель 9626944cd5
Коммит dde42d4dfa
1 изменённых файлов: 6 добавлений и 5 удалений

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

@ -1671,8 +1671,10 @@ BrowserGlue.prototype = {
}
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)
@ -1695,10 +1697,9 @@ BrowserGlue.prototype = {
// 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");
@ -1707,7 +1708,7 @@ BrowserGlue.prototype = {
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);
}
},