gh-14905: Inherit context IDs when syncing tabs (gh-14908)

This commit is contained in:
mr. m
2026-08-10 13:56:48 +02:00
committed by GitHub
parent f2a2f7188b
commit b7439a92dc
2 changed files with 39 additions and 0 deletions

View File

@@ -1373,6 +1373,7 @@ class nsZenWindowSync {
const newTab = win.gBrowser.addTrustedTab("about:blank", {
animate: true,
createLazyBrowser: true,
userContextId: tab.userContextId,
_forZenEmptyTab: tab.hasAttribute("zen-empty-tab"),
});
newTab.id = tab.id;

View File

@@ -16,3 +16,41 @@ add_task(async function test_SimpleTabOpen() {
);
});
});
add_task(async function test_TabOpenInContainer() {
await SpecialPowers.pushPrefEnv({
set: [["privacy.userContext.enabled", true]],
});
let newTab = null;
await withNewSyncedWindow(async win => {
await runSyncAction(
() => {
newTab = gBrowser.addTrustedTab("https://example.com/", {
inBackground: true,
userContextId: 1,
});
},
async () => {
Assert.equal(
newTab.userContextId,
1,
"The opened tab should keep its container"
);
const otherTab = gZenWindowSync.getItemFromWindow(win, newTab.id);
Assert.ok(
otherTab,
"The opened tab should be found in the synced window"
);
Assert.equal(
otherTab.userContextId,
newTab.userContextId,
"The synced tab should inherit the original tab's container"
);
},
"TabOpen"
);
});
let tabClosing = BrowserTestUtils.waitForTabClosing(newTab);
BrowserTestUtils.removeTab(newTab);
await tabClosing;
});