diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 00:47:55 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 00:47:55 +0000 |
commit | 26a029d407be480d791972afb5975cf62c9360a6 (patch) | |
tree | f435a8308119effd964b339f76abb83a57c29483 /toolkit/components/extensions/test/xpcshell/test_ext_proxy_containerIsolation.js | |
parent | Initial commit. (diff) | |
download | firefox-26a029d407be480d791972afb5975cf62c9360a6.tar.xz firefox-26a029d407be480d791972afb5975cf62c9360a6.zip |
Adding upstream version 124.0.1.upstream/124.0.1
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" + ); +}); |