fix: Tab siwtcher crashing zen if no active tabs exist, b=(closes #7865), c=tabs, workspaces

This commit is contained in:
mr. m
2025-04-25 15:21:27 +02:00
parent d15ee91ea0
commit 78ee43347e
3 changed files with 21 additions and 3 deletions

View File

@@ -1,5 +1,5 @@
diff --git a/browser/components/tabbrowser/content/browser-ctrlTab.js b/browser/components/tabbrowser/content/browser-ctrlTab.js
index 6753641cb579032306453be3f5054d7bc7661e8c..e0eda8d77637334ca30ee1842057cb43b4af2c21 100644
index 6753641cb579032306453be3f5054d7bc7661e8c..436ee8940c8a73d238a7aed10768a0a752a3f119 100644
--- a/browser/components/tabbrowser/content/browser-ctrlTab.js
+++ b/browser/components/tabbrowser/content/browser-ctrlTab.js
@@ -252,7 +252,7 @@ var ctrlTab = {
@@ -20,6 +20,15 @@ index 6753641cb579032306453be3f5054d7bc7661e8c..e0eda8d77637334ca30ee1842057cb43
return;
}
@@ -483,7 +483,7 @@ var ctrlTab = {
},
open: function ctrlTab_open() {
- if (this.isOpen) {
+ if (this.isOpen || !this.tabCount) {
return;
}
@@ -761,7 +761,7 @@ var ctrlTab = {
_initRecentlyUsedTabs() {
this._recentlyUsedTabs = Array.prototype.filter.call(

View File

@@ -1274,5 +1274,6 @@
&[hidden='true'] {
visibility: hidden;
pointer-events: none;
position: fixed;
}
}

View File

@@ -1809,6 +1809,7 @@ var ZenWorkspaces = new (class extends ZenMultiWindowFeature {
// Second pass: Handle tab selection
this.tabContainer._invalidateCachedTabs();
const tabToSelect = await this._handleTabSelection(window, onInit, previousWorkspace.uuid);
gBrowser.warmupTab(tabToSelect);
// Update UI and state
const previousWorkspaceIndex = workspaces.workspaces.findIndex((w) => w.uuid === previousWorkspace.uuid);
@@ -2771,8 +2772,12 @@ var ZenWorkspaces = new (class extends ZenMultiWindowFeature {
}
try {
const currentWorkspace = this.getActiveWorkspaceFromCache();
// Check if we need to change workspace
if (!tab.hasAttribute('zen-essential') && tab.getAttribute('zen-workspace-id') !== this.activeWorkspace) {
if (
tab.getAttribute('zen-workspace-id') !== this.activeWorkspace ||
(currentWorkspace.containerTabId !== tab.getAttribute('usercontextid') && this.containerSpecificEssentials)
) {
// Use a mutex-like approach to prevent concurrent workspace changes
if (this._workspaceChangeInProgress) {
console.warn('Workspace change already in progress, deferring tab switch');
@@ -2781,7 +2786,10 @@ var ZenWorkspaces = new (class extends ZenMultiWindowFeature {
this._workspaceChangeInProgress = true;
try {
await this.changeWorkspace({ uuid: tab.getAttribute('zen-workspace-id') });
await this.changeWorkspace({
uuid: tab.getAttribute('zen-workspace-id'),
containerTabId: tab.getAttribute('usercontextid'),
});
} finally {
this._workspaceChangeInProgress = false;
}