allow-scripts-flag-changing-2.html (1464B)
1 <!DOCTYPE html> 2 <meta charset="utf-8"> 3 <title>Meta refresh of the original iframe is not blocked if moved into a sandboxed iframe</title> 4 <script src="/resources/testharness.js"></script> 5 <script src="/resources/testharnessreport.js"></script> 6 <link rel="help" href="https://html.spec.whatwg.org/multipage/semantics.html#attr-meta-http-equiv-refresh"> 7 8 <div id="log"></div> 9 10 <script> 11 "use strict"; 12 setup({ single_test: true }); 13 14 const sourceIFrame = document.createElement("iframe"); 15 16 const destIFrame = document.createElement("iframe"); 17 destIFrame.setAttribute("sandbox", "allow-same-origin"); 18 19 let sourceLoadCount = 0; 20 let destLoadCount = 0; 21 22 sourceIFrame.onload = () => { 23 ++sourceLoadCount; 24 25 if (sourceLoadCount === 2) { 26 assert_equals(sourceIFrame.contentDocument.body.textContent.trim(), "foo"); 27 done(); 28 } 29 30 maybeStartTest(); 31 }; 32 33 destIFrame.onload = () => { 34 ++destLoadCount; 35 36 if (destLoadCount === 2) { 37 assert_unreached("The iframe into which the meta was moved must not refresh"); 38 } 39 40 maybeStartTest(); 41 }; 42 43 function maybeStartTest() { 44 if (sourceLoadCount === 1 && destLoadCount === 1) { 45 const meta = sourceIFrame.contentDocument.querySelector("meta"); 46 destIFrame.contentDocument.body.appendChild(meta); 47 } 48 } 49 50 sourceIFrame.src = "support/refresh.sub.html?input=" + encodeURIComponent("1; url=foo"); 51 destIFrame.src = "support/ufoo"; 52 53 document.body.appendChild(sourceIFrame); 54 document.body.appendChild(destIFrame); 55 </script>