083.html (1509B)
1 <!DOCTYPE html> 2 <html><head> 3 <title> scheduler: event listener defined by script in a document in history</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].location='about:blank'; // returning to about:blank 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_equals(frames[0].location.toString(), "about:blank"); 37 assert_array_equals(eventOrder, ['inline script #1', 38 'IFRAME script', 39 'end script #1', 40 'event: foo', 41 'inline script #2' 42 ]); 43 t.done(); 44 } 45 onload = function() {setTimeout(t.step_func(function() {fireFooEvent(); test()}), 80)}; 46 </script> 47 48 </body></html>