iframe_002.html (967B)
1 <!doctype html> 2 <title>document.write into iframe</title> 3 <script src="/resources/testharness.js"></script><script src="/resources/testharnessreport.js"></script> 4 <iframe id="test"></iframe> 5 <script> 6 test( 7 function() { 8 var iframe = document.getElementById("test"); 9 var s = "<i id='a'>Filler Text</i><b id=b>Filler Text</b>" 10 for (var i=0; i<s.length; i++) { 11 iframe.contentDocument.write(s[i]); 12 } 13 iframe.contentDocument.close(); 14 assert_equals(iframe.contentDocument.body.childNodes[0].textContent, "Filler Text"); 15 assert_equals(iframe.contentDocument.body.childNodes[0].localName, "i"); 16 assert_equals(iframe.contentDocument.body.childNodes[0].getAttribute('id'), "a"); 17 assert_equals(iframe.contentDocument.body.childNodes[1].textContent, "Filler Text"); 18 assert_equals(iframe.contentDocument.body.childNodes[1].localName, "b"); 19 assert_equals(iframe.contentDocument.body.childNodes[1].getAttribute('id'), "b"); 20 }); 21 </script> 22 <div id="log"></div>