content/base/test/test_bug503481.html

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

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

mercurial