feat: Make sure to properly flush all windows when making a new one and fix removing progress listeners, b=no-bug, c=workspaces

This commit is contained in:
Mr. M
2025-12-06 18:49:26 +01:00
parent cde32ca1e0
commit f720dce237
6 changed files with 192 additions and 144 deletions

View File

@@ -1,5 +1,5 @@
diff --git a/browser/components/sessionstore/SessionStore.sys.mjs b/browser/components/sessionstore/SessionStore.sys.mjs
index 2c2f43bf743ef458b378e85e9ed44a971711e1d9..ddeb16347bd279934ad3b8fcd158961ff1220f29 100644
index 2c2f43bf743ef458b378e85e9ed44a971711e1d9..1d06c69e3aebe54aac82ff20b82681812db1ecbb 100644
--- a/browser/components/sessionstore/SessionStore.sys.mjs
+++ b/browser/components/sessionstore/SessionStore.sys.mjs
@@ -127,6 +127,8 @@ const TAB_EVENTS = [
@@ -47,17 +47,23 @@ index 2c2f43bf743ef458b378e85e9ed44a971711e1d9..ddeb16347bd279934ad3b8fcd158961f
!lazy.SessionStartup.willRestore()
) {
// We want to split the window up into pinned tabs and unpinned tabs.
@@ -2215,6 +2223,9 @@ var SessionStoreInternal = {
@@ -2215,6 +2223,15 @@ var SessionStoreInternal = {
});
this._shouldRestoreLastSession = false;
}
+ else if (!aInitialState && isRegularWindow) {
+ lazy.ZenSessionStore.restoreNewWindow(aWindow, this);
+ let windowPromises = [];
+ for (let window of this._browserWindows) {
+ windowPromises.push(lazy.TabStateFlusher.flushWindow(window));
+ }
+ Promise.all(windowPromises).then(() => {
+ lazy.ZenSessionStore.restoreNewWindow(aWindow, this);
+ });
+ }
if (this._restoreLastWindow && aWindow.toolbar.visible) {
// always reset (if not a popup window)
@@ -2384,11 +2395,9 @@ var SessionStoreInternal = {
@@ -2384,11 +2401,9 @@ var SessionStoreInternal = {
tabbrowser.selectedTab.label;
}
@@ -69,7 +75,7 @@ index 2c2f43bf743ef458b378e85e9ed44a971711e1d9..ddeb16347bd279934ad3b8fcd158961f
// 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
@@ -2465,7 +2474,7 @@ var SessionStoreInternal = {
@@ -2465,7 +2480,7 @@ var SessionStoreInternal = {
// 2) Flush the window.
// 3) When the flush is complete, revisit our decision to store the window
// in _closedWindows, and add/remove as necessary.
@@ -78,7 +84,7 @@ index 2c2f43bf743ef458b378e85e9ed44a971711e1d9..ddeb16347bd279934ad3b8fcd158961f
this.maybeSaveClosedWindow(winData, isLastWindow);
}
@@ -2486,7 +2495,7 @@ var SessionStoreInternal = {
@@ -2486,7 +2501,7 @@ var SessionStoreInternal = {
// Save non-private windows if they have at
// least one saveable tab or are the last window.
@@ -87,7 +93,7 @@ index 2c2f43bf743ef458b378e85e9ed44a971711e1d9..ddeb16347bd279934ad3b8fcd158961f
this.maybeSaveClosedWindow(winData, isLastWindow);
if (!isLastWindow && winData.closedId > -1) {
@@ -3373,7 +3382,7 @@ var SessionStoreInternal = {
@@ -3373,7 +3388,7 @@ var SessionStoreInternal = {
if (!isPrivateWindow && tabState.isPrivate) {
return;
}
@@ -96,7 +102,7 @@ index 2c2f43bf743ef458b378e85e9ed44a971711e1d9..ddeb16347bd279934ad3b8fcd158961f
return;
}
@@ -4089,6 +4098,12 @@ var SessionStoreInternal = {
@@ -4089,6 +4104,12 @@ var SessionStoreInternal = {
Math.min(tabState.index, tabState.entries.length)
);
tabState.pinned = false;
@@ -109,7 +115,7 @@ index 2c2f43bf743ef458b378e85e9ed44a971711e1d9..ddeb16347bd279934ad3b8fcd158961f
if (inBackground === false) {
aWindow.gBrowser.selectedTab = newTab;
@@ -4525,6 +4540,7 @@ var SessionStoreInternal = {
@@ -4525,6 +4546,7 @@ var SessionStoreInternal = {
// Append the tab if we're opening into a different window,
tabIndex: aSource == aTargetWindow ? pos : Infinity,
pinned: state.pinned,
@@ -117,7 +123,7 @@ index 2c2f43bf743ef458b378e85e9ed44a971711e1d9..ddeb16347bd279934ad3b8fcd158961f
userContextId: state.userContextId,
skipLoad: true,
preferredRemoteType,
@@ -5374,7 +5390,7 @@ var SessionStoreInternal = {
@@ -5374,7 +5396,7 @@ var SessionStoreInternal = {
for (let i = tabbrowser.pinnedTabCount; i < tabbrowser.tabs.length; i++) {
let tab = tabbrowser.tabs[i];
@@ -126,7 +132,7 @@ index 2c2f43bf743ef458b378e85e9ed44a971711e1d9..ddeb16347bd279934ad3b8fcd158961f
removableTabs.push(tab);
}
}
@@ -5434,7 +5450,7 @@ var SessionStoreInternal = {
@@ -5434,7 +5456,7 @@ var SessionStoreInternal = {
}
let workspaceID = aWindow.getWorkspaceID();
@@ -135,7 +141,7 @@ index 2c2f43bf743ef458b378e85e9ed44a971711e1d9..ddeb16347bd279934ad3b8fcd158961f
winData.workspaceID = workspaceID;
}
},
@@ -5483,7 +5499,7 @@ var SessionStoreInternal = {
@@ -5483,7 +5505,7 @@ var SessionStoreInternal = {
// collect the data for all windows
for (ix in this._windows) {
@@ -144,7 +150,7 @@ index 2c2f43bf743ef458b378e85e9ed44a971711e1d9..ddeb16347bd279934ad3b8fcd158961f
// window data is still in _statesToRestore
continue;
}
@@ -5625,11 +5641,12 @@ var SessionStoreInternal = {
@@ -5625,11 +5647,12 @@ var SessionStoreInternal = {
}
let tabbrowser = aWindow.gBrowser;
@@ -158,7 +164,7 @@ index 2c2f43bf743ef458b378e85e9ed44a971711e1d9..ddeb16347bd279934ad3b8fcd158961f
// update the internal state data for this window
for (let tab of tabs) {
if (tab == aWindow.FirefoxViewHandler.tab) {
@@ -5640,6 +5657,7 @@ var SessionStoreInternal = {
@@ -5640,6 +5663,7 @@ var SessionStoreInternal = {
tabsData.push(tabData);
}
@@ -166,7 +172,7 @@ index 2c2f43bf743ef458b378e85e9ed44a971711e1d9..ddeb16347bd279934ad3b8fcd158961f
// update tab group state for this window
winData.groups = [];
for (let tabGroup of aWindow.gBrowser.tabGroups) {
@@ -5652,7 +5670,7 @@ var SessionStoreInternal = {
@@ -5652,7 +5676,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) {
@@ -175,7 +181,7 @@ index 2c2f43bf743ef458b378e85e9ed44a971711e1d9..ddeb16347bd279934ad3b8fcd158961f
winData.title = tabbrowser.tabs[0].label;
}
winData.selected = selectedIndex;
@@ -5765,8 +5783,8 @@ var SessionStoreInternal = {
@@ -5765,8 +5789,8 @@ var SessionStoreInternal = {
// selectTab represents.
let selectTab = 0;
if (overwriteTabs) {
@@ -186,7 +192,7 @@ index 2c2f43bf743ef458b378e85e9ed44a971711e1d9..ddeb16347bd279934ad3b8fcd158961f
selectTab = Math.min(selectTab, winData.tabs.length);
}
@@ -5809,6 +5827,8 @@ var SessionStoreInternal = {
@@ -5809,6 +5833,8 @@ var SessionStoreInternal = {
winData.tabs,
winData.groups ?? []
);
@@ -195,7 +201,7 @@ index 2c2f43bf743ef458b378e85e9ed44a971711e1d9..ddeb16347bd279934ad3b8fcd158961f
this._log.debug(
`restoreWindow, createTabsForSessionRestore returned ${tabs.length} tabs`
);
@@ -6372,6 +6392,25 @@ var SessionStoreInternal = {
@@ -6372,6 +6398,25 @@ var SessionStoreInternal = {
// Most of tabData has been restored, now continue with restoring
// attributes that may trigger external events.
@@ -221,7 +227,7 @@ index 2c2f43bf743ef458b378e85e9ed44a971711e1d9..ddeb16347bd279934ad3b8fcd158961f
if (tabData.pinned) {
tabbrowser.pinTab(tab);
@@ -7290,7 +7329,7 @@ var SessionStoreInternal = {
@@ -7290,7 +7335,7 @@ var SessionStoreInternal = {
let groupsToSave = new Map();
for (let tIndex = 0; tIndex < window.tabs.length; ) {
@@ -230,7 +236,7 @@ index 2c2f43bf743ef458b378e85e9ed44a971711e1d9..ddeb16347bd279934ad3b8fcd158961f
// Adjust window.selected
if (tIndex + 1 < window.selected) {
window.selected -= 1;
@@ -7305,7 +7344,7 @@ var SessionStoreInternal = {
@@ -7305,7 +7350,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 42027bfa55eab8ea9298a7d425f2ded45188f7f3..91bd99772d2ef1eb6cb896b445369e1d706c5590 100644
index 42027bfa55eab8ea9298a7d425f2ded45188f7f3..86358619b637442eb21c7262b0d1436c7385d4a3 100644
--- a/browser/components/tabbrowser/content/tabbrowser.js
+++ b/browser/components/tabbrowser/content/tabbrowser.js
@@ -386,6 +386,7 @@
@@ -10,7 +10,7 @@ index 42027bfa55eab8ea9298a7d425f2ded45188f7f3..91bd99772d2ef1eb6cb896b445369e1d
const browsers = [];
if (this.#activeSplitView) {
for (const tab of this.#activeSplitView.tabs) {
@@ -450,15 +451,64 @@
@@ -450,15 +451,66 @@
return this.tabContainer.visibleTabs;
}
@@ -18,6 +18,8 @@ index 42027bfa55eab8ea9298a7d425f2ded45188f7f3..91bd99772d2ef1eb6cb896b445369e1d
+ return this.#handleTabMove(...args);
+ }
+
+ get zenTabProgressListener() { return TabProgressListener; }
+
+ get _numVisiblePinTabsWithoutCollapsed() {
+ let i = 0;
+ for (let item of this.tabContainer.ariaFocusableItems) {
@@ -77,7 +79,7 @@ index 42027bfa55eab8ea9298a7d425f2ded45188f7f3..91bd99772d2ef1eb6cb896b445369e1d
set selectedTab(val) {
if (
gSharedTabWarning.willShowSharedTabWarning(val) ||
@@ -613,6 +663,7 @@
@@ -613,6 +665,7 @@
this.tabpanels.appendChild(panel);
let tab = this.tabs[0];
@@ -85,7 +87,7 @@ index 42027bfa55eab8ea9298a7d425f2ded45188f7f3..91bd99772d2ef1eb6cb896b445369e1d
tab.linkedPanel = uniqueId;
this._selectedTab = tab;
this._selectedBrowser = browser;
@@ -898,13 +949,17 @@
@@ -898,13 +951,17 @@
}
this.showTab(aTab);
@@ -104,7 +106,7 @@ index 42027bfa55eab8ea9298a7d425f2ded45188f7f3..91bd99772d2ef1eb6cb896b445369e1d
aTab.setAttribute("pinned", "true");
this._updateTabBarForPinnedTabs();
@@ -917,11 +972,15 @@
@@ -917,11 +974,15 @@
}
this.#handleTabMove(aTab, () => {
@@ -121,7 +123,7 @@ index 42027bfa55eab8ea9298a7d425f2ded45188f7f3..91bd99772d2ef1eb6cb896b445369e1d
});
aTab.style.marginInlineStart = "";
@@ -1098,6 +1157,8 @@
@@ -1098,6 +1159,8 @@
let LOCAL_PROTOCOLS = ["chrome:", "about:", "resource:", "data:"];
@@ -130,7 +132,7 @@ index 42027bfa55eab8ea9298a7d425f2ded45188f7f3..91bd99772d2ef1eb6cb896b445369e1d
if (
aIconURL &&
!LOCAL_PROTOCOLS.some(protocol => aIconURL.startsWith(protocol))
@@ -1107,6 +1168,9 @@
@@ -1107,6 +1170,9 @@
);
return;
}
@@ -140,7 +142,7 @@ index 42027bfa55eab8ea9298a7d425f2ded45188f7f3..91bd99772d2ef1eb6cb896b445369e1d
let browser = this.getBrowserForTab(aTab);
browser.mIconURL = aIconURL;
@@ -1379,7 +1443,6 @@
@@ -1379,7 +1445,6 @@
// Preview mode should not reset the owner
if (!this._previewMode && !oldTab.selected) {
@@ -148,7 +150,7 @@ index 42027bfa55eab8ea9298a7d425f2ded45188f7f3..91bd99772d2ef1eb6cb896b445369e1d
}
let lastRelatedTab = this._lastRelatedTabMap.get(oldTab);
@@ -1470,6 +1533,7 @@
@@ -1470,6 +1535,7 @@
if (!this._previewMode) {
newTab.recordTimeFromUnloadToReload();
newTab.updateLastAccessed();
@@ -156,7 +158,7 @@ index 42027bfa55eab8ea9298a7d425f2ded45188f7f3..91bd99772d2ef1eb6cb896b445369e1d
oldTab.updateLastAccessed();
// if this is the foreground window, update the last-seen timestamps.
if (this.ownerGlobal == BrowserWindowTracker.getTopWindow()) {
@@ -1622,6 +1686,9 @@
@@ -1622,6 +1688,9 @@
}
let activeEl = document.activeElement;
@@ -166,7 +168,7 @@ index 42027bfa55eab8ea9298a7d425f2ded45188f7f3..91bd99772d2ef1eb6cb896b445369e1d
// If focus is on the old tab, move it to the new tab.
if (activeEl == oldTab) {
newTab.focus();
@@ -1945,7 +2012,8 @@
@@ -1945,7 +2014,8 @@
}
_setTabLabel(aTab, aLabel, { beforeTabOpen, isContentTitle, isURL } = {}) {
@@ -176,7 +178,7 @@ index 42027bfa55eab8ea9298a7d425f2ded45188f7f3..91bd99772d2ef1eb6cb896b445369e1d
return false;
}
@@ -2053,7 +2121,7 @@
@@ -2053,7 +2123,7 @@
newIndex = this.selectedTab._tPos + 1;
}
@@ -185,7 +187,7 @@ index 42027bfa55eab8ea9298a7d425f2ded45188f7f3..91bd99772d2ef1eb6cb896b445369e1d
if (this.isTabGroupLabel(targetTab)) {
throw new Error(
"Replacing a tab group label with a tab is not supported"
@@ -2328,6 +2396,7 @@
@@ -2328,6 +2398,7 @@
uriIsAboutBlank,
userContextId,
skipLoad,
@@ -193,7 +195,7 @@ index 42027bfa55eab8ea9298a7d425f2ded45188f7f3..91bd99772d2ef1eb6cb896b445369e1d
} = {}) {
let b = document.createXULElement("browser");
// Use the JSM global to create the permanentKey, so that if the
@@ -2401,8 +2470,7 @@
@@ -2401,8 +2472,7 @@
// we use a different attribute name for this?
b.setAttribute("name", name);
}
@@ -203,7 +205,7 @@ index 42027bfa55eab8ea9298a7d425f2ded45188f7f3..91bd99772d2ef1eb6cb896b445369e1d
b.setAttribute("transparent", "true");
}
@@ -2567,7 +2635,7 @@
@@ -2567,7 +2637,7 @@
let panel = this.getPanel(browser);
let uniqueId = this._generateUniquePanelID();
@@ -212,7 +214,7 @@ index 42027bfa55eab8ea9298a7d425f2ded45188f7f3..91bd99772d2ef1eb6cb896b445369e1d
aTab.linkedPanel = uniqueId;
// Inject the <browser> into the DOM if necessary.
@@ -2626,8 +2694,8 @@
@@ -2626,8 +2696,8 @@
// If we transitioned from one browser to two browsers, we need to set
// hasSiblings=false on both the existing browser and the new browser.
if (this.tabs.length == 2) {
@@ -223,7 +225,7 @@ index 42027bfa55eab8ea9298a7d425f2ded45188f7f3..91bd99772d2ef1eb6cb896b445369e1d
} else {
aTab.linkedBrowser.browsingContext.hasSiblings = this.tabs.length > 1;
}
@@ -2814,7 +2882,6 @@
@@ -2814,7 +2884,6 @@
this.selectedTab = this.addTrustedTab(BROWSER_NEW_TAB_URL, {
tabIndex: tab._tPos + 1,
userContextId: tab.userContextId,
@@ -231,7 +233,7 @@ index 42027bfa55eab8ea9298a7d425f2ded45188f7f3..91bd99772d2ef1eb6cb896b445369e1d
focusUrlBar: true,
});
resolve(this.selectedBrowser);
@@ -2923,6 +2990,9 @@
@@ -2923,6 +2992,9 @@
schemelessInput,
hasValidUserGestureActivation = false,
textDirectiveUserActivation = false,
@@ -241,7 +243,7 @@ index 42027bfa55eab8ea9298a7d425f2ded45188f7f3..91bd99772d2ef1eb6cb896b445369e1d
} = {}
) {
// all callers of addTab that pass a params object need to pass
@@ -2933,10 +3003,17 @@
@@ -2933,10 +3005,17 @@
);
}
@@ -259,7 +261,7 @@ index 42027bfa55eab8ea9298a7d425f2ded45188f7f3..91bd99772d2ef1eb6cb896b445369e1d
// If we're opening a foreground tab, set the owner by default.
ownerTab ??= inBackground ? null : this.selectedTab;
@@ -2944,6 +3021,7 @@
@@ -2944,6 +3023,7 @@
if (this.selectedTab.owner) {
this.selectedTab.owner = null;
}
@@ -267,7 +269,7 @@ index 42027bfa55eab8ea9298a7d425f2ded45188f7f3..91bd99772d2ef1eb6cb896b445369e1d
// Find the tab that opened this one, if any. This is used for
// determining positioning, and inherited attributes such as the
@@ -2996,6 +3074,21 @@
@@ -2996,6 +3076,21 @@
noInitialLabel,
skipBackgroundNotify,
});
@@ -289,7 +291,7 @@ index 42027bfa55eab8ea9298a7d425f2ded45188f7f3..91bd99772d2ef1eb6cb896b445369e1d
if (insertTab) {
// Insert the tab into the tab container in the correct position.
this.#insertTabAtIndex(t, {
@@ -3004,6 +3097,7 @@
@@ -3004,6 +3099,7 @@
ownerTab,
openerTab,
pinned,
@@ -297,7 +299,7 @@ index 42027bfa55eab8ea9298a7d425f2ded45188f7f3..91bd99772d2ef1eb6cb896b445369e1d
bulkOrderedOpen,
tabGroup: tabGroup ?? openerTab?.group,
});
@@ -3022,6 +3116,7 @@
@@ -3022,6 +3118,7 @@
openWindowInfo,
skipLoad,
triggeringRemoteType,
@@ -305,7 +307,7 @@ index 42027bfa55eab8ea9298a7d425f2ded45188f7f3..91bd99772d2ef1eb6cb896b445369e1d
}));
if (focusUrlBar) {
@@ -3146,6 +3241,12 @@
@@ -3146,6 +3243,12 @@
}
}
@@ -318,7 +320,7 @@ index 42027bfa55eab8ea9298a7d425f2ded45188f7f3..91bd99772d2ef1eb6cb896b445369e1d
// Additionally send pinned tab events
if (pinned) {
this.#notifyPinnedStatus(t);
@@ -3349,10 +3450,10 @@
@@ -3349,10 +3452,10 @@
isAdoptingGroup = false,
isUserTriggered = false,
telemetryUserCreateSource = "unknown",
@@ -330,7 +332,7 @@ index 42027bfa55eab8ea9298a7d425f2ded45188f7f3..91bd99772d2ef1eb6cb896b445369e1d
}
if (!color) {
@@ -3373,9 +3474,14 @@
@@ -3373,9 +3476,14 @@
label,
isAdoptingGroup
);
@@ -347,7 +349,7 @@ index 42027bfa55eab8ea9298a7d425f2ded45188f7f3..91bd99772d2ef1eb6cb896b445369e1d
);
group.addTabs(tabs);
@@ -3496,7 +3602,7 @@
@@ -3496,7 +3604,7 @@
}
this.#handleTabMove(tab, () =>
@@ -356,7 +358,7 @@ index 42027bfa55eab8ea9298a7d425f2ded45188f7f3..91bd99772d2ef1eb6cb896b445369e1d
);
}
@@ -3698,6 +3804,7 @@
@@ -3698,6 +3806,7 @@
openWindowInfo,
skipLoad,
triggeringRemoteType,
@@ -364,7 +366,7 @@ index 42027bfa55eab8ea9298a7d425f2ded45188f7f3..91bd99772d2ef1eb6cb896b445369e1d
}
) {
// If we don't have a preferred remote type (or it is `NOT_REMOTE`), and
@@ -3767,6 +3874,7 @@
@@ -3767,6 +3876,7 @@
openWindowInfo,
name,
skipLoad,
@@ -372,7 +374,7 @@ index 42027bfa55eab8ea9298a7d425f2ded45188f7f3..91bd99772d2ef1eb6cb896b445369e1d
});
}
@@ -3955,7 +4063,7 @@
@@ -3955,7 +4065,7 @@
// Add a new tab if needed.
if (!tab) {
let createLazyBrowser =
@@ -381,7 +383,7 @@ index 42027bfa55eab8ea9298a7d425f2ded45188f7f3..91bd99772d2ef1eb6cb896b445369e1d
let url = "about:blank";
if (tabData.entries?.length) {
@@ -3992,8 +4100,10 @@
@@ -3992,8 +4102,10 @@
insertTab: false,
skipLoad: true,
preferredRemoteType,
@@ -393,7 +395,7 @@ index 42027bfa55eab8ea9298a7d425f2ded45188f7f3..91bd99772d2ef1eb6cb896b445369e1d
if (select) {
tabToSelect = tab;
}
@@ -4005,7 +4115,8 @@
@@ -4005,7 +4117,8 @@
this.pinTab(tab);
// Then ensure all the tab open/pinning information is sent.
this._fireTabOpen(tab, {});
@@ -403,7 +405,7 @@ index 42027bfa55eab8ea9298a7d425f2ded45188f7f3..91bd99772d2ef1eb6cb896b445369e1d
let { groupId } = tabData;
const tabGroup = tabGroupWorkingData.get(groupId);
// if a tab refers to a tab group we don't know, skip any group
@@ -4019,7 +4130,10 @@
@@ -4019,7 +4132,10 @@
tabGroup.stateData.id,
tabGroup.stateData.color,
tabGroup.stateData.collapsed,
@@ -415,7 +417,7 @@ index 42027bfa55eab8ea9298a7d425f2ded45188f7f3..91bd99772d2ef1eb6cb896b445369e1d
);
tabsFragment.appendChild(tabGroup.node);
}
@@ -4064,9 +4178,23 @@
@@ -4064,9 +4180,23 @@
// to remove the old selected tab.
if (tabToSelect) {
let leftoverTab = this.selectedTab;
@@ -439,7 +441,7 @@ index 42027bfa55eab8ea9298a7d425f2ded45188f7f3..91bd99772d2ef1eb6cb896b445369e1d
if (tabs.length > 1 || !tabs[0].selected) {
this._updateTabsAfterInsert();
@@ -4257,11 +4385,14 @@
@@ -4257,11 +4387,14 @@
if (ownerTab) {
tab.owner = ownerTab;
}
@@ -455,7 +457,7 @@ index 42027bfa55eab8ea9298a7d425f2ded45188f7f3..91bd99772d2ef1eb6cb896b445369e1d
if (
!bulkOrderedOpen &&
((openerTab &&
@@ -4273,7 +4404,7 @@
@@ -4273,7 +4406,7 @@
let lastRelatedTab =
openerTab && this._lastRelatedTabMap.get(openerTab);
let previousTab = lastRelatedTab || openerTab || this.selectedTab;
@@ -464,7 +466,7 @@ index 42027bfa55eab8ea9298a7d425f2ded45188f7f3..91bd99772d2ef1eb6cb896b445369e1d
tabGroup = previousTab.group;
}
if (
@@ -4284,7 +4415,7 @@
@@ -4284,7 +4417,7 @@
) {
elementIndex = Infinity;
} else if (previousTab.visible) {
@@ -473,7 +475,7 @@ index 42027bfa55eab8ea9298a7d425f2ded45188f7f3..91bd99772d2ef1eb6cb896b445369e1d
} else if (previousTab == FirefoxViewHandler.tab) {
elementIndex = 0;
}
@@ -4312,14 +4443,14 @@
@@ -4312,14 +4445,14 @@
}
// Ensure index is within bounds.
if (tab.pinned) {
@@ -492,7 +494,7 @@ index 42027bfa55eab8ea9298a7d425f2ded45188f7f3..91bd99772d2ef1eb6cb896b445369e1d
if (pinned && !itemAfter?.pinned) {
itemAfter = null;
@@ -4330,7 +4461,7 @@
@@ -4330,7 +4463,7 @@
this.tabContainer._invalidateCachedTabs();
@@ -501,7 +503,7 @@ index 42027bfa55eab8ea9298a7d425f2ded45188f7f3..91bd99772d2ef1eb6cb896b445369e1d
if (this.isTab(itemAfter) && itemAfter.group == tabGroup) {
// Place at the front of, or between tabs in, the same tab group
this.tabContainer.insertBefore(tab, itemAfter);
@@ -4358,7 +4489,11 @@
@@ -4358,7 +4491,11 @@
const tabContainer = pinned
? this.tabContainer.pinnedTabsContainer
: this.tabContainer;
@@ -513,7 +515,7 @@ index 42027bfa55eab8ea9298a7d425f2ded45188f7f3..91bd99772d2ef1eb6cb896b445369e1d
}
this._updateTabsAfterInsert();
@@ -4366,6 +4501,7 @@
@@ -4366,6 +4503,7 @@
if (pinned) {
this._updateTabBarForPinnedTabs();
}
@@ -521,7 +523,7 @@ index 42027bfa55eab8ea9298a7d425f2ded45188f7f3..91bd99772d2ef1eb6cb896b445369e1d
TabBarVisibility.update();
}
@@ -4916,6 +5052,7 @@
@@ -4916,6 +5054,7 @@
telemetrySource,
} = {}
) {
@@ -529,7 +531,7 @@ index 42027bfa55eab8ea9298a7d425f2ded45188f7f3..91bd99772d2ef1eb6cb896b445369e1d
// When 'closeWindowWithLastTab' pref is enabled, closing all tabs
// can be considered equivalent to closing the window.
if (
@@ -5005,6 +5142,7 @@
@@ -5005,6 +5144,7 @@
if (lastToClose) {
this.removeTab(lastToClose, aParams);
}
@@ -537,7 +539,7 @@ index 42027bfa55eab8ea9298a7d425f2ded45188f7f3..91bd99772d2ef1eb6cb896b445369e1d
} catch (e) {
console.error(e);
}
@@ -5043,6 +5181,12 @@
@@ -5043,6 +5183,12 @@
aTab._closeTimeNoAnimTimerId = Glean.browserTabclose.timeNoAnim.start();
}
@@ -550,7 +552,7 @@ index 42027bfa55eab8ea9298a7d425f2ded45188f7f3..91bd99772d2ef1eb6cb896b445369e1d
// Handle requests for synchronously removing an already
// asynchronously closing tab.
if (!animate && aTab.closing) {
@@ -5057,6 +5201,9 @@
@@ -5057,6 +5203,9 @@
// state).
let tabWidth = window.windowUtils.getBoundsWithoutFlushing(aTab).width;
let isLastTab = this.#isLastTabInWindow(aTab);
@@ -560,7 +562,7 @@ index 42027bfa55eab8ea9298a7d425f2ded45188f7f3..91bd99772d2ef1eb6cb896b445369e1d
if (
!this._beginRemoveTab(aTab, {
closeWindowFastpath: true,
@@ -5105,7 +5252,13 @@
@@ -5105,7 +5254,13 @@
// We're not animating, so we can cancel the animation stopwatch.
Glean.browserTabclose.timeAnim.cancel(aTab._closeTimeAnimTimerId);
aTab._closeTimeAnimTimerId = null;
@@ -575,7 +577,7 @@ index 42027bfa55eab8ea9298a7d425f2ded45188f7f3..91bd99772d2ef1eb6cb896b445369e1d
return;
}
@@ -5239,7 +5392,7 @@
@@ -5239,7 +5394,7 @@
closeWindowWithLastTab != null
? closeWindowWithLastTab
: !window.toolbar.visible ||
@@ -584,7 +586,7 @@ index 42027bfa55eab8ea9298a7d425f2ded45188f7f3..91bd99772d2ef1eb6cb896b445369e1d
if (closeWindow) {
// We've already called beforeunload on all the relevant tabs if we get here,
@@ -5263,6 +5416,7 @@
@@ -5263,6 +5418,7 @@
newTab = true;
}
@@ -592,7 +594,7 @@ index 42027bfa55eab8ea9298a7d425f2ded45188f7f3..91bd99772d2ef1eb6cb896b445369e1d
aTab._endRemoveArgs = [closeWindow, newTab];
// swapBrowsersAndCloseOther will take care of closing the window without animation.
@@ -5303,13 +5457,7 @@
@@ -5303,13 +5459,7 @@
aTab._mouseleave();
if (newTab) {
@@ -607,7 +609,7 @@ index 42027bfa55eab8ea9298a7d425f2ded45188f7f3..91bd99772d2ef1eb6cb896b445369e1d
} else {
TabBarVisibility.update();
}
@@ -5442,6 +5590,7 @@
@@ -5442,6 +5592,7 @@
this.tabs[i]._tPos = i;
}
@@ -615,7 +617,7 @@ index 42027bfa55eab8ea9298a7d425f2ded45188f7f3..91bd99772d2ef1eb6cb896b445369e1d
if (!this._windowIsClosing) {
// update tab close buttons state
this.tabContainer._updateCloseButtons();
@@ -5663,6 +5812,7 @@
@@ -5663,6 +5814,7 @@
}
let excludeTabs = new Set(aExcludeTabs);
@@ -623,7 +625,7 @@ index 42027bfa55eab8ea9298a7d425f2ded45188f7f3..91bd99772d2ef1eb6cb896b445369e1d
// If this tab has a successor, it should be selectable, since
// hiding or closing a tab removes that tab as a successor.
@@ -5675,13 +5825,13 @@
@@ -5675,13 +5827,13 @@
!excludeTabs.has(aTab.owner) &&
Services.prefs.getBoolPref("browser.tabs.selectOwnerOnClose")
) {
@@ -639,7 +641,7 @@ index 42027bfa55eab8ea9298a7d425f2ded45188f7f3..91bd99772d2ef1eb6cb896b445369e1d
);
let tab = this.tabContainer.findNextTab(aTab, {
@@ -5697,7 +5847,7 @@
@@ -5697,7 +5849,7 @@
}
if (tab) {
@@ -648,7 +650,7 @@ index 42027bfa55eab8ea9298a7d425f2ded45188f7f3..91bd99772d2ef1eb6cb896b445369e1d
}
// If no qualifying visible tab was found, see if there is a tab in
@@ -5718,7 +5868,7 @@
@@ -5718,7 +5870,7 @@
});
}
@@ -657,7 +659,7 @@ index 42027bfa55eab8ea9298a7d425f2ded45188f7f3..91bd99772d2ef1eb6cb896b445369e1d
}
_blurTab(aTab) {
@@ -5729,7 +5879,7 @@
@@ -5729,7 +5881,7 @@
* @returns {boolean}
* False if swapping isn't permitted, true otherwise.
*/
@@ -666,7 +668,7 @@ index 42027bfa55eab8ea9298a7d425f2ded45188f7f3..91bd99772d2ef1eb6cb896b445369e1d
// Do not allow transfering a private tab to a non-private window
// and vice versa.
if (
@@ -5783,6 +5933,7 @@
@@ -5783,6 +5935,7 @@
// fire the beforeunload event in the process. Close the other
// window if this was its last tab.
if (
@@ -674,7 +676,7 @@ index 42027bfa55eab8ea9298a7d425f2ded45188f7f3..91bd99772d2ef1eb6cb896b445369e1d
!remoteBrowser._beginRemoveTab(aOtherTab, {
adoptedByTab: aOurTab,
closeWindowWithLastTab: true,
@@ -5794,7 +5945,7 @@
@@ -5794,7 +5947,7 @@
// If this is the last tab of the window, hide the window
// immediately without animation before the docshell swap, to avoid
// about:blank being painted.
@@ -683,7 +685,7 @@ index 42027bfa55eab8ea9298a7d425f2ded45188f7f3..91bd99772d2ef1eb6cb896b445369e1d
if (closeWindow) {
let win = aOtherTab.ownerGlobal;
win.windowUtils.suppressAnimation(true);
@@ -5918,11 +6069,13 @@
@@ -5918,11 +6071,13 @@
}
// Finish tearing down the tab that's going away.
@@ -697,7 +699,7 @@ index 42027bfa55eab8ea9298a7d425f2ded45188f7f3..91bd99772d2ef1eb6cb896b445369e1d
this.setTabTitle(aOurTab);
@@ -6124,10 +6277,10 @@
@@ -6124,10 +6279,10 @@
SessionStore.deleteCustomTabValue(aTab, "hiddenBy");
}
@@ -710,7 +712,7 @@ index 42027bfa55eab8ea9298a7d425f2ded45188f7f3..91bd99772d2ef1eb6cb896b445369e1d
aTab.selected ||
aTab.closing ||
// Tabs that are sharing the screen, microphone or camera cannot be hidden.
@@ -6185,7 +6338,8 @@
@@ -6185,7 +6340,8 @@
*
* @param {MozTabbrowserTab|MozTabbrowserTabGroup|MozTabbrowserTabGroup.labelElement} aTab
*/
@@ -720,7 +722,7 @@ index 42027bfa55eab8ea9298a7d425f2ded45188f7f3..91bd99772d2ef1eb6cb896b445369e1d
if (this.tabs.length == 1) {
return null;
}
@@ -6213,7 +6367,8 @@
@@ -6213,7 +6369,8 @@
AppConstants.BROWSER_CHROME_URL,
"_blank",
options,
@@ -730,7 +732,7 @@ index 42027bfa55eab8ea9298a7d425f2ded45188f7f3..91bd99772d2ef1eb6cb896b445369e1d
);
}
@@ -6319,7 +6474,7 @@
@@ -6319,7 +6476,7 @@
* `true` if element is a `<tab-group>`
*/
isTabGroup(element) {
@@ -739,7 +741,7 @@ index 42027bfa55eab8ea9298a7d425f2ded45188f7f3..91bd99772d2ef1eb6cb896b445369e1d
}
/**
@@ -6404,8 +6559,8 @@
@@ -6404,8 +6561,8 @@
}
// Don't allow mixing pinned and unpinned tabs.
@@ -750,7 +752,7 @@ index 42027bfa55eab8ea9298a7d425f2ded45188f7f3..91bd99772d2ef1eb6cb896b445369e1d
} else {
tabIndex = Math.max(tabIndex, this.pinnedTabCount);
}
@@ -6431,10 +6586,16 @@
@@ -6431,10 +6588,16 @@
this.#handleTabMove(
element,
() => {
@@ -769,7 +771,7 @@ index 42027bfa55eab8ea9298a7d425f2ded45188f7f3..91bd99772d2ef1eb6cb896b445369e1d
if (neighbor && this.isTab(element) && tabIndex > element._tPos) {
neighbor.after(element);
} else {
@@ -6492,23 +6653,28 @@
@@ -6492,23 +6655,28 @@
#moveTabNextTo(element, targetElement, moveBefore = false, metricsContext) {
if (this.isTabGroupLabel(targetElement)) {
targetElement = targetElement.group;
@@ -804,7 +806,7 @@ index 42027bfa55eab8ea9298a7d425f2ded45188f7f3..91bd99772d2ef1eb6cb896b445369e1d
} else if (!element.pinned && targetElement && targetElement.pinned) {
// If the caller asks to move an unpinned element next to a pinned
// tab, move the unpinned element to be the first unpinned element
@@ -6521,14 +6687,34 @@
@@ -6521,14 +6689,34 @@
// move the tab group right before the first unpinned tab.
// 4. Moving a tab group and the first unpinned tab is grouped:
// move the tab group right before the first unpinned tab's tab group.
@@ -840,7 +842,7 @@ index 42027bfa55eab8ea9298a7d425f2ded45188f7f3..91bd99772d2ef1eb6cb896b445369e1d
element.pinned
? this.tabContainer.pinnedTabsContainer
: this.tabContainer;
@@ -6537,7 +6723,7 @@
@@ -6537,7 +6725,7 @@
element,
() => {
if (moveBefore) {
@@ -849,7 +851,7 @@ index 42027bfa55eab8ea9298a7d425f2ded45188f7f3..91bd99772d2ef1eb6cb896b445369e1d
} else if (targetElement) {
targetElement.after(element);
} else {
@@ -6607,10 +6793,10 @@
@@ -6607,10 +6795,10 @@
* @param {TabMetricsContext} [metricsContext]
*/
moveTabToGroup(aTab, aGroup, metricsContext) {
@@ -862,7 +864,7 @@ index 42027bfa55eab8ea9298a7d425f2ded45188f7f3..91bd99772d2ef1eb6cb896b445369e1d
return;
}
if (aTab.group && aTab.group.id === aGroup.id) {
@@ -6656,6 +6842,7 @@
@@ -6656,6 +6844,7 @@
let state = {
tabIndex: tab._tPos,
@@ -870,7 +872,7 @@ index 42027bfa55eab8ea9298a7d425f2ded45188f7f3..91bd99772d2ef1eb6cb896b445369e1d
};
if (tab.visible) {
state.elementIndex = tab.elementIndex;
@@ -6682,7 +6869,7 @@
@@ -6682,7 +6871,7 @@
let changedTabGroup =
previousTabState.tabGroupId != currentTabState.tabGroupId;
@@ -879,7 +881,7 @@ index 42027bfa55eab8ea9298a7d425f2ded45188f7f3..91bd99772d2ef1eb6cb896b445369e1d
tab.dispatchEvent(
new CustomEvent("TabMove", {
bubbles: true,
@@ -6723,6 +6910,10 @@
@@ -6723,6 +6912,10 @@
moveActionCallback();
@@ -890,7 +892,7 @@ index 42027bfa55eab8ea9298a7d425f2ded45188f7f3..91bd99772d2ef1eb6cb896b445369e1d
// Clear tabs cache after moving nodes because the order of tabs may have
// changed.
this.tabContainer._invalidateCachedTabs();
@@ -7623,7 +7814,7 @@
@@ -7623,7 +7816,7 @@
// preventDefault(). It will still raise the window if appropriate.
break;
}
@@ -899,7 +901,7 @@ index 42027bfa55eab8ea9298a7d425f2ded45188f7f3..91bd99772d2ef1eb6cb896b445369e1d
window.focus();
aEvent.preventDefault();
break;
@@ -7640,7 +7831,6 @@
@@ -7640,7 +7833,6 @@
}
case "TabGroupCollapse":
aEvent.target.tabs.forEach(tab => {
@@ -907,7 +909,7 @@ index 42027bfa55eab8ea9298a7d425f2ded45188f7f3..91bd99772d2ef1eb6cb896b445369e1d
});
break;
case "TabGroupCreateByUser":
@@ -8589,6 +8779,7 @@
@@ -8589,6 +8781,7 @@
aWebProgress.isTopLevel
) {
this.mTab.setAttribute("busy", "true");
@@ -915,7 +917,7 @@ index 42027bfa55eab8ea9298a7d425f2ded45188f7f3..91bd99772d2ef1eb6cb896b445369e1d
gBrowser._tabAttrModified(this.mTab, ["busy"]);
this.mTab._notselectedsinceload = !this.mTab.selected;
}
@@ -9623,7 +9814,7 @@ var TabContextMenu = {
@@ -9623,7 +9816,7 @@ var TabContextMenu = {
);
contextUnpinSelectedTabs.hidden =
!this.contextTab.pinned || !this.multiselected;

View File

@@ -1,22 +0,0 @@
diff --git a/docshell/base/BrowsingContextWebProgress.cpp b/docshell/base/BrowsingContextWebProgress.cpp
index cc5bf6de7bf4875acf0c572549dc30ff06ac7f6f..4e0f3648f551fe9507a654d19f0a99e455418aa9 100644
--- a/docshell/base/BrowsingContextWebProgress.cpp
+++ b/docshell/base/BrowsingContextWebProgress.cpp
@@ -54,7 +54,7 @@ NS_IMETHODIMP BrowsingContextWebProgress::AddProgressListener(
if (mListenerInfoList.Contains(listener)) {
// The listener is already registered!
- return NS_ERROR_FAILURE;
+ return NS_OK;
}
mListenerInfoList.AppendElement(ListenerInfo(listener, aNotifyMask));
@@ -68,7 +68,7 @@ NS_IMETHODIMP BrowsingContextWebProgress::RemoveProgressListener(
return NS_ERROR_INVALID_ARG;
}
- return mListenerInfoList.RemoveElement(listener) ? NS_OK : NS_ERROR_FAILURE;
+ return mListenerInfoList.RemoveElement(listener) ? NS_OK : NS_OK;
}
NS_IMETHODIMP BrowsingContextWebProgress::GetBrowsingContextXPCOM(

View File

@@ -11,8 +11,10 @@ ChromeUtils.defineESModuleGetters(lazy, {
TabGroupState: 'resource:///modules/sessionstore/TabGroupState.sys.mjs',
SessionStore: 'resource:///modules/sessionstore/SessionStore.sys.mjs',
SessionSaver: 'resource:///modules/sessionstore/SessionSaver.sys.mjs',
setTimeout: 'resource://gre/modules/Timer.sys.mjs',
});
const MIGRATION_PREF = 'zen.ui.migration.session-manager-restore';
const OBSERVING = ['browser-window-before-show'];
class nsZenSessionManager {
@@ -40,6 +42,17 @@ class nsZenSessionManager {
}
onFileRead(initialState) {
// For the first time after migration, we restore the tabs
// That where going to be restored by SessionStore. The sidebar
// object will always be empty after migration because we haven't
// gotten the opportunity to save the session yet.
if (!Services.prefs.getBoolPref(MIGRATION_PREF, false)) {
Services.prefs.setBoolPref(MIGRATION_PREF, true);
return;
}
// Restore all windows with the same sidebar object, this will
// guarantee that all tabs, groups, folders and split view data
// are properly synced across all windows.
for (const winData of initialState.windows || []) {
this.restoreWindowData(winData);
}
@@ -76,9 +89,9 @@ class nsZenSessionManager {
* The current session state.
*/
saveState(state) {
if (lazy.PrivateBrowsingUtils.permanentPrivateBrowsing) {
if (lazy.PrivateBrowsingUtils.permanentPrivateBrowsing || !state?.windows?.length) {
// Don't save (or even collect) anything in permanent private
// browsing mode
// browsing mode. We also don't want to save if there are no windows.
return;
}
this.#collectWindowData(state);
@@ -111,8 +124,6 @@ class nsZenSessionManager {
* The current session state.
*/
#collectTabsData(sidebarData, state) {
if (!state?.windows?.length) return;
const tabIdRelationMap = new Map();
for (const window of state.windows) {
// Only accept the tabs with `_zenIsActiveTab` set to true from
@@ -149,14 +160,19 @@ class nsZenSessionManager {
return;
}
lazy.SessionSaver.run().then(() => {
const state = lazy.SessionStore.getCurrentState(true);
const windows = state.windows || {};
let newWindow = Cu.cloneInto(windows[0], {});
delete newWindow.selected;
const newState = { windows: [newWindow] };
aWindow._zenRestorePromise = new Promise((resolve) => {
SessionStoreInternal.restoreWindows(aWindow, newState, {});
resolve();
lazy.setTimeout(() => {
const state = lazy.SessionStore.getCurrentState(true);
const windows = state.windows || [];
let windowToClone = windows[0];
if (!windowToClone) {
this.restoreWindowData((windowToClone = {}));
}
let newWindow = Cu.cloneInto(windowToClone, {});
delete newWindow.selected;
const newState = { windows: [newWindow] };
SessionStoreInternal.restoreWindows(aWindow, newState, {
firstWindow: true,
});
});
});
}

View File

@@ -427,21 +427,63 @@ class nsZenWindowSync {
this.#swapBrowserDocSheellsInner(aOurTab, aOtherTab);
}
/**
* Restores the tab progress listener for a given tab.
*
* @param {Object} aTab - The tab to restore the progress listener for.
* @param {Function} callback - The callback function to execute while the listener is removed.
* @param {boolean} onClose - Indicates if the swap is done during a tab close operation.
*/
#withRestoreTabProgressListener(aTab, callback, onClose = false) {
const otherTabBrowser = aTab.ownerGlobal.gBrowser;
const otherBrowser = aTab.linkedBrowser;
// We aren't closing the other tab so, we also need to swap its tablisteners.
let filter = otherTabBrowser._tabFilters.get(aTab);
let tabListener = otherTabBrowser._tabListeners.get(aTab);
otherBrowser.webProgress.removeProgressListener(filter);
filter.removeProgressListener(tabListener);
try {
callback();
} catch (e) {
console.error(e);
}
// Restore the listeners for the swapped in tab.
if (!onClose) {
tabListener = new otherTabBrowser.zenTabProgressListener(aTab, otherBrowser, false, false);
otherTabBrowser._tabListeners.set(aTab, tabListener);
const notifyAll = Ci.nsIWebProgress.NOTIFY_ALL;
filter.addProgressListener(tabListener, notifyAll);
otherBrowser.webProgress.addProgressListener(filter, notifyAll);
}
}
/**
* Swaps the browser docshells between two tabs.
*
* @param {Object} aOurTab - The tab in the current window.
* @param {Object} aOtherTab - The tab in the other window.
* @param {boolean} focus - Indicates if the tab should be focused after the swap.
* @param {boolean} onClose - Indicates if the swap is done during a tab close operation.
*/
#swapBrowserDocSheellsInner(aOurTab, aOtherTab, focus = true) {
#swapBrowserDocSheellsInner(aOurTab, aOtherTab, focus = true, onClose = false) {
// Load about:blank
if (aOurTab.linkedBrowser?.currentURI.spec !== 'about:blank') {
if (!onClose && aOurTab.linkedBrowser?.currentURI.spec !== 'about:blank') {
aOurTab.linkedBrowser.loadURI(Services.io.newURI('about:blank'), {
triggeringPrincipal: Services.scriptSecurityManager.getSystemPrincipal(),
loadFlags: Ci.nsIWebNavigation.LOAD_FLAGS_REPLACE_HISTORY,
});
}
aOurTab.ownerGlobal.gBrowser.swapBrowsersAndCloseOther(aOurTab, aOtherTab, false);
this.#withRestoreTabProgressListener(
aOtherTab,
() => {
aOurTab.ownerGlobal.gBrowser.swapBrowsersAndCloseOther(aOurTab, aOtherTab, false);
},
onClose
);
aOtherTab.permanentKey = aOurTab.permanentKey;
const kAttributesToRemove = ['muted', 'soundplaying', 'sharing', 'pictureinpicture'];
// swapBrowsersAndCloseOther already takes care of transferring attributes like 'muted',
@@ -572,7 +614,7 @@ class nsZenWindowSync {
const targetTab = this.#getItemFromWindow(mostRecentWindow, tab.id);
if (targetTab) {
targetTab._zenContentsVisible = true;
this.#swapBrowserDocSheellsInner(targetTab, tab, targetTab.selected);
this.#swapBrowserDocSheellsInner(targetTab, tab, targetTab.selected, /* onClose =*/ true);
// We can animate later, whats important is to always stay on the same
// process and avoid async operations here to avoid the closed window
// being unloaded before the swap is done.
@@ -672,14 +714,10 @@ class nsZenWindowSync {
}
};
if (!win) {
win = this.replaceTabWithWindow(selectedTab, {}, /* zenForceSync = */ true);
win.addEventListener(
'before-initial-tab-adopted',
() => {
moveAllTabsToWindow();
},
{ once: true }
);
win = aWindow.gBrowser.replaceTabWithWindow(selectedTab, {}, /* zenForceSync = */ true);
win.gZenWorkspaces.promiseInitialized.then(() => {
moveAllTabsToWindow();
});
return;
}
moveAllTabsToWindow(true);
@@ -690,8 +728,9 @@ class nsZenWindowSync {
on_TabOpen(aEvent) {
const tab = aEvent.target;
const window = tab.ownerGlobal;
// TODO: Should we only set this flag if the tab is selected?
tab._zenContentsVisible = true;
if (tab.selected) {
tab._zenContentsVisible = true;
}
if (tab.id) {
// This tab was opened as part of a sync operation.
return;
@@ -715,10 +754,18 @@ class nsZenWindowSync {
}
on_ZenTabIconChanged(aEvent) {
if (!aEvent.target?._zenContentsVisible) {
// No need to sync icon changes for tabs that aren't active in this window.
return;
}
return this.#delegateGenericSyncEvent(aEvent, SYNC_FLAG_ICON);
}
on_ZenTabLabelChanged(aEvent) {
if (!aEvent.target?._zenContentsVisible) {
// No need to sync label changes for tabs that aren't active in this window.
return;
}
return this.#delegateGenericSyncEvent(aEvent, SYNC_FLAG_LABEL);
}

View File

@@ -55,7 +55,6 @@ class nsZenWorkspaces extends nsZenMultiWindowFeature {
this.promiseDBInitialized,
this.promisePinnedInitialized,
SessionStore.promiseAllWindowsRestored,
window._zenRestorePromise,
]);
}