fix: Fixed pinned tabs wrongly restoring on macos, making it crash, b=closes #11416, c=no-component

This commit is contained in:
mr. m
2025-11-29 00:37:43 +01:00
parent 706505cc50
commit d4f1916382

View File

@@ -1,5 +1,5 @@
diff --git a/browser/components/sessionstore/SessionStore.sys.mjs b/browser/components/sessionstore/SessionStore.sys.mjs
index 1cdbc0f41bf5b55dfbbd850cb618c6d870f7a261..4eac2fed26d779908107ef60f1c2bd0eeba2381c 100644
index 1cdbc0f41bf5b55dfbbd850cb618c6d870f7a261..7a46b3b9819d2abe5801a99984788a3ccf6f32bb 100644
--- a/browser/components/sessionstore/SessionStore.sys.mjs
+++ b/browser/components/sessionstore/SessionStore.sys.mjs
@@ -127,6 +127,8 @@ const TAB_EVENTS = [
@@ -20,15 +20,7 @@ index 1cdbc0f41bf5b55dfbbd850cb618c6d870f7a261..4eac2fed26d779908107ef60f1c2bd0e
this.saveStateDelayed(win);
break;
case "TabGroupCreate":
@@ -2151,7 +2155,6 @@ var SessionStoreInternal = {
if (closedWindowState) {
let newWindowState;
if (
- AppConstants.platform == "macosx" ||
!lazy.SessionStartup.willRestore()
) {
// We want to split the window up into pinned tabs and unpinned tabs.
@@ -2384,11 +2387,9 @@ var SessionStoreInternal = {
@@ -2384,11 +2388,9 @@ var SessionStoreInternal = {
tabbrowser.selectedTab.label;
}
@@ -40,7 +32,7 @@ index 1cdbc0f41bf5b55dfbbd850cb618c6d870f7a261..4eac2fed26d779908107ef60f1c2bd0e
// Store the window's close date to figure out when each individual tab
// was closed. This timestamp should allow re-arranging data based on how
@@ -3373,7 +3374,7 @@ var SessionStoreInternal = {
@@ -3373,7 +3375,7 @@ var SessionStoreInternal = {
if (!isPrivateWindow && tabState.isPrivate) {
return;
}
@@ -49,7 +41,7 @@ index 1cdbc0f41bf5b55dfbbd850cb618c6d870f7a261..4eac2fed26d779908107ef60f1c2bd0e
return;
}
@@ -4089,6 +4090,12 @@ var SessionStoreInternal = {
@@ -4089,6 +4091,12 @@ var SessionStoreInternal = {
Math.min(tabState.index, tabState.entries.length)
);
tabState.pinned = false;
@@ -62,7 +54,7 @@ index 1cdbc0f41bf5b55dfbbd850cb618c6d870f7a261..4eac2fed26d779908107ef60f1c2bd0e
if (inBackground === false) {
aWindow.gBrowser.selectedTab = newTab;
@@ -4525,6 +4532,7 @@ var SessionStoreInternal = {
@@ -4525,6 +4533,7 @@ var SessionStoreInternal = {
// Append the tab if we're opening into a different window,
tabIndex: aSource == aTargetWindow ? pos : Infinity,
pinned: state.pinned,
@@ -70,7 +62,7 @@ index 1cdbc0f41bf5b55dfbbd850cb618c6d870f7a261..4eac2fed26d779908107ef60f1c2bd0e
userContextId: state.userContextId,
skipLoad: true,
preferredRemoteType,
@@ -5374,7 +5382,7 @@ var SessionStoreInternal = {
@@ -5374,7 +5383,7 @@ var SessionStoreInternal = {
for (let i = tabbrowser.pinnedTabCount; i < tabbrowser.tabs.length; i++) {
let tab = tabbrowser.tabs[i];
@@ -79,7 +71,7 @@ index 1cdbc0f41bf5b55dfbbd850cb618c6d870f7a261..4eac2fed26d779908107ef60f1c2bd0e
removableTabs.push(tab);
}
}
@@ -5434,7 +5442,7 @@ var SessionStoreInternal = {
@@ -5434,7 +5443,7 @@ var SessionStoreInternal = {
}
let workspaceID = aWindow.getWorkspaceID();
@@ -88,7 +80,7 @@ index 1cdbc0f41bf5b55dfbbd850cb618c6d870f7a261..4eac2fed26d779908107ef60f1c2bd0e
winData.workspaceID = workspaceID;
}
},
@@ -5625,11 +5633,12 @@ var SessionStoreInternal = {
@@ -5625,11 +5634,12 @@ var SessionStoreInternal = {
}
let tabbrowser = aWindow.gBrowser;
@@ -102,7 +94,7 @@ index 1cdbc0f41bf5b55dfbbd850cb618c6d870f7a261..4eac2fed26d779908107ef60f1c2bd0e
// update the internal state data for this window
for (let tab of tabs) {
if (tab == aWindow.FirefoxViewHandler.tab) {
@@ -5640,6 +5649,7 @@ var SessionStoreInternal = {
@@ -5640,6 +5650,7 @@ var SessionStoreInternal = {
tabsData.push(tabData);
}
@@ -110,7 +102,7 @@ index 1cdbc0f41bf5b55dfbbd850cb618c6d870f7a261..4eac2fed26d779908107ef60f1c2bd0e
// update tab group state for this window
winData.groups = [];
for (let tabGroup of aWindow.gBrowser.tabGroups) {
@@ -5652,7 +5662,7 @@ var SessionStoreInternal = {
@@ -5652,7 +5663,7 @@ var SessionStoreInternal = {
// a window is closed, point to the first item in the tab strip instead (it will never be the Firefox View tab,
// since it's only inserted into the tab strip after it's selected).
if (aWindow.FirefoxViewHandler.tab?.selected) {
@@ -119,7 +111,7 @@ index 1cdbc0f41bf5b55dfbbd850cb618c6d870f7a261..4eac2fed26d779908107ef60f1c2bd0e
winData.title = tabbrowser.tabs[0].label;
}
winData.selected = selectedIndex;
@@ -5764,8 +5774,8 @@ var SessionStoreInternal = {
@@ -5764,8 +5775,8 @@ var SessionStoreInternal = {
// selectTab represents.
let selectTab = 0;
if (overwriteTabs) {
@@ -130,7 +122,7 @@ index 1cdbc0f41bf5b55dfbbd850cb618c6d870f7a261..4eac2fed26d779908107ef60f1c2bd0e
selectTab = Math.min(selectTab, winData.tabs.length);
}
@@ -5808,6 +5818,8 @@ var SessionStoreInternal = {
@@ -5808,6 +5819,8 @@ var SessionStoreInternal = {
winData.tabs,
winData.groups ?? []
);
@@ -139,7 +131,7 @@ index 1cdbc0f41bf5b55dfbbd850cb618c6d870f7a261..4eac2fed26d779908107ef60f1c2bd0e
this._log.debug(
`restoreWindow, createTabsForSessionRestore returned ${tabs.length} tabs`
);
@@ -6371,6 +6383,25 @@ var SessionStoreInternal = {
@@ -6371,6 +6384,25 @@ var SessionStoreInternal = {
// Most of tabData has been restored, now continue with restoring
// attributes that may trigger external events.
@@ -165,7 +157,7 @@ index 1cdbc0f41bf5b55dfbbd850cb618c6d870f7a261..4eac2fed26d779908107ef60f1c2bd0e
if (tabData.pinned) {
tabbrowser.pinTab(tab);
@@ -7289,7 +7320,7 @@ var SessionStoreInternal = {
@@ -7289,7 +7321,7 @@ var SessionStoreInternal = {
let groupsToSave = new Map();
for (let tIndex = 0; tIndex < window.tabs.length; ) {
@@ -174,3 +166,12 @@ index 1cdbc0f41bf5b55dfbbd850cb618c6d870f7a261..4eac2fed26d779908107ef60f1c2bd0e
// Adjust window.selected
if (tIndex + 1 < window.selected) {
window.selected -= 1;
@@ -7304,7 +7336,7 @@ var SessionStoreInternal = {
);
// We don't want to increment tIndex here.
continue;
- } else if (window.tabs[tIndex].groupId) {
+ } else if (window.tabs[tIndex].groupId && false) {
// Convert any open groups into saved groups.
let groupStateToSave = window.groups.find(
groupState => groupState.id == window.tabs[tIndex].groupId