commit 2d48f28facb2e785bab24cca384decd0f0bfb3a0
parent 7cce9daae246b808d55379579b74f58712524ebf
Author: Duncan McIntosh <dmcintosh@mozilla.com>
Date: Fri, 12 Dec 2025 21:34:08 +0000
Bug 2000947 - Part 1: Be more careful in tests about cleaning up Taskbar Tabs and not creating them when we don't want to. r=nrishel
Differential Revision: https://phabricator.services.mozilla.com/D275324
Diffstat:
3 files changed, 30 insertions(+), 12 deletions(-)
diff --git a/browser/components/taskbartabs/test/browser/browser_taskbarTabs_manifest.js b/browser/components/taskbartabs/test/browser/browser_taskbarTabs_manifest.js
@@ -197,7 +197,7 @@ async function usingManifest(aCallback, aLocation = "/") {
let result = await TaskbarTabs.moveTabIntoTaskbarTab(tab);
const uri = Services.io.newURI(httpUrl(aLocation));
- const tt = await TaskbarTabs.findOrCreateTaskbarTab(uri, 0);
+ const tt = await TaskbarTabs.findTaskbarTab(uri, 0);
is(
await TaskbarTabsUtils.getTaskbarTabIdFromWindow(result.window),
tt.id,
diff --git a/browser/components/taskbartabs/test/browser/browser_taskbarTabs_pageAction.js b/browser/components/taskbartabs/test/browser/browser_taskbarTabs_pageAction.js
@@ -333,10 +333,12 @@ add_task(async function testPrefIsMonitored() {
});
add_task(async function test_moveTabIntoTaskbarTabCreation() {
- // Ensure example.com does not have a Taskbar Tab.
const uri = Services.io.newURI(BASE_URL);
- const tt = await TaskbarTabs.findOrCreateTaskbarTab(uri, 0);
- await TaskbarTabs.removeTaskbarTab(tt.id);
+ Assert.equal(
+ await TaskbarTabs.findTaskbarTab(uri, 0),
+ null,
+ "example.com does not already have a taskbar tab"
+ );
await BrowserTestUtils.withNewTab("https://example.com/", async browser => {
const tab = window.gBrowser.getTabForBrowser(browser);
@@ -345,6 +347,7 @@ add_task(async function test_moveTabIntoTaskbarTabCreation() {
const found = TaskbarTabsUtils.getTaskbarTabIdFromWindow(move.window);
is(found, move.taskbarTab.id, "Returned Taskbar Tab matches window");
await BrowserTestUtils.closeWindow(move.window);
+ await TaskbarTabs.removeTaskbarTab(found);
});
});
@@ -360,8 +363,8 @@ add_task(async function test_moveTabIntoTaskbarTabReuse() {
const found = TaskbarTabsUtils.getTaskbarTabIdFromWindow(move.window);
is(found, move.taskbarTab.id, "Returned Taskbar Tab matches window");
is(tt.id, move.taskbarTab.id, "Returned Taskbar Tab existed before");
- await TaskbarTabs.removeTaskbarTab(tt.id);
await BrowserTestUtils.closeWindow(move.window);
+ await TaskbarTabs.removeTaskbarTab(tt.id);
});
});
@@ -379,7 +382,7 @@ add_task(async function test_page_action_uses_manifest() {
const win = await newWinPromise;
const uri = Services.io.newURI(url);
- const tt = await TaskbarTabs.findOrCreateTaskbarTab(uri, 0);
+ const tt = await TaskbarTabs.findTaskbarTab(uri, 0);
is(
await TaskbarTabsUtils.getTaskbarTabIdFromWindow(win),
tt.id,
@@ -387,7 +390,7 @@ add_task(async function test_page_action_uses_manifest() {
);
is(tt.name, "Mochitest", "Manifest name was used");
- await TaskbarTabs.removeTaskbarTab(tt.id);
await BrowserTestUtils.closeWindow(win);
+ await TaskbarTabs.removeTaskbarTab(tt.id);
});
});
diff --git a/browser/components/taskbartabs/test/browser/browser_taskbarTabs_title.js b/browser/components/taskbartabs/test/browser/browser_taskbarTabs_title.js
@@ -70,7 +70,10 @@ async function phaseBeforeContentTitle(aContainer, aProfileName) {
// tick and hopefully that's enough.
await TestUtils.waitForTick();
- return win;
+ return {
+ win,
+ tt,
+ };
}
async function phaseAfterContentTitle(aWindow) {
@@ -97,7 +100,7 @@ function assertHasContainerName(aPrivate, aTitle) {
}
async function test_defaultCase(aPrivate) {
- const win = await phaseBeforeContentTitle(0, null, aPrivate);
+ const { tt, win } = await phaseBeforeContentTitle(0, null, aPrivate);
const title = win.document.title;
assertHasTaskbarTabName(aPrivate, title);
ok(!title.includes(kUserContextLabel), "Doesn't include container name");
@@ -107,10 +110,11 @@ async function test_defaultCase(aPrivate) {
ok(!title.includes(kUserContextLabel), "Title still has no container name");
await BrowserTestUtils.closeWindow(win);
+ await TaskbarTabs.removeTaskbarTab(tt.id);
}
async function test_container(aPrivate) {
- const win = await phaseBeforeContentTitle(1, null, aPrivate);
+ const { tt, win } = await phaseBeforeContentTitle(1, null, aPrivate);
const title = win.document.title;
assertHasTaskbarTabName(aPrivate, title);
assertHasContainerName(aPrivate, title);
@@ -120,10 +124,15 @@ async function test_container(aPrivate) {
assertHasContainerName(aPrivate, title);
await BrowserTestUtils.closeWindow(win);
+ await TaskbarTabs.removeTaskbarTab(tt.id);
}
async function test_profile(aPrivate) {
- const win = await phaseBeforeContentTitle(0, kGenericProfileName, aPrivate);
+ const { tt, win } = await phaseBeforeContentTitle(
+ 0,
+ kGenericProfileName,
+ aPrivate
+ );
const title = win.document.title;
assertHasTaskbarTabName(aPrivate, title);
ok(!title.includes(kUserContextLabel), "Doesn't include container name");
@@ -135,10 +144,15 @@ async function test_profile(aPrivate) {
ok(title.includes(kGenericProfileName), "Does include profile name");
await BrowserTestUtils.closeWindow(win);
+ await TaskbarTabs.removeTaskbarTab(tt.id);
}
async function test_profileAndContainer(aPrivate) {
- const win = await phaseBeforeContentTitle(1, kGenericProfileName, aPrivate);
+ const { tt, win } = await phaseBeforeContentTitle(
+ 1,
+ kGenericProfileName,
+ aPrivate
+ );
const title = win.document.title;
assertHasTaskbarTabName(aPrivate, title);
assertHasContainerName(aPrivate, title);
@@ -150,6 +164,7 @@ async function test_profileAndContainer(aPrivate) {
ok(title.includes(kGenericProfileName), "Does include profile name");
await BrowserTestUtils.closeWindow(win);
+ await TaskbarTabs.removeTaskbarTab(tt.id);
}
async function withoutExposingTitle(aTestCase) {