tor-browser

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

050.html (2331B)


      1 <!DOCTYPE html>
      2 <html><head>
      3        <title> scheduler: adding external script that removes all scripts from document</title>
      4        <meta name="timeout" content="long">
      5        <script src="/resources/testharness.js"></script>
      6        <script src="/resources/testharnessreport.js"></script>
      7        <script src="testlib/testlib.js"></script>
      8 </head>
      9 <body>
     10 
     11        <div id="log">FAILED (This TC requires JavaScript enabled)</div>
     12 
     13        <script>log('inline script #1');
     14                var script=testlib.addScript('', { src:'scripts/include-5.js' }, document.getElementsByTagName('head')[0], false );
     15                // caching might affect whether the below script runs or not. Adding Math.random() makes the test a bit more predictable? :-p
     16                var script=testlib.addScript('', { src:'scripts/include-1.js?pipe=trickle(d1)&'+Math.random() }, document.getElementsByTagName('head')[0], false );
     17                log('end script #1');
     18        </script>
     19        <script src="scripts/include-2.js?pipe=trickle(d4)"></script>
     20        <script type="text/javascript">
     21        var t = async_test()
     22 
     23        function test() {
     24            // Per-spec, non-blocking/async scripts can execute at any time.
     25            // Therefore, there are two possibilities for the script order here.
     26            // 1. inline script first, followed by include-5 (async), then
     27            //    external script #1 (slow async) and finally external #2
     28            //    (inline).
     29            // 2. inline script, external '2, 'include 5', then include-1.
     30            assert_array_equals(eventOrder.slice(0, 2), [
     31                'inline script #1', 'end script #1'
     32            ]);
     33            if (eventOrder[2] == 'include-5 before removing scripts') {
     34                assert_array_equals(eventOrder.slice(3), [
     35                    'include-5 after removing scripts', 'external script #1',
     36                    'external script #2'
     37                ]);
     38            } else {
     39                assert_array_equals(eventOrder.slice(2), ['external script #2',
     40                    'include-5 before removing scripts',
     41                    'include-5 after removing scripts',
     42                    'external script #1'
     43                ]);
     44            }
     45            t.done();
     46        }
     47        onload = t.step_func(test)
     48        </script>
     49 
     50 </body></html>