Skip to content

Commit c41e2a0

Browse files
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
1 parent a249c3e commit c41e2a0

File tree

1 file changed

+22
-20
lines changed

1 file changed

+22
-20
lines changed

browser/components/sessionstore/SessionStore.sys.mjs

Lines changed: 22 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -6532,27 +6532,29 @@ var SessionStoreInternal = {
65326532
activeIndex = Math.min(activeIndex, tabState.entries.length - 1);
65336533
activeIndex = Math.max(activeIndex, 0);
65346534

6535-
let title =
6536-
tabState.entries[activeIndex].title ||
6537-
tabState.entries[activeIndex].url;
6538-
6539-
let tabData = {
6540-
state: tabState,
6541-
title,
6542-
image: tabState.image,
6543-
pos: tIndex,
6544-
closedAt: Date.now(),
6545-
closedInGroup: false,
6546-
removeAfterRestore: true,
6547-
};
6535+
if (activeIndex in tabState.entries) {
6536+
let title =
6537+
tabState.entries[activeIndex].title ||
6538+
tabState.entries[activeIndex].url;
65486539

6549-
if (this._shouldSaveTabState(tabState)) {
6550-
this.saveClosedTabData(
6551-
window,
6552-
newWindowState._closedTabs,
6553-
tabData,
6554-
false
6555-
);
6540+
let tabData = {
6541+
state: tabState,
6542+
title,
6543+
image: tabState.image,
6544+
pos: tIndex,
6545+
closedAt: Date.now(),
6546+
closedInGroup: false,
6547+
removeAfterRestore: true,
6548+
};
6549+
6550+
if (this._shouldSaveTabState(tabState)) {
6551+
this.saveClosedTabData(
6552+
window,
6553+
newWindowState._closedTabs,
6554+
tabData,
6555+
false
6556+
);
6557+
}
65566558
}
65576559
}
65586560
tIndex++;

0 commit comments

Comments
 (0)