diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 17:32:43 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 17:32:43 +0000 |
commit | 6bf0a5cb5034a7e684dcc3500e841785237ce2dd (patch) | |
tree | a68f146d7fa01f0134297619fbe7e33db084e0aa /browser/components/contextualidentity/test/browser/browser_count_and_remove.js | |
parent | Initial commit. (diff) | |
download | thunderbird-6bf0a5cb5034a7e684dcc3500e841785237ce2dd.tar.xz thunderbird-6bf0a5cb5034a7e684dcc3500e841785237ce2dd.zip |
Adding upstream version 1:115.7.0.upstream/1%115.7.0upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'browser/components/contextualidentity/test/browser/browser_count_and_remove.js')
-rw-r--r-- | browser/components/contextualidentity/test/browser/browser_count_and_remove.js | 107 |
1 files changed, 107 insertions, 0 deletions
diff --git a/browser/components/contextualidentity/test/browser/browser_count_and_remove.js b/browser/components/contextualidentity/test/browser/browser_count_and_remove.js new file mode 100644 index 0000000000..8f044db94e --- /dev/null +++ b/browser/components/contextualidentity/test/browser/browser_count_and_remove.js @@ -0,0 +1,107 @@ +/* Any copyright is dedicated to the Public Domain. + * http://creativecommons.org/publicdomain/zero/1.0/ */ + +function openTabInUserContext(userContextId) { + let tab = BrowserTestUtils.addTab(gBrowser, "about:blank", { userContextId }); + gBrowser.selectedTab = tab; +} + +add_setup(async function () { + // make sure userContext is enabled. + await SpecialPowers.pushPrefEnv({ + set: [["privacy.userContext.enabled", true]], + }); +}); + +add_task(async function test() { + is( + ContextualIdentityService.countContainerTabs(), + 0, + "0 container tabs by default." + ); + + openTabInUserContext(1); + is( + ContextualIdentityService.countContainerTabs(), + 1, + "1 container tab created" + ); + is( + ContextualIdentityService.countContainerTabs(1), + 1, + "1 container tab created with id 1" + ); + is( + ContextualIdentityService.countContainerTabs(2), + 0, + "0 container tabs created with id 2" + ); + + openTabInUserContext(1); + is( + ContextualIdentityService.countContainerTabs(), + 2, + "2 container tabs created" + ); + is( + ContextualIdentityService.countContainerTabs(1), + 2, + "2 container tabs created with id 1" + ); + is( + ContextualIdentityService.countContainerTabs(2), + 0, + "0 container tabs created with id 2" + ); + + openTabInUserContext(2); + is( + ContextualIdentityService.countContainerTabs(), + 3, + "3 container tab created" + ); + is( + ContextualIdentityService.countContainerTabs(1), + 2, + "2 container tabs created with id 1" + ); + is( + ContextualIdentityService.countContainerTabs(2), + 1, + "1 container tab created with id 2" + ); + + await ContextualIdentityService.closeContainerTabs(1); + is( + ContextualIdentityService.countContainerTabs(), + 1, + "1 container tab created" + ); + is( + ContextualIdentityService.countContainerTabs(1), + 0, + "0 container tabs created with id 1" + ); + is( + ContextualIdentityService.countContainerTabs(2), + 1, + "1 container tab created with id 2" + ); + + await ContextualIdentityService.closeContainerTabs(); + is( + ContextualIdentityService.countContainerTabs(), + 0, + "0 container tabs at the end." + ); + is( + ContextualIdentityService.countContainerTabs(1), + 0, + "0 container tabs at the end with id 1." + ); + is( + ContextualIdentityService.countContainerTabs(2), + 0, + "0 container tabs at the end with id 2." + ); +}); |