1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/content/base/test/test_bug503481.html Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,69 @@ 1.4 +<!DOCTYPE HTML> 1.5 +<html> 1.6 +<!-- 1.7 +https://bugzilla.mozilla.org/show_bug.cgi?id=503481 1.8 +--> 1.9 +<head> 1.10 + <title>Test for Bug 503481</title> 1.11 + <script src="/tests/SimpleTest/SimpleTest.js"></script> 1.12 + <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" /> 1.13 +</head> 1.14 +<body onload="done();"> 1.15 + 1.16 +<a href="https://bugzilla.mozilla.org/show_bug.cgi?id=503481" 1.17 + target="_blank" >Mozilla Bug 503481</a> 1.18 + 1.19 +<p id="display"></p> 1.20 + 1.21 +<script> 1.22 +SimpleTest.waitForExplicitFinish(); 1.23 +function done() { 1.24 + is(firstRan, true, "first has run"); 1.25 + is(secondRan, true, "second has run"); 1.26 + is(thirdRan, true, "third has run"); 1.27 + SimpleTest.finish(); 1.28 +} 1.29 +var reqs = []; 1.30 +function unblock(s) { 1.31 + xhr = new XMLHttpRequest(); 1.32 + xhr.open("GET", "file_bug503481.sjs?unblock=" + s); 1.33 + xhr.send(); 1.34 + reqs.push(xhr); 1.35 +} 1.36 +var firstRan = false, secondRan = false, thirdRan = false; 1.37 +function runFirst() { firstRan = true; } 1.38 +function runSecond() { 1.39 + is(thirdRan, true, "should have run third already"); 1.40 + secondRan = true; 1.41 +} 1.42 +function runThird() { 1.43 + is(secondRan, false, "shouldn't have unblocked second yet"); 1.44 + thirdRan = true; 1.45 + unblock("B"); 1.46 +} 1.47 +</script> 1.48 +<script id=firstScript async src="file_bug503481.sjs?blockOn=A&body=runFirst();"></script> 1.49 +<script id=firstScriptHelper> 1.50 +is(document.getElementById("firstScript").async, true, 1.51 + "async set"); 1.52 +is(document.getElementById("firstScriptHelper").async, false, 1.53 + "async not set"); 1.54 +document.getElementById("firstScript").async = false; 1.55 +is(document.getElementById("firstScript").async, false, 1.56 + "async no longer set"); 1.57 +is(document.getElementById("firstScript").hasAttribute("async"), false, 1.58 + "async attribute no longer set"); 1.59 +is(firstRan, false, "First async script shouldn't have run"); 1.60 +unblock("A"); 1.61 +</script> 1.62 + 1.63 +<script async src="file_bug503481.sjs?blockOn=B&body=runSecond();"></script> 1.64 +<script async src="file_bug503481.sjs?blockOn=C&body=runThird();"></script> 1.65 +<script> 1.66 +is(secondRan, false, "Second async script shouldn't have run"); 1.67 +is(thirdRan, false, "Third async script shouldn't have run"); 1.68 +unblock("C"); 1.69 +</script> 1.70 + 1.71 +</body> 1.72 +</html>