Created
September 26, 2016 09:14
-
-
Save mikewest/557a0e08dd10bad6854683739492bc0a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<script src="/resources/testharness.js"></script> | |
<script src="/resources/testharnessreport.js"></script> | |
<script> | |
// IDL stuff. | |
test(t => { | |
var i = document.createElement('iframe'); | |
assert_equals("string", i.csp); | |
}, "<iframe> has a 'csp' attibute which is a string."); | |
test(t => { | |
var i = document.createElement('iframe'); | |
i.setAttribute('csp', 'value'); | |
assert_equals('value', i.csp); | |
}, "<iframe> has a 'csp' attibute."); | |
test(t => { | |
var i = document.createElement('iframe'); | |
i.csp = 'value'; | |
assert_equals('value', i.getAttribute('csp')); | |
}, "<iframe> has a 'csp' attibute."); | |
</script> | |
<script> | |
// Loading stuff. | |
async_test(t => { | |
var i = document.createElement('iframe'); | |
i.csp = 'value'; | |
i.src = 'resources/post-header.php'; | |
window.addEventListener('message', t.step_func(e => { | |
if (e.source != i.contentWindow) | |
return; | |
assert_equals('value', e.data['embedding-csp']); | |
t.done(); | |
})); | |
document.body.appendChild('i'); | |
}, "<iframe csp> sends a request header"); | |
</script> | |
// Some other file: | |
<?php | |
$headers = //php goes here; | |
?> | |
<script> | |
var headers = // something something $headers; | |
window.top.postMessage(headers, '*'); | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment