|
1 <!DOCTYPE HTML> |
|
2 <html> |
|
3 <head> |
|
4 <!-- Async script that isn't preloaded --> |
|
5 <script async src="file_bug503481.sjs?blockOn=R&body=runFirst();"></script> |
|
6 <script> |
|
7 firstRan = false; |
|
8 secondRan = false; |
|
9 thirdRan = false; |
|
10 forthRan = false; |
|
11 function runFirst() { |
|
12 firstRan = true; |
|
13 } |
|
14 function runThird() { |
|
15 parent.is(forthRan, false, "forth should still be blocked"); |
|
16 unblock("T"); |
|
17 thirdRan = true; |
|
18 } |
|
19 function runForth() { |
|
20 forthRan = true; |
|
21 } |
|
22 |
|
23 function done() { |
|
24 parent.is(firstRan, true, "first should have run by onload"); |
|
25 parent.is(secondRan, true, "second should have run by onload"); |
|
26 parent.is(thirdRan, true, "third should have run by onload"); |
|
27 parent.is(forthRan, true, "forth should have run by onload"); |
|
28 parent.SimpleTest.finish(); |
|
29 } |
|
30 |
|
31 var reqs = []; |
|
32 function unblock(s) { |
|
33 xhr = new XMLHttpRequest(); |
|
34 xhr.open("GET", "file_bug503481.sjs?unblock=" + s); |
|
35 xhr.send(); |
|
36 reqs.push(xhr); |
|
37 } |
|
38 |
|
39 |
|
40 parent.is(firstRan, false, "First async script shouldn't have run"); |
|
41 unblock("R"); |
|
42 </script> |
|
43 |
|
44 <!-- test that inline async isn't actually async --> |
|
45 <script async> |
|
46 secondRan = true; |
|
47 </script> |
|
48 <script> |
|
49 parent.is(secondRan, true, "Second script shouldn't be async"); |
|
50 </script> |
|
51 |
|
52 <!-- test that setting both defer and async treats the script as async --> |
|
53 <script defer async src="file_bug503481.sjs?blockOn=S&body=runThird();"></script> |
|
54 <script> |
|
55 parent.is(thirdRan, false, "third should not have run yet"); |
|
56 unblock("S"); |
|
57 </script> |
|
58 <script src="file_bug503481.sjs?blockOn=T&body=runForth();"></script> |
|
59 |
|
60 </head> |
|
61 |
|
62 <body onload="done()"> |