commit bce4b78eddce4c8fe675671513f04485d2db6241
parent 398e1b51f819bab472d646032349dcfc146a17a6
Author: Duncan McIntosh <dmcintosh@mozilla.com>
Date: Fri, 19 Dec 2025 19:17:21 +0000
Bug 2000947 - Part 3: Return the removed TaskbarTab from TaskbarTabsRegistry.removeTaskbarTab. r=nrishel
Differential Revision: https://phabricator.services.mozilla.com/D275326
Diffstat:
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() {