Source code
Revision control
Copy as Markdown
Other Tools
Test Info: Warnings
- This test gets skipped with pattern: os == 'win' && socketprocess_networking && fission OR os == 'mac' && socketprocess_networking && fission OR os == 'mac' && debug OR os == 'linux' && socketprocess_networking
- Manifest: toolkit/components/extensions/test/xpcshell/xpcshell-remote.toml includes toolkit/components/extensions/test/xpcshell/xpcshell-common.toml
- Manifest: toolkit/components/extensions/test/xpcshell/xpcshell.toml includes toolkit/components/extensions/test/xpcshell/xpcshell-common.toml
"use strict";
const server = createHttpServer({ hosts: ["example.com"] });
server.registerPathHandler("/", (req, res) => {
res.write("ok");
});
add_setup(async () => {
Services.prefs.setBoolPref("extensions.manifestV3.enabled", true);
});
add_task(async function test_csp_upgrade() {
async function background() {
browser.webRequest.onBeforeRequest.addListener(
details => {
browser.test.assertEq(
details.url,
"request upgraded and sent"
);
browser.test.notifyPass();
return { cancel: true };
},
{
},
["blocking"]
);
await browser.test.assertRejects(
"NetworkError when attempting to fetch resource.",
"request was upgraded"
);
}
let extension = ExtensionTestUtils.loadExtension({
background,
temporarilyInstalled: true,
manifest: {
manifest_version: 3,
granted_host_permissions: true,
host_permissions: ["*://example.com/*"],
permissions: ["webRequest", "webRequestBlocking"],
},
});
await extension.startup();
await extension.awaitFinish();
await extension.unload();
});
add_task(async function test_csp_noupgrade() {
async function background() {
browser.test.assertEq(
req.url,
"request not upgraded"
);
browser.test.notifyPass();
}
let extension = ExtensionTestUtils.loadExtension({
background,
temporarilyInstalled: true,
allowInsecureRequests: true,
manifest: {
manifest_version: 3,
granted_host_permissions: true,
host_permissions: ["*://example.com/*"],
},
});
await extension.startup();
await extension.awaitFinish();
await extension.unload();
});