1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/content/base/test/test_bug602838.html Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,68 @@ 1.4 +<!DOCTYPE HTML> 1.5 +<html> 1.6 +<!-- 1.7 +https://bugzilla.mozilla.org/show_bug.cgi?id=602838 1.8 +--> 1.9 +<head> 1.10 + <title>Test for Bug 602838</title> 1.11 + <script type="text/javascript" src="/MochiKit/MochiKit.js"></script> 1.12 + <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script> 1.13 + <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" /> 1.14 +</head> 1.15 +<body> 1.16 +<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=602838">Mozilla Bug 602838</a> 1.17 +<p id="display"></p> 1.18 +<div id="content" style="display: none"> 1.19 + 1.20 +</div> 1.21 +<pre id="test"> 1.22 +<script id=withasync async></script> 1.23 +<script id=withoutasync></script> 1.24 +<script class="testbody" type="text/javascript"> 1.25 + 1.26 +/** Test for Bug 602838 **/ 1.27 +SimpleTest.waitForExplicitFinish(); 1.28 +var firstRan = false; 1.29 +var asyncRan = false; 1.30 + 1.31 +var withoutasync = document.getElementById("withoutasync"); 1.32 +ok(withoutasync.async, "When a script loses parser-insertedness, it should become async."); 1.33 + 1.34 +var withasync = document.getElementById("withasync"); 1.35 +ok(withasync.async, "A script with the async content attribute should have the DOM attribute reporting true."); 1.36 +withasync.removeAttribute("async"); 1.37 +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."); 1.38 + 1.39 +var s = document.createElement("script"); 1.40 +ok(s.async, "Script-created scripts should default to .async=true"); 1.41 +ok(!s.hasAttribute("async"), "Script-created scripts should not have the async content attribute by default."); 1.42 +s.removeAttribute("async"); 1.43 +ok(s.async, "Removing a non-existing content-attribute should not have an effect on the forced async DOM property."); 1.44 +s.setAttribute("async", ""); 1.45 +ok(s.async, "The async DOM property should still be true."); 1.46 +s.removeAttribute("async"); 1.47 +ok(!s.async, "When a previously present async content attribute is removed, the DOM property should become false."); 1.48 +s.src = "script_bug602838.sjs"; 1.49 +document.body.appendChild(s); 1.50 + 1.51 +s = document.createElement("script"); 1.52 +s.src = "data:text/javascript,ok(firstRan, 'The first script should have run'); SimpleTest.finish();"; 1.53 +s.async = false; 1.54 +ok(!s.async, "Setting the async DOM property to false should turned of forcing async to true."); 1.55 +document.body.appendChild(s); 1.56 + 1.57 +function unblock() { 1.58 + var xhr = new XMLHttpRequest(); 1.59 + xhr.open("GET", "script_bug602838.sjs?unblock"); 1.60 + xhr.send(); 1.61 +} 1.62 + 1.63 +s = document.createElement("script"); 1.64 +s.src = "data:text/javascript,ok(!firstRan, 'Non-async should not have run yet.'); asyncRan = true; unblock();"; 1.65 +document.body.appendChild(s); 1.66 + 1.67 +</script> 1.68 +</pre> 1.69 +</body> 1.70 +</html> 1.71 +