async_004.htm (1455B)
1 <!DOCTYPE html> 2 <html> 3 <head> 4 <title>An async script executes as soon as possible after a download is complete</title> 5 <meta name="timeout" content="long"> 6 <meta http-equiv="content-type" content="text/html; charset=UTF-8" /> 7 <meta description="This test ensures an async script executes as soon as possible after a download is complete." /> 8 <link rel="author" title="Microsoft" href="http://www.microsoft.com/" /> 9 <link rel="help" href="https://html.spec.whatwg.org/multipage/#attr-script-async"/> 10 <script src="/resources/testharness.js"></script> 11 <script src="/resources/testharnessreport.js"></script> 12 </head> 13 <body> 14 <div id=log></div> 15 <script type="text/javascript"> 16 var t = async_test("async script executes as soon as possible after a download is complete"); 17 18 function timeout() 19 { 20 t.step(function(){ assert_equals(document.getElementById("testresult").innerHTML, "21")}); 21 t.done(); 22 } 23 24 var timer = setTimeout(timeout, 4000); 25 26 function log(text) 27 { 28 var textNode = document.createTextNode(text); 29 document.getElementById("testresult").appendChild(textNode); 30 } 31 </script> 32 33 <span id="testresult"></span> 34 35 <script src="log.py?sec=3&id=1" async></script> 36 <script src="log.py?sec=1&id=2" async></script> 37 </body> 38 </html>