Bug 511640 - Port Bug 490040 [Reattaching a lone tab into another window causes an empty window to be added to Recently Closed Windows], r+sr=Neil
authorMisak Khachatryan <misak@xter.net>
Tue, 25 Aug 2009 18:32:49 +0200
changeset 3412 0a8d10dcc7595c29be3ba1d8a3e1c1a8bc53b096
parent 3411 cea01fa911fb5681860d4a10d1b4e9bbc790983f
child 3413 da5af32d8c069a7262d894d6e9359d8ef285bac0
push idunknown
push userunknown
push dateunknown
bugs511640, 490040
Bug 511640 - Port Bug 490040 [Reattaching a lone tab into another window causes an empty window to be added to Recently Closed Windows], r+sr=Neil
suite/common/src/nsSessionStore.js
--- a/suite/common/src/nsSessionStore.js
+++ b/suite/common/src/nsSessionStore.js
@@ -393,17 +393,19 @@ SessionStoreService.prototype = {
       case "TabOpen":
       case "TabClose":
         var panelID = aEvent.originalTarget.linkedPanel;
         var tabpanel = aEvent.originalTarget.ownerDocument.getElementById(panelID);
         if (aEvent.type == "TabOpen") {
           this.onTabAdd(aEvent.currentTarget.ownerDocument.defaultView, tabpanel);
         }
         else {
-          this.onTabClose(aEvent.currentTarget.ownerDocument.defaultView, aEvent.originalTarget);
+          // aEvent.detail determines if the tab was closed by moving to a different window
+          if (!aEvent.detail)
+            this.onTabClose(aEvent.currentTarget.ownerDocument.defaultView, aEvent.originalTarget);
           this.onTabRemove(aEvent.currentTarget.ownerDocument.defaultView, tabpanel);
         }
         break;
       case "TabSelect":
         var tabpanels = aEvent.currentTarget.mPanelContainer;
         this.onTabSelect(aEvent.currentTarget.ownerDocument.defaultView, tabpanels);
         break;
     }
@@ -522,19 +524,22 @@ SessionStoreService.prototype = {
 
       if (isFullyLoaded) {
         winData.title = aWindow.content.document.title || tabbrowser.selectedTab.label;
         winData.title = this._replaceLoadingTitle(winData.title, tabbrowser,
                                                   tabbrowser.selectedTab);
         this._updateCookies([winData]);
       }
 
-      // store closed-window data for undo
-      this._closedWindows.unshift(winData);
-      this._capClosedWindows();
+      // save the window if it has multiple tabs or a single tab with entries
+      if (winData.tabs.length > 1 ||
+          (winData.tabs.length == 1 && winData.tabs[0].entries.length > 0)) {
+        this._closedWindows.unshift(winData);
+        this._capClosedWindows();
+      }
 
       // clear this window from the list
       delete this._windows[aWindow.__SSi];
 
       // save the state without this window to disk
       this.saveStateDelayed();
     }