diff --git a/browser/components/sessionstore/src/nsSessionStore.js b/browser/components/sessionstore/src/nsSessionStore.js index 7deda88583a2..ca43ce973f24 100644 --- a/browser/components/sessionstore/src/nsSessionStore.js +++ b/browser/components/sessionstore/src/nsSessionStore.js @@ -2981,8 +2981,9 @@ SessionStoreService.prototype = { restoreHistory: function sss_restoreHistory(aWindow, aTabs, aTabData, aIdMap, aDocIdentMap) { var _this = this; - while (aTabs.length > 0 && (!aTabs[0].linkedBrowser.__SS_tabStillLoading || !aTabs[0].parentNode)) { - aTabs.shift(); // this tab got removed before being completely restored + // if the tab got removed before being completely restored, then skip it + while (aTabs.length > 0 && !(this._canRestoreTabHistory(aTabs[0]))) { + aTabs.shift(); aTabData.shift(); } if (aTabs.length == 0) { @@ -3996,6 +3997,20 @@ SessionStoreService.prototype = { !aTabState.userTypedValue); }, + /** + * Determine if we can restore history into this tab. + * This will be false when a tab has been removed (usually between + * restoreHistoryPrecursor && restoreHistory) or if the tab is still marked + * as loading. + * + * @param aTab + * @returns boolean + */ + _canRestoreTabHistory: function sss__canRestoreTabHistory(aTab) { + return aTab.parentNode && aTab.linkedBrowser && + aTab.linkedBrowser.__SS_tabStillLoading; + }, + /** * This is going to take a state as provided at startup (via * nsISessionStartup.state) and split it into 2 parts. The first part