test_bug527896.html (1966B)
1 <!DOCTYPE HTML> 2 <html> 3 <!-- 4 https://bugzilla.mozilla.org/show_bug.cgi?id=527896 5 --> 6 <head> 7 <title>Test for Bug 527896</title> 8 <script src="/tests/SimpleTest/SimpleTest.js"></script> 9 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" /> 10 </head> 11 <body onload='done();'> 12 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=527896">Mozilla Bug 527896</a> 13 <p id="display"></p> 14 <div id="content" style="display: none"> 15 <iframe></iframe> 16 </div> 17 <pre id="test"> 18 <script class="testbody" type="text/javascript"> 19 20 /** Test for Bug 527896 */ 21 22 SimpleTest.waitForExplicitFinish(); 23 24 var docWrittenSrcExecuted = false; 25 var scriptInsertedSrcExecuted = false; 26 27 // the iframe test runs with the HTML5 parser 28 29 var iframe = document.getElementsByTagName('iframe')[0]; 30 iframe.contentWindow.document.open(); 31 iframe.contentWindow.document.write("<!DOCTYPE html>"); 32 iframe.contentWindow.document.write("<body><script id =\"thescript\" src=\"data:text/javascript,parent.docWrittenSrcExecuted = true;\">"); 33 34 // now remove the src attribute before the end tag is parsed 35 iframe.contentWindow.document.getElementById('thescript').removeAttribute('src'); 36 37 iframe.contentWindow.document.write("parent.ok(false, \"Content executed.\");"); 38 iframe.contentWindow.document.write("<\/script>"); 39 iframe.contentWindow.document.close(); 40 41 // the insertion test runs with the default HTML parser since it's in this document itself! 42 43 var div = document.getElementById('content'); 44 var script = document.createElement('script'); 45 div.appendChild(script); // this shouldn't yet freeze the script node nor run it 46 script.setAttribute("src", "data:text/javascript,scriptInsertedSrcExecuted = true;"); 47 48 todo(false, "Add SVG tests after bug 528442."); 49 50 function done() { 51 ok(docWrittenSrcExecuted, "document.written src didn't execute"); 52 ok(scriptInsertedSrcExecuted, "script-inserted src didn't execute"); 53 54 SimpleTest.finish(); 55 } 56 57 </script> 58 </pre> 59 </body> 60 </html>