Bug 852267 - Part 2 - Add a null check before restoring history. r=margaret draft
authorJan Henning <jh+bugzilla@buttercookie.de>
Thu, 31 Mar 2016 21:05:02 +0200
changeset 347351 f5cec589e03f3ef32365ae1cde1137b46545d03b
parent 346789 aa736257b6103ae9f12e4a9de85740adcc6b491d
child 347352 d575f8d79742addfa40859af827911e0ad768d40
push id14563
push usermozilla@buttercookie.de
push dateMon, 04 Apr 2016 18:09:06 +0000
reviewersmargaret
bugs852267, 1229259
milestone48.0a1
Bug 852267 - Part 2 - Add a null check before restoring history. r=margaret Normally we shouldn't get into a situation where aTabData will be null/empty when trying to restore history, but bug 1229259 comment 10 shows that this can somehow still happen, most probably because we zombified a tab before it had any chance to build some session data. MozReview-Commit-ID: 9Mw55NTiVTP
mobile/android/components/SessionStore.js
--- a/mobile/android/components/SessionStore.js
+++ b/mobile/android/components/SessionStore.js
@@ -988,22 +988,28 @@ SessionStore.prototype = {
     return Services.prefs.getIntPref(pref) < (isHTTPS ? PRIVACY_ENCRYPTED : PRIVACY_FULL);
   },
 
   /**
   * Starts the restoration process for a browser. History is restored at this
   * point, but text data must be delayed until the content loads.
   */
   _restoreTab: function ss_restoreTab(aTabData, aBrowser) {
+    // aTabData shouldn't be empty here, but if it is,
+    // _restoreHistory() will crash otherwise.
+    if (!aTabData || aTabData.entries.length == 0) {
+      Cu.reportError("SessionStore.js: Error trying to restore tab with empty tabdata");
+      return;
+    }
     this._restoreHistory(aTabData, aBrowser.sessionHistory);
 
     // Restoring the text data requires waiting for the content to load. So
     // we set a flag and delay this until the "load" event.
     //this._restoreTextData(aTabData, aBrowser);
-    aBrowser.__SS_restore_data = aTabData || {};
+    aBrowser.__SS_restore_data = aTabData;
   },
 
   /**
   * Takes serialized history data and create news entries into the given
   * nsISessionHistory object.
   */
   _restoreHistory: function ss_restoreHistory(aTabData, aHistory) {
     if (aHistory.count > 0) {