test_bug503481.html (2057B)
1 <!DOCTYPE HTML> 2 <html> 3 <!-- 4 https://bugzilla.mozilla.org/show_bug.cgi?id=503481 5 --> 6 <head> 7 <title>Test for Bug 503481</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 13 <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=503481" 14 target="_blank" >Mozilla Bug 503481</a> 15 16 <p id="display"></p> 17 18 <script> 19 SimpleTest.waitForExplicitFinish(); 20 function done() { 21 is(firstRan, true, "first has run"); 22 is(secondRan, true, "second has run"); 23 is(thirdRan, true, "third has run"); 24 SimpleTest.finish(); 25 } 26 var reqs = []; 27 function unblock(s) { 28 xhr = new XMLHttpRequest(); 29 xhr.open("GET", "file_bug503481.sjs?unblock=" + s); 30 xhr.send(); 31 reqs.push(xhr); 32 } 33 var firstRan = false, secondRan = false, thirdRan = false; 34 function runFirst() { firstRan = true; } 35 function runSecond() { 36 is(thirdRan, true, "should have run third already"); 37 secondRan = true; 38 } 39 function runThird() { 40 is(secondRan, false, "shouldn't have unblocked second yet"); 41 thirdRan = true; 42 unblock("B"); 43 } 44 </script> 45 <script id=firstScript async src="file_bug503481.sjs?blockOn=A&body=runFirst();"></script> 46 <script id=firstScriptHelper> 47 is(document.getElementById("firstScript").async, true, 48 "async set"); 49 is(document.getElementById("firstScriptHelper").async, false, 50 "async not set"); 51 document.getElementById("firstScript").async = false; 52 is(document.getElementById("firstScript").async, false, 53 "async no longer set"); 54 is(document.getElementById("firstScript").hasAttribute("async"), false, 55 "async attribute no longer set"); 56 is(firstRan, false, "First async script shouldn't have run"); 57 unblock("A"); 58 </script> 59 60 <script async src="file_bug503481.sjs?blockOn=B&body=runSecond();"></script> 61 <script async src="file_bug503481.sjs?blockOn=C&body=runThird();"></script> 62 <script> 63 is(secondRan, false, "Second async script shouldn't have run"); 64 is(thirdRan, false, "Third async script shouldn't have run"); 65 unblock("C"); 66 </script> 67 68 </body> 69 </html>