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
--- 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) {