Bug 590268 - Provide access to sessionstore tab data sooner [r=dietrich, a=blocking2.0:betaN]
authorIan Gilman <ian@iangilman.com>
Tue, 26 Oct 2010 11:55:10 -0700
changeset 56515 85cf0af22be3238fb19a9489702e6bc34e85fd7d
parent 56514 3d56a8182a7aafafaf2eade5fc7326ac0d6639d2
child 56516 e98bd46f26407fced5dd77c87f9deb5d4616ade4
push id16593
push userposhannessy@mozilla.com
push dateTue, 26 Oct 2010 18:58:53 +0000
treeherdermozilla-central@e7a1b719e090 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdietrich, blocking2
bugs590268
milestone2.0b8pre
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 590268 - Provide access to sessionstore tab data sooner [r=dietrich, a=blocking2.0:betaN]
browser/components/sessionstore/src/nsSessionStore.js
--- a/browser/components/sessionstore/src/nsSessionStore.js
+++ b/browser/components/sessionstore/src/nsSessionStore.js
@@ -1263,25 +1263,42 @@ SessionStoreService.prototype = {
     if (aWindow.__SSi && this._windows[aWindow.__SSi].extData &&
         this._windows[aWindow.__SSi].extData[aKey])
       delete this._windows[aWindow.__SSi].extData[aKey];
     else
       throw (Components.returnCode = Cr.NS_ERROR_INVALID_ARG);
   },
 
   getTabValue: function sss_getTabValue(aTab, aKey) {
-    var data = aTab.__SS_extdata || {};
+    let data = {};
+    if (aTab.__SS_extdata) {
+      data = aTab.__SS_extdata;
+    }
+    else if (aTab.linkedBrowser.__SS_data && aTab.linkedBrowser.__SS_data.extData) {
+      // If the tab hasn't been fully restored, get the data from the to-be-restored data
+      data = aTab.linkedBrowser.__SS_data.extData;
+    }
     return data[aKey] || "";
   },
 
   setTabValue: function sss_setTabValue(aTab, aKey, aStringValue) {
-    if (!aTab.__SS_extdata) {
+    // If the tab hasn't been restored, then set the data there, otherwise we
+    // could lose newly added data.
+    let saveTo;
+    if (aTab.__SS_extdata) {
+      saveTo = aTab.__SS_extdata;
+    }
+    else if (aTab.linkedBrowser.__SS_data && aTab.linkedBrowser.__SS_data.extData) {
+      saveTo = aTab.linkedBrowser.__SS_data.extData;
+    }
+    else {
       aTab.__SS_extdata = {};
+      saveTo = aTab.__SS_extdata;
     }
-    aTab.__SS_extdata[aKey] = aStringValue;
+    saveTo[aKey] = aStringValue;
     this.saveStateDelayed(aTab.ownerDocument.defaultView);
   },
 
   deleteTabValue: function sss_deleteTabValue(aTab, aKey) {
     if (aTab.__SS_extdata && aTab.__SS_extdata[aKey])
       delete aTab.__SS_extdata[aKey];
     else
       throw (Components.returnCode = Cr.NS_ERROR_INVALID_ARG);