tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

commit a335f2b8e44ce62b3c5d4c0a8e391ffcde7d720b
parent c9f8c20276695e03906d9fd73cf71bdb3bb9d8d0
Author: Duncan McIntosh <dmcintosh@mozilla.com>
Date:   Fri, 12 Dec 2025 21:34:08 +0000

Bug 2000947 - Part 3: Return the removed TaskbarTab from TaskbarTabsRegistry.removeTaskbarTab. r=nrishel

Differential Revision: https://phabricator.services.mozilla.com/D275326

Diffstat:
Mbrowser/components/taskbartabs/TaskbarTabsRegistry.sys.mjs | 8++++++--
Mbrowser/components/taskbartabs/test/xpcshell/test_TaskbarTabsRegistry.js | 12+++++++++++-
2 files changed, 17 insertions(+), 3 deletions(-)

diff --git a/browser/components/taskbartabs/TaskbarTabsRegistry.sys.mjs b/browser/components/taskbartabs/TaskbarTabsRegistry.sys.mjs @@ -286,6 +286,8 @@ export class TaskbarTabsRegistry { * Removes a Taskbar Tab. * * @param {string} aId - The ID of the TaskbarTab to remove. + * @returns {TaskbarTab?} The removed taskbar tab, or null if it wasn't + * found. */ removeTaskbarTab(aId) { let tts = this.#taskbarTabs; @@ -299,9 +301,11 @@ export class TaskbarTabsRegistry { Glean.webApp.uninstall.record({}); this.#emitter.emit(kTaskbarTabsRegistryEvents.removed, removed[0]); - } else { - lazy.logConsole.error(`Taskbar Tab ID ${aId} not found.`); + return removed[0]; } + + lazy.logConsole.error(`Taskbar Tab ID ${aId} not found.`); + return null; } /** diff --git a/browser/components/taskbartabs/test/xpcshell/test_TaskbarTabsRegistry.js b/browser/components/taskbartabs/test/xpcshell/test_TaskbarTabsRegistry.js @@ -91,12 +91,22 @@ add_task(async function test_remove_taskbar_tab() { "Taskbar Tab ID should match the ID returned on creation." ); - registry.removeTaskbarTab(taskbarTab.id); + Assert.deepEqual( + registry.removeTaskbarTab(taskbarTab.id), + taskbarTab, + "The removed Taskbar Tab was removed" + ); Assert.ok( !registry.findTaskbarTab(url, userContextId), "Taskbar Tab ID should be removed." ); + + Assert.strictEqual( + registry.removeTaskbarTab(taskbarTab.id), + null, + "Null was returned since no Taskbar Tab with that ID exists" + ); }); add_task(async function test_container_mismatch() {