Skip to content

Commit

Permalink
COOP: test iframe sandbox without allow-same-origin
Browse files Browse the repository at this point in the history
Part of #18354.
  • Loading branch information
zcorpan committed Jan 9, 2020
1 parent 0b7d1a4 commit e280694
Showing 1 changed file with 20 additions and 15 deletions.
35 changes: 20 additions & 15 deletions html/cross-origin-opener-policy/coop-sandbox.https.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,25 @@
<script src="/common/utils.js"></script> <!-- Use token() to allow running tests in parallel -->
<div id=log>
<script>
async_test(t => {
const frame = document.createElement("iframe");
const channel = new BroadcastChannel(token());
channel.onmessage = t.unreached_func("A COOP popup was created from a sandboxed frame");
t.add_cleanup(() => frame.remove());
frame.sandbox = "allow-popups allow-scripts allow-same-origin";
frame.srcdoc = `<script>
const popup = window.open("resources/coop-coep.py?coop=same-origin&coep=&channel=${channel.name}");
<\/script>`;
document.body.append(frame);
window.onload = t.step_func(() => {
t.step_timeout(() => {
t.done()
}, 1500);
});
[
"allow-popups allow-scripts allow-same-origin",
"allow-popups allow-scripts",
].forEach(sandboxValue => {
async_test(t => {
const frame = document.createElement("iframe");
const channel = new BroadcastChannel(token());
channel.onmessage = t.unreached_func("A COOP popup was created from a sandboxed frame");
t.add_cleanup(() => frame.remove());
frame.sandbox = sandboxValue;
frame.srcdoc = `<script>
const popup = window.open("resources/coop-coep.py?coop=same-origin&coep=&channel=${channel.name}");
<\/script>`;
document.body.append(frame);
window.onload = t.step_func(() => {
t.step_timeout(() => {
t.done()
}, 1500);
});
}, `<iframe sandbox="${sandboxValue}"> ${document.title}`);
});
</script>

0 comments on commit e280694

Please sign in to comment.