aboutsummaryrefslogtreecommitdiff
path: root/test-suite
diff options
context:
space:
mode:
authorTianren Dong <tianrendong.dtr@gmail.com>2026-09-28 19:45:18 -0400
committerTianren Dong <tianrendong.dtr@gmail.com>2026-09-28 19:45:18 -0400
commitb33d18552599664901356ae27db0270df3cc3129 (patch)
tree362a08c4721e65f084390cf6976292ccda375253 /test-suite
parent9e4514f020ecab9af0a8b8d36f01fc802ff5123e (diff)
Create session tab groups in the tab's own window
chrome.tabs.group without createProperties.windowId creates the group in the current (user's) window and moves the tab there, so a session's automation tab left its dedicated window and became a hidden inactive tab. Make the unit mock match Chrome's behavior.
Diffstat (limited to 'test-suite')
-rw-r--r--test-suite/unit/automation-target.test.mjs11
1 files changed, 7 insertions, 4 deletions
diff --git a/test-suite/unit/automation-target.test.mjs b/test-suite/unit/automation-target.test.mjs
index 7f46597..73fbc77 100644
--- a/test-suite/unit/automation-target.test.mjs
+++ b/test-suite/unit/automation-target.test.mjs
@@ -87,14 +87,17 @@ function makeChrome(state, { withWindows = true, withStorage = true, withTabGrou
// Chrome closes a window automatically when its final tab is removed.
if (tab && ![...tabs.values()].some((other) => other.windowId === tab.windowId)) windows.delete(tab.windowId);
},
- group: async ({ groupId, tabIds = [] } = {}) => {
+ // Like Chrome: a new group goes into createProperties.windowId, else the *current* window
+ // (the user's), and grouped tabs move into the group's window.
+ group: async ({ groupId, tabIds = [], createProperties } = {}) => {
let gid = groupId;
if (typeof gid !== "number") {
gid = alloc.group();
- const firstTab = tabs.get(tabIds[0]);
- groups.set(gid, { id: gid, title: "", color: "grey", collapsed: false, windowId: firstTab ? firstTab.windowId : userWindowId });
+ const windowId = typeof createProperties?.windowId === "number" ? createProperties.windowId : userWindowId;
+ groups.set(gid, { id: gid, title: "", color: "grey", collapsed: false, windowId });
}
- for (const tid of tabIds) { const t = tabs.get(tid); if (t) t.groupId = gid; }
+ const groupWindow = groups.get(gid).windowId;
+ for (const tid of tabIds) { const t = tabs.get(tid); if (t) { t.groupId = gid; t.windowId = groupWindow; } }
return gid;
},
ungroup: async (id) => { const ids = Array.isArray(id) ? id : [id]; for (const tid of ids) { const t = tabs.get(tid); if (t) t.groupId = -1; } },