Bug 1024557 - Test XFO is ignored when frame-ancestors is present. r=smaug

This commit is contained in:
Christoph Kerschbaumer 2017-06-07 10:12:55 +02:00
parent 632fd14dfa
commit 0d10a7c233
6 changed files with 90 additions and 0 deletions

View File

@ -0,0 +1,10 @@
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<title>Bug 1024557: Ignore x-frame-options if CSP with frame-ancestors exists</title>
</head>
<body>
<div id="cspmessage">Ignoring XFO because of CSP</div>
</body>
</html>

View File

@ -0,0 +1,3 @@
Content-Security-Policy: frame-ancestors http://mochi.test:8888
X-Frame-Options: deny
Cache-Control: no-cache

View File

@ -0,0 +1,10 @@
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<title>Bug 1024557: Ignore x-frame-options if CSP with frame-ancestors exists</title>
</head>
<body>
<div id="cspmessage">Ignoring XFO because of CSP_RO</div>
</body>
</html>

View File

@ -0,0 +1,3 @@
Content-Security-Policy-Report-Only: frame-ancestors http://mochi.test:8888
X-Frame-Options: deny
Cache-Control: no-cache

View File

@ -213,6 +213,10 @@ support-files =
file_websocket_self_wsh.py
file_image_nonce.html
file_image_nonce.html^headers^
file_ignore_xfo.html
file_ignore_xfo.html^headers^
file_ro_ignore_xfo.html
file_ro_ignore_xfo.html^headers^
[test_base-uri.html]
[test_blob_data_schemes.html]
@ -306,3 +310,4 @@ tags = mcb
[test_image_nonce.html]
[test_websocket_self.html]
skip-if = toolkit == 'android'
[test_ignore_xfo.html]

View File

@ -0,0 +1,59 @@
<!DOCTYPE HTML>
<html>
<head>
<title>Bug 1024557: Ignore x-frame-options if CSP with frame-ancestors exists</title>
<!-- Including SimpleTest.js so we can use waitForExplicitFinish !-->
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
</head>
<body>
<iframe style="width:100%;" id="csp_testframe"></iframe>
<iframe style="width:100%;" id="csp_ro_testframe"></iframe>
<script class="testbody" type="text/javascript">
/*
* We load two frames using:
* x-frame-options: deny
* where the first frame uses a csp and the second a csp_ro including frame-ancestors.
* We make sure that xfo is ignored for regular csp but not for csp_ro.
*/
SimpleTest.waitForExplicitFinish();
var testcounter = 0;
function checkFinished() {
testcounter++;
if (testcounter < 2) {
return;
}
SimpleTest.finish();
}
// 1) test XFO with CSP
var csp_testframe = document.getElementById("csp_testframe");
csp_testframe.onload = function() {
var msg = csp_testframe.contentWindow.document.getElementById("cspmessage");
is(msg.innerHTML, "Ignoring XFO because of CSP", "Loading frame with with XFO and CSP");
checkFinished();
}
csp_testframe.onerror = function() {
ok(false, "sanity: should not fire onerror for csp_testframe");
}
csp_testframe.src = "file_ignore_xfo.html";
// 2) test XFO with CSP_RO
var csp_ro_testframe = document.getElementById("csp_ro_testframe");
csp_ro_testframe.onload = function() {
var msg = csp_ro_testframe.contentWindow.document.getElementById("cspmessage");
is(msg, null, "Blocking frame with with XFO and CSP_RO");
checkFinished();
}
csp_ro_testframe.onerror = function() {
ok(false, "sanity: should not fire onerror for csp_ro_testframe");
}
csp_ro_testframe.src = "file_ro_ignore_xfo.html";
</script>
</body>
</html>