blob: 7135efa2503dcd7d87aa24fafbe896728763e02e [file] [log] [blame] [edit]
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Sandbox Navigation Timing</title>
<script src=/resources/testharness.js></script>
<script src=/resources/testharnessreport.js></script>
</head>
<body>
<script>
async_test(t => {
const iframe = document.createElement('iframe');
iframe.srcdoc = "<scr" + "ipt>try{parent.document.body;" +
"parent.postMessage(\"Not sandboxed\",\"*\")}catch(e){" +
"parent.postMessage(\"Sandboxed\",\"*\")}</scr" + "ipt>";
// Construction of the srcdoc document should be initiated here. The value
// of the sandbox attribute should be snapshotted.
document.body.appendChild(iframe);
// Manipulating the sandbox attribute at this point should not affect the
// sandbox flags used for the document in the iframe.
iframe.sandbox = 'allow-scripts';
// After navigation, child frame should not be sandboxed.
window.onmessage = t.step_func_done(e => {
assert_equals(e.data, 'Not sandboxed');
});
}, "setting sandbox attribute after iframe is attached to document should" +
" not affect document in srcdoc iframe.");
</script>
</body>
</html>