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 tsan OR os == 'linux' && socketprocess_networking
- Manifest: toolkit/components/extensions/test/xpcshell/xpcshell-remote.toml
"use strict";
const server = createHttpServer({
hosts: ["a.example.com", "b.example.com", "c.example.com"],
});
server.registerDirectory("/data/", do_get_file("data"));
add_task(async function test_perf_observers_cors() {
const extension = ExtensionTestUtils.loadExtension({
manifest: {
content_scripts: [
{
js: ["cs.js"],
},
],
},
files: {
"cs.js"() {
let obs = new window.PerformanceObserver(list => {
list.getEntries().forEach(e => {
browser.test.sendMessage("observed", {
url: e.name,
time: e.connectEnd,
size: e.encodedBodySize,
});
});
});
obs.observe({ entryTypes: ["resource"] });
let b = document.createElement("link");
b.rel = "stylesheet";
// Simulate page including a cross-origin resource from b.example.com.
document.head.appendChild(b);
let c = document.createElement("link");
c.rel = "stylesheet";
// Simulate page including a cross-origin resource from c.example.com.
document.head.appendChild(c);
},
},
});
let page = await ExtensionTestUtils.loadContentPage(
);
await extension.startup();
let b = await extension.awaitMessage("observed");
let c = await extension.awaitMessage("observed");
[c, b] = [b, c];
}
Assert.greater(b.time, 0, "connectionEnd available from b.example.com");
equal(b.size, 46, "encodedBodySize available from b.example.com");
equal(c.time, 0, "connectionEnd == 0 from c.example.com");
equal(c.size, 0, "encodedBodySize == 0 from c.example.com");
await extension.unload();
await page.close();
});