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 347273 ad09950144312e6a0e40a9158a620737c26944ec
parent 346789 aa736257b6103ae9f12e4a9de85740adcc6b491d
child 347340 0666d6febc55f99dea69f4e631190192ec08122d
push id14531
push usermozilla@buttercookie.de
push dateMon, 04 Apr 2016 08:33:19 +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. 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) {
+      dump("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) {