Source code
Revision control
Copy as Markdown
Other Tools
Test Info: Warnings
- This test gets skipped with pattern: http3 OR http2
- Manifest: dom/security/test/csp/mochitest.toml
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<script src="/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
</head>
<body>
<iframe style="width:100%;" id="testframe"></iframe>
<script class="testbody" type="text/javascript">
SimpleTest.waitForExplicitFinish();
/* Description of the test:
* We load a page inlcuding a frame a CSP of:
* and make sure that frame-src governs frames correctly. In addition,
* we make sure that child-src is discarded in case frame-src is specified.
*/
let TESTS = [
// frame-src tests
ORIGIN_1 + "file_frame_src_frame_governs.html",
ORIGIN_2 + "file_frame_src_frame_governs.html",
// child-src tests
ORIGIN_1 + "file_frame_src_child_governs.html",
ORIGIN_2 + "file_frame_src_child_governs.html",
];
let testIndex = 0;
function checkFinish() {
if (testIndex >= TESTS.length) {
window.removeEventListener("message", receiveMessage);
SimpleTest.finish();
return;
}
runNextTest();
}
window.addEventListener("message", receiveMessage);
function receiveMessage(event) {
let href = event.data.href;
let result = event.data.result;
if (result == "frame-allowed") {
}
else {
}
}
if (result == "frame-blocked") {
}
else {
}
}
else {
// sanity check, we should never enter that branch, bust just in case...
ok(false, "unexpected result: " + result);
}
checkFinish();
}
function runNextTest() {
document.getElementById("testframe").src = TESTS[testIndex];
testIndex++;
}
// fire up the tests
runNextTest();
</script>
</body>
</html>