diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
commit | 36d22d82aa202bb199967e9512281e9a53db42c9 (patch) | |
tree | 105e8c98ddea1c1e4784a60a5a6410fa416be2de /toolkit/components/extensions/test/xpcshell/test_ext_proxy_containerIsolation.js | |
parent | Initial commit. (diff) | |
download | firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.tar.xz firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.zip |
Adding upstream version 115.7.0esr.upstream/115.7.0esr
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'toolkit/components/extensions/test/xpcshell/test_ext_proxy_containerIsolation.js')
-rw-r--r-- | toolkit/components/extensions/test/xpcshell/test_ext_proxy_containerIsolation.js | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/toolkit/components/extensions/test/xpcshell/test_ext_proxy_containerIsolation.js b/toolkit/components/extensions/test/xpcshell/test_ext_proxy_containerIsolation.js new file mode 100644 index 0000000000..9a375f68a9 --- /dev/null +++ b/toolkit/components/extensions/test/xpcshell/test_ext_proxy_containerIsolation.js @@ -0,0 +1,59 @@ +"use strict"; + +const server = createHttpServer({ hosts: ["example.com"] }); + +server.registerPathHandler("/dummy", (request, response) => { + response.setStatusLine(request.httpVersion, 200, "OK"); + response.setHeader("Content-Type", "text/html", false); + response.write("<!DOCTYPE html><html></html>"); +}); + +add_task(async function test_userContextId_proxy() { + Services.prefs.setBoolPref("extensions.userContextIsolation.enabled", true); + let extension = ExtensionTestUtils.loadExtension({ + manifest: { + permissions: ["proxy", "<all_urls>"], + }, + background() { + browser.proxy.onRequest.addListener( + async details => { + browser.test.assertEq( + "firefox-container-2", + details.cookieStoreId, + "cookieStoreId is set" + ); + browser.test.notifyPass("allowed"); + }, + { urls: ["http://example.com/dummy"] } + ); + }, + }); + + Services.prefs.setCharPref( + "extensions.userContextIsolation.defaults.restricted", + "[1]" + ); + await extension.startup(); + + let restrictedPage = await ExtensionTestUtils.loadContentPage( + "http://example.com/dummy", + { userContextId: 1 } + ); + + let allowedPage = await ExtensionTestUtils.loadContentPage( + "http://example.com/dummy", + { + userContextId: 2, + } + ); + await extension.awaitFinish("allowed"); + + await extension.unload(); + await restrictedPage.close(); + await allowedPage.close(); + + Services.prefs.clearUserPref("extensions.userContextIsolation.enabled"); + Services.prefs.clearUserPref( + "extensions.userContextIsolation.defaults.restricted" + ); +}); |