tor-browser

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

084.html (1414B)


      1 <!DOCTYPE html>
      2 <html><head>
      3  <title> scheduler: event listener defined by script in a removed IFRAME</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 
     10  <div id="log">FAILED (This TC requires JavaScript enabled)</div>
     11  <iframe src="about:blank"></iframe>
     12  <script>
     13    log('inline script #1');
     14    function fireFooEvent(){
     15      var evt=document.createEvent('Event');
     16      evt.initEvent('foo', true, true);
     17      document.dispatchEvent(evt);
     18    }
     19    var doc=frames[0].document;
     20    doc.open( 'text/html' );
     21    doc.write( '<script>top.log("IFRAME script");top.document.addEventListener("foo", function(e){ top.log("event: "+e.type); }, false)<\/script>' );
     22    log('end script #1');
     23  </script>
     24  <script>
     25    fireFooEvent();
     26    frames[0].frameElement.parentNode.removeChild( frames[0].frameElement ); // removing the IFRAME should de-activate document that defined event listener..?
     27  </script>
     28  <script>
     29    fireFooEvent();
     30  </script>
     31  <script type="text/javascript">
     32  log( 'inline script #2' );
     33  var t = async_test()
     34 
     35  function test() {
     36    assert_array_equals(eventOrder, ['inline script #1',
     37      'IFRAME script',
     38      'end script #1',
     39      'event: foo',
     40      'inline script #2'
     41    ]);
     42    t.done();
     43  }
     44  onload = t.step_func(test)
     45  </script>
     46 
     47 </body></html>