fix: Fixed race condition happening when moving tabs to a synced window, b=closes #12707, c=common

This commit is contained in:
mr. m
2026-03-11 00:30:15 +01:00
parent 036cfb187c
commit eb176edf8b
2 changed files with 26 additions and 8 deletions

View File

@@ -11,6 +11,9 @@ class ZenStartup {
#hasInitializedLayout = false;
isReady = false;
promiseInitialized = new Promise(resolve => {
this.promiseInitializedResolve = resolve;
});
init() {
this.openWatermark();
@@ -94,6 +97,8 @@ class ZenStartup {
.getElementById("tabbrowser-arrowscrollbox")
.setAttribute("orient", "vertical");
this.isReady = true;
this.promiseInitializedResolve();
delete this.promiseInitializedResolve;
});
}

View File

@@ -810,11 +810,18 @@ class nsZenWindowSync {
aOtherTab,
() => {
this.log(`Swapping docshells between windows for tab ${aOurTab.id}`);
aOurTab.ownerGlobal.gBrowser.swapBrowsersAndCloseOther(
aOurTab,
aOtherTab,
false
);
try {
aOurTab.ownerGlobal.gBrowser.swapBrowsersAndCloseOther(
aOurTab,
aOtherTab,
false
);
} catch (e) {
console.error(
`Error swapping browsers for tabs ${aOurTab.id} and ${aOtherTab.id}:`,
e
);
}
// Swap permanent keys
if (!onClose) {
@@ -1221,9 +1228,15 @@ class nsZenWindowSync {
{},
/* zenForceSync = */ true
);
win.gZenWorkspaces.promiseInitialized.then(() => {
moveAllTabsToWindow();
});
win.addEventListener(
"MozBeforeInitialXULLayout",
() => {
win.gZenStartup.promiseInitialized.then(() => {
moveAllTabsToWindow();
});
},
{ once: true }
);
return;
}
moveAllTabsToWindow(true);