Bug 563337 - "Error: preview is undefined" and "this.preview is undefined" when closing the last tab with browser.tabs.closeWindowWithLastTab = false. r=gavin
authorDão Gottwald <dao@mozilla.com>
Wed, 18 May 2011 10:04:36 +0200
changeset 69684 fde29e9e42ac0a3cc230463c885249d18e318674
parent 69683 63284a27cb1b57ea8bde163cb78fb42a21debedf
child 69685 caba046161e5d8d127f86f7196d2dc50163f6527
push idunknown
push userunknown
push dateunknown
reviewersgavin
bugs563337
milestone6.0a1
Bug 563337 - "Error: preview is undefined" and "this.preview is undefined" when closing the last tab with browser.tabs.closeWindowWithLastTab = false. r=gavin
browser/base/content/tabbrowser.xml
--- a/browser/base/content/tabbrowser.xml
+++ b/browser/base/content/tabbrowser.xml
@@ -1532,18 +1532,20 @@
                   this._removingTabs.length == 0 &&
                   (this._windowIsClosing = window.closeWindow(true)))
                 return null;
 
               newTab = true;
             }
 
             this._removingTabs.push(aTab);
-
-            this.tabContainer.updateVisibility();
+            if (newTab)
+              this.addTab("about:blank", {skipAnimation: true});
+            else
+              this.tabContainer.updateVisibility();
 
             // We're committed to closing the tab now.
             // Dispatch a notification.
             // We dispatch it before any teardown so that event listeners can
             // inspect the tab that's about to close.
             var evt = document.createEvent("UIEvent");
             evt.initUIEvent("TabClose", true, false, window, aTabWillBeMoved ? 1 : 0);
             aTab.dispatchEvent(evt);
@@ -1589,18 +1591,16 @@
               aCloseWindow = false;
               aNewTab = false;
             }
 
             this._lastRelatedTab = null;
 
             // update the UI early for responsiveness
             aTab.collapsed = true;
-            if (aNewTab)
-              this.addTab("about:blank", {skipAnimation: true});
             this.tabContainer._fillTrailingGap();
             this._blurTab(aTab);
 
             this._removingTabs.splice(this._removingTabs.indexOf(aTab), 1);
 
             if (aCloseWindow) {
               this._windowIsClosing = true;
               while (this._removingTabs.length)