From 6bf0a5cb5034a7e684dcc3500e841785237ce2dd Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 7 Apr 2024 19:32:43 +0200 Subject: Adding upstream version 1:115.7.0. Signed-off-by: Daniel Baumann --- .../test/browser/browser_count_and_remove.js | 107 +++++++++++++++++++++ 1 file changed, 107 insertions(+) create mode 100644 browser/components/contextualidentity/test/browser/browser_count_and_remove.js (limited to 'browser/components/contextualidentity/test/browser/browser_count_and_remove.js') 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." + ); +}); -- cgit v1.2.3