Bug 1865154 - Add check for activeIndex in tabState.entries r=sessionstore-reviewers,sfoster

* Only add previously open tabs to the newWindowState in _prepDataForDeferredRestore
if they have entries

Differential Revision: https://phabricator.services.mozilla.com/D196157
This commit is contained in:
Sarah Clements
2023-12-18 16:55:11 +00:00
parent 5b4510041c
commit 7bc0261e9d

View File

@@ -6532,27 +6532,29 @@ var SessionStoreInternal = {
activeIndex = Math.min(activeIndex, tabState.entries.length - 1);
activeIndex = Math.max(activeIndex, 0);
let title =
tabState.entries[activeIndex].title ||
tabState.entries[activeIndex].url;
if (activeIndex in tabState.entries) {
let title =
tabState.entries[activeIndex].title ||
tabState.entries[activeIndex].url;
let tabData = {
state: tabState,
title,
image: tabState.image,
pos: tIndex,
closedAt: Date.now(),
closedInGroup: false,
removeAfterRestore: true,
};
let tabData = {
state: tabState,
title,
image: tabState.image,
pos: tIndex,
closedAt: Date.now(),
closedInGroup: false,
removeAfterRestore: true,
};
if (this._shouldSaveTabState(tabState)) {
this.saveClosedTabData(
window,
newWindowState._closedTabs,
tabData,
false
);
if (this._shouldSaveTabState(tabState)) {
this.saveClosedTabData(
window,
newWindowState._closedTabs,
tabData,
false
);
}
}
}
tIndex++;