srcdoc-attribute-reset.html (1380B)
1 <title>Verify that clearing srcdoc resets the iframe's content.</title> 2 <link rel="help" href="https://html.spec.whatwg.org/multipage/iframe-embed-object.html#process-the-iframe-attributes"> 3 <link rel="author" title="James MacLean" href="mailto:wjmaclean@chromium.org"> 4 <script src="/resources/testharness.js"></script> 5 <script src="/resources/testharnessreport.js"></script> 6 7 <iframe id=myframe srcdoc='srcdoc_text'></iframe> 8 <script> 9 'use strict'; 10 11 async_test(function(t) { 12 window.onload = () => { 13 // Verify that the srcdoc content is loaded before we start. 14 t.step(() => { 15 assert_true(typeof myframe.contentDocument !== 'undefined', 16 'iframe has contentDocument'); 17 assert_equals(myframe.contentDocument.body.innerText, 'srcdoc_text', 18 'iframe contains srcdoc content'); 19 }); 20 21 myframe.onload = t.step_func_done(function() { 22 assert_true(typeof myframe.contentDocument !== 'undefined', 23 'iframe has contentDocument'); 24 assert_equals(myframe.contentDocument.body.innerText, '', 25 'iframe content is empty'); 26 }); 27 28 // Don't remove srcdoc until the initial load has completed, and the 29 // frame's onload handler is in place. 30 myframe.removeAttribute('srcdoc'); 31 }; 32 }, 'Verify that the frame reloads with empty body after we remove srcdoc.'); 33 </script>