Source code
Revision control
Copy as Markdown
Other Tools
Test Info: Errors
- 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
- This test failed 3 times in the preceding 30 days. quicksearch this test
- 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("/HELLO", (req, res) => {
res.write("BYE");
});
add_task(async function request_from_extension_page() {
let extension = ExtensionTestUtils.loadExtension({
manifest: {
},
files: {
"tab.html": `<!DOCTYPE html><script src="tab.js"></script>`,
"tab.js": async function () {
browser.webRequest.onHeadersReceived.addListener(
details => {
let { responseHeaders } = details;
responseHeaders.push({
name: "X-Added-by-Test",
value: "TheValue",
});
return { responseHeaders };
},
{
},
["blocking", "responseHeaders"]
);
await browser.runtime.getPlatformInfo();
browser.test.assertEq(
"TheValue",
response.headers.get("X-added-by-test"),
"expected response header from webRequest listener"
);
browser.test.assertEq(
await response.text(),
"BYE",
"Expected response from server"
);
browser.test.sendMessage("done");
},
},
});
await extension.startup();
let contentPage = await ExtensionTestUtils.loadContentPage(
{ extension }
);
await extension.awaitMessage("done");
await contentPage.close();
await extension.unload();
});