test_bug602838.html (2523B)
1 <!DOCTYPE HTML> 2 <html> 3 <!-- 4 https://bugzilla.mozilla.org/show_bug.cgi?id=602838 5 --> 6 <head> 7 <title>Test for Bug 602838</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> 12 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=602838">Mozilla Bug 602838</a> 13 <p id="display"></p> 14 <div id="content" style="display: none"> 15 16 </div> 17 <pre id="test"> 18 <script id=withasync async></script> 19 <script id=withoutasync></script> 20 <script class="testbody" type="text/javascript"> 21 22 /** Test for Bug 602838 */ 23 SimpleTest.waitForExplicitFinish(); 24 var firstRan = false; 25 var asyncRan = false; 26 27 var withoutasync = document.getElementById("withoutasync"); 28 ok(withoutasync.async, "When a script loses parser-insertedness, it should become async."); 29 30 var withasync = document.getElementById("withasync"); 31 ok(withasync.async, "A script with the async content attribute should have the DOM attribute reporting true."); 32 withasync.removeAttribute("async"); 33 ok(!withasync.async, "Should be able to remove asyncness from a script that had the async content attribute when losing parser-insertedness by removing the content attribute."); 34 35 var s = document.createElement("script"); 36 ok(s.async, "Script-created scripts should default to .async=true"); 37 ok(!s.hasAttribute("async"), "Script-created scripts should not have the async content attribute by default."); 38 s.removeAttribute("async"); 39 ok(s.async, "Removing a non-existing content-attribute should not have an effect on the forced async DOM property."); 40 s.setAttribute("async", ""); 41 ok(s.async, "The async DOM property should still be true."); 42 s.removeAttribute("async"); 43 ok(!s.async, "When a previously present async content attribute is removed, the DOM property should become false."); 44 s.src = "script_bug602838.sjs"; 45 document.body.appendChild(s); 46 47 s = document.createElement("script"); 48 s.src = "data:text/javascript,ok(firstRan, 'The first script should have run'); SimpleTest.finish();"; 49 s.async = false; 50 ok(!s.async, "Setting the async DOM property to false should turned of forcing async to true."); 51 document.body.appendChild(s); 52 53 function unblock() { 54 var xhr = new XMLHttpRequest(); 55 xhr.open("GET", "script_bug602838.sjs?unblock"); 56 xhr.send(); 57 } 58 59 s = document.createElement("script"); 60 s.src = "data:text/javascript,ok(!firstRan, 'Non-async should not have run yet.'); asyncRan = true; unblock();"; 61 document.body.appendChild(s); 62 63 </script> 64 </pre> 65 </body> 66 </html>