Bug 958166 - Fix error saving tabs from other groups to session store. r=emtwo, a=lsblakk
authorMatt Brubeck <mbrubeck@mozilla.com>
Thu, 09 Jan 2014 12:13:12 -0800
changeset 175797 37f7074626f66a420df38f8711183cff461ac099
parent 175796 6d14601401882a0a60cd175ebb46df8d5eb8a104
child 175798 9734d99bf243ab24d47dd9d834bf25f01e74a2d1
push id445
push userffxbld
push dateMon, 10 Mar 2014 22:05:19 +0000
treeherdermozilla-release@dc38b741b04e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersemtwo, lsblakk
bugs958166
milestone28.0a2
Bug 958166 - Fix error saving tabs from other groups to session store. r=emtwo, a=lsblakk
browser/metro/components/SessionStore.js
--- a/browser/metro/components/SessionStore.js
+++ b/browser/metro/components/SessionStore.js
@@ -534,42 +534,40 @@ SessionStore.prototype = {
     let tabData = {};
     tabData.entries = aHistory.entries;
     tabData.index = aHistory.index;
     tabData.attributes = { image: aBrowser.mIconURL };
 
     aBrowser.__SS_data = tabData;
   },
 
-  _saveTabData: function(aTabList, aWinData) {
-    for (let tab of aTabList) {
+  _getTabData: function(aWindow) {
+    return aWindow.Browser.tabs.map(tab => {
       let browser = tab.browser;
       if (browser.__SS_data) {
         let tabData = browser.__SS_data;
         if (browser.__SS_extdata)
           tabData.extData = browser.__SS_extdata;
-        aWinData.tabs.push(tabData);
+        return tabData;
       }
-    }
+    });
   },
 
   _collectWindowData: function ss__collectWindowData(aWindow) {
     // Ignore windows not tracked by SessionStore
     if (!aWindow.__SSID || !this._windows[aWindow.__SSID])
       return;
 
     let winData = this._windows[aWindow.__SSID];
-    winData.tabs = [];
 
     let index = aWindow.Elements.browsers.selectedIndex;
     winData.selected = parseInt(index) + 1; // 1-based
 
-    let tabs = aWindow.Browser.tabs;
-    this._saveTabData(tabs, winData);
-    this._saveTabData(this._tabsFromOtherGroups, winData);
+    let tabData = this._getTabData(aWindow);
+    winData.tabs = tabData.concat(this._tabsFromOtherGroups);
   },
 
   _forEachBrowserWindow: function ss_forEachBrowserWindow(aFunc) {
     let windowsEnum = Services.wm.getEnumerator("navigator:browser");
     while (windowsEnum.hasMoreElements()) {
       let window = windowsEnum.getNext();
       if (window.__SSID && !window.closed)
         aFunc.call(this, window);
@@ -788,18 +786,19 @@ SessionStore.prototype = {
         // Move all window data from sessionstore.js to this._windows.
         for (let i = 0; i < data.windows.length; i++) {
           let SSID;
           if (i != windowIndex) {
             SSID = "window" + gUUIDGenerator.generateUUID().toString();
             this._windows[SSID] = data.windows[i];
           } else {
             SSID = window.__SSID;
+            this._windows[SSID].extData = data.windows[i].extData;
             this._windows[SSID]._closedTabs =
-              this._windows[SSID]._closedTabs.concat(data.windows[windowIndex]._closedTabs);
+              this._windows[SSID]._closedTabs.concat(data.windows[i]._closedTabs);
           }
           this._orderedWindows.push(SSID);
         }
 
         if (selected > tabs.length) // Clamp the selected index if it's bogus
           selected = 1;
 
         for (let i=0; i<tabs.length; i++) {