iframe_remove_src.html (1499B)
1 <!DOCTYPE html> 2 <meta charset=utf-8> 3 <title>Test that removing the src attribute of an iframe loads about:blank 4 instead of whatever was loaded previously.</title> 5 <script src="/resources/testharness.js"></script> 6 <script src="/resources/testharnessreport.js"></script> 7 <body> 8 <script> 9 var iframe; 10 var t = async_test(); 11 t.step(setupFrame); 12 13 function setupFrame() { 14 iframe = document.createElement("iframe"); 15 iframe.src = URL.createObjectURL(new Blob(["text"], { type: "text/html" })); 16 iframe.onload = t.step_func(blobLoaded); 17 document.body.appendChild(iframe); 18 } 19 20 var removalRunning = false; 21 function blobLoaded() { 22 assert_equals(iframe.contentDocument.location.protocol, "blob:", 23 "Should have loaded the blob"); 24 assert_equals(iframe.contentDocument.documentElement.textContent, "text", 25 "Should have loaded the blob text"); 26 iframe.onload = t.step_func_done(aboutBlankLoaded); 27 removalRunning = true; 28 iframe.removeAttribute("src"); 29 removalRunning = false; 30 } 31 32 function aboutBlankLoaded() { 33 assert_false(removalRunning, "Should not have loaded about:blank sync"); 34 assert_equals(iframe.contentDocument.location.href, "about:blank", 35 "Should have loaded about:blank"); 36 assert_equals(iframe.contentDocument.documentElement.textContent, "", 37 "Should have loaded the about:blank text"); 38 } 39 </script> 40 </body>