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