diff --git a/src/zen/sessionstore/ZenWindowSync.sys.mjs b/src/zen/sessionstore/ZenWindowSync.sys.mjs index 452ab5fd8..8b74bda90 100644 --- a/src/zen/sessionstore/ZenWindowSync.sys.mjs +++ b/src/zen/sessionstore/ZenWindowSync.sys.mjs @@ -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; diff --git a/src/zen/tests/window_sync/browser_sync_tab_open.js b/src/zen/tests/window_sync/browser_sync_tab_open.js index 7dddf1834..9df69e1a7 100644 --- a/src/zen/tests/window_sync/browser_sync_tab_open.js +++ b/src/zen/tests/window_sync/browser_sync_tab_open.js @@ -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; +});