iframe_003.html (1053B)
1 <!doctype html> 2 <title>document.write script 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 = "<script>document.write(\"<i id='a'>Filler Text</i>\")</script" + "><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 //Note: <script> ends up in <head> 15 assert_equals(iframe.contentDocument.body.childNodes[0].textContent, "Filler Text"); 16 assert_equals(iframe.contentDocument.body.childNodes[0].localName, "i"); 17 assert_equals(iframe.contentDocument.body.childNodes[0].getAttribute('id'), "a"); 18 assert_equals(iframe.contentDocument.body.childNodes[1].textContent, "Filler Text"); 19 assert_equals(iframe.contentDocument.body.childNodes[1].localName, "b"); 20 assert_equals(iframe.contentDocument.body.childNodes[1].getAttribute('id'), "b"); 21 }); 22 </script> 23 <div id="log"></div>