explicitly close window when closing last tab to fix strange 3.0.x bug
authorGavin Sharp <gavin@mozilla.com>
Thu, 27 Nov 2008 21:58:12 -0500
changeset 4 4b03928f2aed
parent 3 2ca1430df187
child 5 39b206d6d338
push id5
push usergsharp@mozilla.com
push dateFri, 28 Nov 2008 02:57:42 +0000
explicitly close window when closing last tab to fix strange 3.0.x bug
content/overlay.js
--- a/content/overlay.js
+++ b/content/overlay.js
@@ -92,15 +92,21 @@ var tabcloser = {
     // prompt?
     var message = this.strings.getFormattedString("areYouSure.message",
                                                 [tabsToClose.length, host]);
     var title = this.strings.getString("areYouSure");
     var promptService = Cc["@mozilla.org/embedcomp/prompt-service;1"].
                         getService(Ci.nsIPromptService);
     if (promptService.confirm(null, title, message)) {
       tabsToClose.forEach(function (el) {
-        gBrowser.removeTab(el);
+        // work around some strange bug in 3.0.x that causes removeTab to fail
+        // silently when closing the last tab this way. This isn't needed on
+        // trunk...
+        if (gBrowser.mTabs.length == 1)
+          closeWindow(true);
+        else
+          gBrowser.removeTab(t);
       });
     }
   },
 
 };
 window.addEventListener("load", function(e) { tabcloser.onLoad(e); }, false);