summaryrefslogtreecommitdiffstats
path: root/toolkit/components/extensions/test/xpcshell/test_ext_proxy_containerIsolation.js
diff options
context:
space:
mode:
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.js59
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"
+ );
+});