tor-browser

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

039.html (1806B)


      1 <!DOCTYPE html>
      2 <html><head>
      3        <title> scheduler: IFRAMEs added with DOM</title>
      4        <script src="/resources/testharness.js"></script>
      5        <script src="/resources/testharnessreport.js"></script>
      6        <script src="testlib/testlib.js"></script>
      7 </head>
      8 <body>
      9        <div id="log">FAILED (This TC requires JavaScript enabled)</div>
     10        <div></div>
     11        <script>log('inline script #1');
     12                for( var i=0; i<2; i++ ){
     13                        var iframe=document.createElement('iframe');
     14                        document.getElementsByTagName('div')[1].appendChild(iframe);
     15                        iframe.src='pages/helloworld.html?'+i+'&'+Math.random();
     16                }
     17                log('end script #1');
     18        </script>
     19 
     20        <script type="text/javascript">
     21        log( 'inline script #2' );
     22        promise_test(() => {
     23          const frames = document.querySelectorAll("iframe");
     24          return Promise.all([
     25            new Promise(resolve => window.addEventListener('load', resolve)),
     26            new Promise(resolve => frames[0].addEventListener('load', resolve)),
     27            new Promise(resolve => frames[1].addEventListener('load', resolve)),
     28          ]).then(() => {
     29            assert_equals(eventOrder.length, 5);
     30            assert_array_equals(
     31                eventOrder.slice(0, 3),
     32                ['inline script #1', 'end script #1', 'inline script #2'],
     33                "inline scripts should run first");
     34            assert_in_array('frame/popup script 0', eventOrder.slice(3, 5), 'iframe should have loaded');
     35            assert_in_array('frame/popup script 1', eventOrder.slice(3, 5), 'iframe should have loaded');
     36          });
     37        }, 'iframes should load asynchronously after inline script run');
     38        </script>
     39 </body></html>