tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

async_010.htm (2137B)


      1 <!DOCTYPE html>
      2 <html>
      3    <head>
      4        <title>Removing an async script before execution</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 that an async script still executes if it is removed from a markup before the download is complete. The other two scripts that come after it in insertion order should execute as well." />
      8        <link rel="author" title="Microsoft" href="http://www.microsoft.com/" />
      9        <link rel="help" href="https://html.spec.whatwg.org/multipage/#execute-the-script-block"/>
     10        <script src="/resources/testharness.js"></script>
     11        <script src="/resources/testharnessreport.js"></script>
     12        <script type="text/javascript">
     13        var t = async_test("Removing an async script before execution");
     14 
     15        function timeout()
     16        {
     17            t.step(function(){ assert_equals(document.getElementById("testresult").innerHTML, "4123")});
     18            t.done();
     19        }
     20 
     21        var timer = setTimeout(timeout, 8000);
     22 
     23        function log(text)
     24        {
     25            var textNode = document.createTextNode(text);
     26            document.getElementById("testresult").appendChild(textNode);
     27        }
     28        </script>
     29    </head>
     30    <body>
     31        <div id=log></div>
     32        <span id="testresult"></span>
     33        <script type="text/javascript">
     34            var s1 = document.createElement("script");
     35            s1.src="log.py?sec=2&id=1";
     36            s1.async = false;
     37            document.body.appendChild(s1);
     38 
     39            var s2 = document.createElement("script");
     40            s2.src="log.py?sec=1&id=2";
     41            s2.async = false;
     42            document.body.appendChild(s2);
     43 
     44            var s3 = document.createElement("script");
     45            s3.id = "s3";
     46            s3.src="log.py?sec=0&id=3";
     47            s3.async = false;
     48            document.body.appendChild(s3);
     49 
     50            //Remove s1 (Should still execute)
     51            document.body.removeChild(s1);
     52        </script>
     53        <script type="text/javascript">log('4');</script>
     54    </body>
     55 </html>