Reland bug 476928 (Backed out changeset ce9c2499760d)
authorDão Gottwald <dao@mozilla.com>
Sat, 04 Apr 2009 21:37:38 +0200
changeset 24225 7d20407a4bec8f0f0cfe29943fdcb7d98c861be0
parent 24202 ce9c2499760da70e59b08f589fb440dfa4374c1a
child 24226 d158f30ccde126a47260438f0972543d328d3e02
push id1087
push userdgottwald@mozilla.com
push dateSat, 04 Apr 2009 19:38:40 +0000
bugs476928
milestone1.9.1b4pre
Reland bug 476928 (Backed out changeset ce9c2499760d)
browser/components/sessionstore/src/nsSessionStore.js
--- a/browser/components/sessionstore/src/nsSessionStore.js
+++ b/browser/components/sessionstore/src/nsSessionStore.js
@@ -1659,18 +1659,19 @@ SessionStoreService.prototype = {
       tabs.push(t < openTabCount ? tabbrowser.mTabs[t] : tabbrowser.addTab());
       // when resuming at startup: add additionally requested pages to the end
       if (!aOverwriteTabs && root._firstTabs) {
         tabbrowser.moveTabTo(tabs[t], t);
       }
     }
 
     // when overwriting tabs, remove all superflous ones
-    for (t = openTabCount - 1; t >= newTabCount; t--) {
-      tabbrowser.removeTab(tabbrowser.mTabs[t]);
+    if (aOverwriteTabs && newTabCount < openTabCount) {
+      Array.slice(tabbrowser.mTabs, newTabCount, openTabCount)
+           .forEach(tabbrowser.removeTab, tabbrowser);
     }
     
     if (aOverwriteTabs) {
       this.restoreWindowFeatures(aWindow, winData);
     }
     if (winData.cookies) {
       this.restoreCookies(winData.cookies);
     }