From 1fc2299801a99c0b347df771c329978944d5c718 Mon Sep 17 00:00:00 2001 From: "mr. m" Date: Fri, 9 May 2025 19:29:53 +0200 Subject: [PATCH] fix: Fixed workspace tests having an extra tab, b=(no-bug), c=common, compact-mode, workspaces, tests --- src/zen/common/ZenUIManager.mjs | 14 ++++++-------- src/zen/compact-mode/ZenCompactMode.mjs | 8 +++++++- .../tests/workspaces/browser_basic_workspaces.js | 6 +++--- src/zen/workspaces/ZenWorkspaces.mjs | 8 ++++---- 4 files changed, 20 insertions(+), 16 deletions(-) diff --git a/src/zen/common/ZenUIManager.mjs b/src/zen/common/ZenUIManager.mjs index d53bfb984..7190f3f7c 100644 --- a/src/zen/common/ZenUIManager.mjs +++ b/src/zen/common/ZenUIManager.mjs @@ -420,14 +420,12 @@ var gZenUIManager = { clearTimeout(this._toastTimeouts[messageId]); } this._toastTimeouts[messageId] = setTimeout(() => { - this.motion - .animate(toast, { opacity: [1, 0], scale: [1, 0.5] }, { duration: 0.2, bounce: 0 }) - .then(() => { - toast.remove(); - if (this._toastContainer.children.length === 0) { - this._toastContainer.setAttribute('hidden', true); - } - }); + this.motion.animate(toast, { opacity: [1, 0], scale: [1, 0.5] }, { duration: 0.2, bounce: 0 }).then(() => { + toast.remove(); + if (this._toastContainer.children.length === 0) { + this._toastContainer.setAttribute('hidden', true); + } + }); }, options.timeout || 3000); }, diff --git a/src/zen/compact-mode/ZenCompactMode.mjs b/src/zen/compact-mode/ZenCompactMode.mjs index 89d0b8dae..06383b165 100644 --- a/src/zen/compact-mode/ZenCompactMode.mjs +++ b/src/zen/compact-mode/ZenCompactMode.mjs @@ -560,7 +560,13 @@ var gZenCompactModeManager = { }, async _onTabOpen(tab, inBackground) { - if (inBackground && this.preference && !this.isSidebarPotentiallyOpen() && this._canShowBackgroundTabToast && !gZenGlanceManager._animating) { + if ( + inBackground && + this.preference && + !this.isSidebarPotentiallyOpen() && + this._canShowBackgroundTabToast && + !gZenGlanceManager._animating + ) { gZenUIManager.showToast('zen-background-tab-opened-toast'); } }, diff --git a/src/zen/tests/workspaces/browser_basic_workspaces.js b/src/zen/tests/workspaces/browser_basic_workspaces.js index cd76681d4..94ced75a3 100644 --- a/src/zen/tests/workspaces/browser_basic_workspaces.js +++ b/src/zen/tests/workspaces/browser_basic_workspaces.js @@ -21,8 +21,8 @@ add_task(async function test_Check_Creation() { await ZenWorkspaces.removeWorkspace(ZenWorkspaces.activeWorkspace); const workspacesAfterRemove = await ZenWorkspaces._workspaces(); - ok(workspacesAfterRemove.workspaces.length, 1); + ok(workspacesAfterRemove.workspaces.length === 1, 'One workspace should exist.'); ok(workspacesAfterRemove.workspaces[0].uuid === currentWorkspaceUUID, 'The workspace should be the one we started with.'); - - ok(gBrowser.tabs.length, 1); + ok(gBrowser.tabs.length === 2, 'There should be one tab.'); + BrowserTestUtils.removeTab(gBrowser.selectedTab); }); diff --git a/src/zen/workspaces/ZenWorkspaces.mjs b/src/zen/workspaces/ZenWorkspaces.mjs index ac8d2c0f2..476b66dba 100644 --- a/src/zen/workspaces/ZenWorkspaces.mjs +++ b/src/zen/workspaces/ZenWorkspaces.mjs @@ -278,9 +278,6 @@ var ZenWorkspaces = new (class extends ZenMultiWindowFeature { } _initializeEmptyTab() { - if (gZenUIManager.testingEnabled) { - return; - } this._emptyTab = gBrowser.addTrustedTab('about:blank', { inBackground: true, userContextId: 0, _forZenEmptyTab: true }); } @@ -1154,16 +1151,19 @@ var ZenWorkspaces = new (class extends ZenMultiWindowFeature { async removeWorkspace(windowID) { let workspacesData = await this._workspaces(); - await this.changeWorkspace(workspacesData.workspaces.find((workspace) => workspace.uuid !== windowID)); this._deleteAllTabsInWorkspace(windowID); + await this.changeWorkspace(workspacesData.workspaces.find((workspace) => workspace.uuid !== windowID)); delete this._lastSelectedWorkspaceTabs[windowID]; await ZenWorkspacesStorage.removeWorkspace(windowID); + // Remove the workspace from the cache + this._workspaceCache.workspaces = this._workspaceCache.workspaces.filter((workspace) => workspace.uuid !== windowID); await this._propagateWorkspaceData(); await this._updateWorkspacesChangeContextMenu(); this.onWindowResize(); for (let container of document.querySelectorAll(`.zen-workspace-tabs-section[zen-workspace-id="${windowID}"]`)) { container.remove(); } + this.registerPinnedResizeObserver(); } isWorkspaceActive(workspace) {