bug 348031 - make Cmd+W always close the window on the last tab
--- a/browser/base/content/browser.js
+++ b/browser/base/content/browser.js
@@ -1609,25 +1609,31 @@ function BrowserCloseTabOrWindow()
#ifdef XP_MACOSX
// If we're not a browser window, just close the window
if (window.location.href != getBrowserURL()) {
closeWindow(true);
return;
}
#endif
- if (gBrowser.tabContainer.childNodes.length > 1 ||
- window.toolbar.visible && !gPrefService.getBoolPref("browser.tabs.autoHide")) {
- // Just close the tab (and focus the address bar if it was the last one).
- var isLastTab = gBrowser.tabContainer.childNodes.length == 1;
+ if (gBrowser.tabContainer.childNodes.length > 1) {
+ gBrowser.removeCurrentTab();
+ return;
+ }
+
+#ifndef XP_MACOSX
+ if (gBrowser.localName == "tabbrowser" && window.toolbar.visible &&
+ !gPrefService.getBoolPref("browser.tabs.autoHide")) {
+ // Replace the remaining tab with a blank one and focus the address bar
gBrowser.removeCurrentTab();
- if (isLastTab && gURLBar)
+ if (gURLBar)
setTimeout(function() { gURLBar.focus(); }, 0);
return;
}
+#endif
closeWindow(true);
}
function BrowserTryToCloseWindow()
{
if (WindowIsClosing())
window.close(); // WindowIsClosing does all the necessary checks