fix: Add a flag to change labels when restoring, b=bug #12152, c=no-component

This commit is contained in:
mr. m
2026-02-12 20:19:02 +01:00
parent 66081e97f6
commit 2eb09f092c
3 changed files with 40 additions and 17 deletions

View File

@@ -1,5 +1,5 @@
diff --git a/browser/components/sessionstore/SessionStore.sys.mjs b/browser/components/sessionstore/SessionStore.sys.mjs
index 2a055f0c5f34f0a2667f659185120c07d38f4e41..f52b8ddecf31e258ca33bbaf3483951d2b804210 100644
index 2a055f0c5f34f0a2667f659185120c07d38f4e41..53465df6060e6765e1e4564d340bba5fbefff5ce 100644
--- a/browser/components/sessionstore/SessionStore.sys.mjs
+++ b/browser/components/sessionstore/SessionStore.sys.mjs
@@ -127,6 +127,9 @@ const TAB_EVENTS = [
@@ -201,7 +201,19 @@ index 2a055f0c5f34f0a2667f659185120c07d38f4e41..f52b8ddecf31e258ca33bbaf3483951d
userContextId: state.userContextId,
skipLoad: true,
preferredRemoteType,
@@ -5414,7 +5443,7 @@ var SessionStoreInternal = {
@@ -5055,9 +5084,10 @@ var SessionStoreInternal = {
if (activePageData.title && activePageData.title != activePageData.url) {
win.gBrowser.setInitialTabTitle(tab, activePageData.title, {
isContentTitle: true,
+ _zenChangeLabelFlag: true,
});
} else {
- win.gBrowser.setInitialTabTitle(tab, activePageData.url);
+ win.gBrowser.setInitialTabTitle(tab, activePageData.url, { _zenChangeLabelFlag: true });
}
}
@@ -5414,7 +5444,7 @@ var SessionStoreInternal = {
for (let i = tabbrowser.pinnedTabCount; i < tabbrowser.tabs.length; i++) {
let tab = tabbrowser.tabs[i];
@@ -210,7 +222,7 @@ index 2a055f0c5f34f0a2667f659185120c07d38f4e41..f52b8ddecf31e258ca33bbaf3483951d
removableTabs.push(tab);
}
}
@@ -5525,7 +5554,7 @@ var SessionStoreInternal = {
@@ -5525,7 +5555,7 @@ var SessionStoreInternal = {
// collect the data for all windows
for (ix in this._windows) {
@@ -219,7 +231,7 @@ index 2a055f0c5f34f0a2667f659185120c07d38f4e41..f52b8ddecf31e258ca33bbaf3483951d
// window data is still in _statesToRestore
continue;
}
@@ -5668,11 +5697,12 @@ var SessionStoreInternal = {
@@ -5668,11 +5698,12 @@ var SessionStoreInternal = {
}
let tabbrowser = aWindow.gBrowser;
@@ -233,7 +245,7 @@ index 2a055f0c5f34f0a2667f659185120c07d38f4e41..f52b8ddecf31e258ca33bbaf3483951d
// update the internal state data for this window
for (let tab of tabs) {
if (tab == aWindow.FirefoxViewHandler.tab) {
@@ -5683,6 +5713,9 @@ var SessionStoreInternal = {
@@ -5683,6 +5714,9 @@ var SessionStoreInternal = {
tabsData.push(tabData);
}
@@ -243,7 +255,7 @@ index 2a055f0c5f34f0a2667f659185120c07d38f4e41..f52b8ddecf31e258ca33bbaf3483951d
// update tab group state for this window
winData.groups = [];
for (let tabGroup of aWindow.gBrowser.tabGroups) {
@@ -5695,7 +5728,7 @@ var SessionStoreInternal = {
@@ -5695,7 +5729,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) {
@@ -252,7 +264,7 @@ index 2a055f0c5f34f0a2667f659185120c07d38f4e41..f52b8ddecf31e258ca33bbaf3483951d
winData.title = tabbrowser.tabs[0].label;
}
winData.selected = selectedIndex;
@@ -5810,8 +5843,8 @@ var SessionStoreInternal = {
@@ -5810,8 +5844,8 @@ var SessionStoreInternal = {
// selectTab represents.
let selectTab = 0;
if (overwriteTabs) {
@@ -263,7 +275,7 @@ index 2a055f0c5f34f0a2667f659185120c07d38f4e41..f52b8ddecf31e258ca33bbaf3483951d
selectTab = Math.min(selectTab, winData.tabs.length);
}
@@ -5833,6 +5866,7 @@ var SessionStoreInternal = {
@@ -5833,6 +5867,7 @@ var SessionStoreInternal = {
if (overwriteTabs) {
for (let i = tabbrowser.browsers.length - 1; i >= 0; i--) {
if (!tabbrowser.tabs[i].selected) {
@@ -271,7 +283,7 @@ index 2a055f0c5f34f0a2667f659185120c07d38f4e41..f52b8ddecf31e258ca33bbaf3483951d
tabbrowser.removeTab(tabbrowser.tabs[i]);
}
}
@@ -5866,6 +5900,12 @@ var SessionStoreInternal = {
@@ -5866,6 +5901,12 @@ var SessionStoreInternal = {
savedTabGroup => !openTabGroupIdsInWindow.has(savedTabGroup.id)
);
}
@@ -284,7 +296,7 @@ index 2a055f0c5f34f0a2667f659185120c07d38f4e41..f52b8ddecf31e258ca33bbaf3483951d
// Move the originally open tabs to the end.
if (initialTabs) {
@@ -6419,6 +6459,25 @@ var SessionStoreInternal = {
@@ -6419,6 +6460,25 @@ var SessionStoreInternal = {
// Most of tabData has been restored, now continue with restoring
// attributes that may trigger external events.
@@ -310,7 +322,7 @@ index 2a055f0c5f34f0a2667f659185120c07d38f4e41..f52b8ddecf31e258ca33bbaf3483951d
if (tabData.pinned) {
tabbrowser.pinTab(tab);
@@ -6567,6 +6626,9 @@ var SessionStoreInternal = {
@@ -6567,6 +6627,9 @@ var SessionStoreInternal = {
aWindow.gURLBar.readOnly = false;
}
}
@@ -320,7 +332,7 @@ index 2a055f0c5f34f0a2667f659185120c07d38f4e41..f52b8ddecf31e258ca33bbaf3483951d
let promiseParts = Promise.withResolvers();
aWindow.setTimeout(() => {
@@ -7343,7 +7405,7 @@ var SessionStoreInternal = {
@@ -7343,7 +7406,7 @@ var SessionStoreInternal = {
let groupsToSave = new Map();
for (let tIndex = 0; tIndex < window.tabs.length; ) {
@@ -329,7 +341,7 @@ index 2a055f0c5f34f0a2667f659185120c07d38f4e41..f52b8ddecf31e258ca33bbaf3483951d
// Adjust window.selected
if (tIndex + 1 < window.selected) {
window.selected -= 1;
@@ -7358,7 +7420,7 @@ var SessionStoreInternal = {
@@ -7358,7 +7421,7 @@ var SessionStoreInternal = {
);
// We don't want to increment tIndex here.
continue;

View File

@@ -1,5 +1,5 @@
diff --git a/browser/components/tabbrowser/content/tabbrowser.js b/browser/components/tabbrowser/content/tabbrowser.js
index 0eaca7a58e0026237b71b2ad515efe84d9e8c779..c7c7e6dd8cacf5d2d13c48ad9bed8195d677420f 100644
index 0eaca7a58e0026237b71b2ad515efe84d9e8c779..db1c57c8eb4b3d614b5e5aa820871d66b00ec9a4 100644
--- a/browser/components/tabbrowser/content/tabbrowser.js
+++ b/browser/components/tabbrowser/content/tabbrowser.js
@@ -398,6 +398,7 @@
@@ -186,11 +186,13 @@ index 0eaca7a58e0026237b71b2ad515efe84d9e8c779..c7c7e6dd8cacf5d2d13c48ad9bed8195
// If focus is on the old tab, move it to the new tab.
if (activeEl == oldTab) {
newTab.focus();
@@ -1959,6 +2039,11 @@
@@ -1958,7 +2038,12 @@
return this._setTabLabel(aTab, aLabel);
}
_setTabLabel(aTab, aLabel, { beforeTabOpen, isContentTitle, isURL } = {}) {
+ if (!aTab._zenContentsVisible && !aTab._zenChangeLabelFlag && !aTab._labelIsInitialTitle && !gZenWorkspaces.privateWindowOrDisabled) {
- _setTabLabel(aTab, aLabel, { beforeTabOpen, isContentTitle, isURL } = {}) {
+ _setTabLabel(aTab, aLabel, { beforeTabOpen, isContentTitle, isURL, _zenChangeLabelFlag } = {}) {
+ if (!aTab._zenContentsVisible && !aTab._zenChangeLabelFlag && !aTab._labelIsInitialTitle && !gZenWorkspaces.privateWindowOrDisabled && !_zenChangeLabelFlag) {
+ return false;
+ }
+ aLabel = (typeof aTab.zenStaticLabel === "string" && aTab.zenStaticLabel) ? aTab.zenStaticLabel : aLabel;

View File

@@ -30,6 +30,10 @@ XPCOMUtils.defineLazyPreferenceGetter(
3
);
const SHOULD_LOG_TAB_ENTRIES = Services.prefs.getBoolPref(
"zen.session-store.log-tab-entries",
false
);
const SHOULD_BACKUP_FILE = Services.prefs.getBoolPref("zen.session-store.backup-file", true);
const FILE_NAME = "zen-sessions.jsonlz4";
@@ -221,6 +225,11 @@ export class nsZenSessionManager {
this._shouldRunMigration = true;
await this.#getDataFromDBForMigration();
}
if (SHOULD_LOG_TAB_ENTRIES) {
for (const tab of this.#sidebar.tabs || []) {
this.log("Tab entry in session file:", tab);
}
}
}
get #shouldRestoreOnlyPinned() {