sandbox-navigation-timing.tentative.html (1320B)
1 <!DOCTYPE html> 2 <meta charset="utf-8"> 3 <title>Sandbox Navigation Timing</title> 4 <script src=/resources/testharness.js></script> 5 <script src=/resources/testharnessreport.js></script> 6 <html></html> 7 <script> 8 const sandboxUrl = location.pathname.substring(0, location.pathname.lastIndexOf('/') + 1) + 'sandbox-navigation-timing-iframe.tentative.html'; 9 async_test(t => { 10 const iframe = document.createElement('iframe'); 11 iframe.src = sandboxUrl; 12 document.body.appendChild(iframe); // Navigation starts; value of sandbox flags locked on. 13 // This should not affect the sandbox value used for both about:blank document 14 // and the final document in iframe. 15 iframe.sandbox = 'allow-scripts'; 16 const iframeAboutBlankDocument = iframe.contentDocument; 17 18 iframe.onload = t.step_func(() => { 19 const iframeAboutBlankContents = iframeAboutBlankDocument.querySelectorAll('body'); 20 assert_equals(iframeAboutBlankContents[0].tagName, "BODY", 21 "about:blank document's contents should still be accessible"); 22 23 iframe.contentWindow.postMessage("is iframe sandboxed?", "*"); 24 }); 25 window.onmessage = t.step_func_done(e => { 26 assert_equals(e.data.result, 'iframe not sandboxed'); 27 }); 28 }, 'setting sandbox attribute should not affect current document in iframe'); 29 </script>