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 OR appname == 'thunderbird'
- This test failed 1 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 HOSTS = new Set(["example.com"]);
const server = createHttpServer({ hosts: HOSTS });
server.registerPathHandler("/dummy", (request, response) => {
response.setStatusLine(request.httpVersion, 200, "OK");
response.write("ok");
});
add_task(async function test_webSocket() {
let extension = ExtensionTestUtils.loadExtension({
manifest: {
permissions: ["webRequest", "webRequestBlocking", "<all_urls>"],
},
background() {
browser.webRequest.onBeforeRequest.addListener(
details => {
browser.test.assertEq(
"ws:",
new URL(details.url).protocol,
"ws protocol worked"
);
browser.test.notifyPass("websocket");
},
["blocking"]
);
browser.test.onMessage.addListener(() => {
ws.onopen = () => {
ws.send("data");
};
ws.onclose = () => {};
ws.onerror = () => {};
ws.onmessage = () => {
ws.close();
};
});
browser.test.sendMessage("ready");
},
});
await extension.startup();
await extension.awaitMessage("ready");
extension.sendMessage("go");
await extension.awaitFinish("websocket");
// Wait until the next tick so that listener responses are processed
// before we unload.
await new Promise(executeSoon);
await extension.unload();
});