Bug 677424: If a tab is closed between quit-application-requested and quit-application-granted then it is still restored when the application restarts. r=zpao
☠☠ backed out by 9698a1031317 ☠ ☠
authorDave Townsend <dtownsend@oxymoronical.com>
Thu, 11 Aug 2011 19:35:48 -0700
changeset 74322 d980e7a3aa49389ecc55ef7066048fdeac7c7845
parent 74321 1dd81c324ac739060ab16ad9bf444beecd7e2406
child 74323 eee41544cb847990fa7c3994eff1118c1402a7a8
push id2
push userbsmedberg@mozilla.com
push dateFri, 19 Aug 2011 14:38:13 +0000
reviewerszpao
bugs677424
milestone8.0a1
Bug 677424: If a tab is closed between quit-application-requested and quit-application-granted then it is still restored when the application restarts. r=zpao
browser/components/sessionstore/src/nsSessionStore.js
--- a/browser/components/sessionstore/src/nsSessionStore.js
+++ b/browser/components/sessionstore/src/nsSessionStore.js
@@ -1060,16 +1060,24 @@ SessionStoreService.prototype = {
         title: tabTitle,
         image: aTab.getAttribute("image"),
         pos: aTab._tPos
       });
       var length = this._windows[aWindow.__SSi]._closedTabs.length;
       if (length > maxTabsUndo)
         this._windows[aWindow.__SSi]._closedTabs.splice(maxTabsUndo, length - maxTabsUndo);
     }
+
+    // Remove the tab from the saved window state if it matches what is already
+    // there. This solves bug 677424
+    if (aTab._tPos < this._windows[aWindow.__SSi].tabs.length) {
+      var oldTab = this._windows[aWindow.__SSi].tabs[aTab._tPos];
+      if (oldTab.entries[oldTab.index - 1].url == aTab.linkedBrowser.currentURI.spec)
+        this._windows[aWindow.__SSi].tabs.splice(aTab._tPos, 1);
+    }
   },
 
   /**
    * When a tab loads, save state.
    * @param aWindow
    *        Window reference
    * @param aBrowser
    *        Browser reference