OLD | NEW |
(Empty) | |
| 1 <!DOCTYPE html> |
| 2 <html> |
| 3 <head> |
| 4 <script src="../js/resources/js-test-pre.js"></script> |
| 5 <script> |
| 6 window.jsTestIsAsync = true; |
| 7 |
| 8 document.addEventListener('DOMContentLoaded', function () { |
| 9 var outer = document.querySelector('#outer'); |
| 10 var inner1 = document.querySelector('#inner1'); |
| 11 var inner2 = document.querySelector('#inner2'); |
| 12 |
| 13 [outer, inner1, inner2].forEach(function (el) { |
| 14 ['mouseover', 'mouseout', 'mouseenter', 'mouseleave'].forEach(fu
nction (type) { |
| 15 if (el === inner2 && (type === 'mouseenter' || type === 'mou
seleave')) |
| 16 return; |
| 17 el.addEventListener(type, handleEvent); |
| 18 }); |
| 19 }); |
| 20 |
| 21 if (window.testRunner) { |
| 22 eventSender.mouseMoveTo(1, 125); |
| 23 |
| 24 debug('// Entering #inner1'); |
| 25 eventSender.mouseMoveTo(75, 125); |
| 26 |
| 27 debug('// Entering #outer and #inner2'); |
| 28 eventSender.mouseMoveTo(125, 125); |
| 29 } |
| 30 |
| 31 finishJSTest(); |
| 32 }); |
| 33 |
| 34 function handleEvent(e) { |
| 35 var phases = ['', 'capturing', 'at target', 'bubbling']; |
| 36 var target = e.target ? e.target : e.srcElement; |
| 37 debug(e.type + " (" + phases[e.eventPhase] + ") on " + target.id); |
| 38 |
| 39 if (e.type === 'mouseleave' && target.id === 'inner1') { |
| 40 debug('// Setting capturing mouseenter handler on #outer from #i
nner1\'s mouseleave handler.'); |
| 41 document.querySelector('#outer').addEventListener('mouseenter',
handleEvent, true); |
| 42 } |
| 43 } |
| 44 </script> |
| 45 <script src="../js/resources/js-test-post.js"></script> |
| 46 <style> |
| 47 #outer { |
| 48 background: blue; |
| 49 height: 100px; |
| 50 left: 100px; |
| 51 position: absolute; |
| 52 top: 100px; |
| 53 width: 100px; |
| 54 } |
| 55 |
| 56 #inner1 { |
| 57 position: absolute; |
| 58 height: 50px; |
| 59 width: 50px; |
| 60 left: -50px; |
| 61 background: green; |
| 62 } |
| 63 |
| 64 #inner2 { |
| 65 background: red; |
| 66 height: 50px; |
| 67 position: absolute; |
| 68 width: 50px; |
| 69 } |
| 70 </style> |
| 71 </head> |
| 72 <body> |
| 73 <div id="outer"> |
| 74 <div id="inner1"></div> |
| 75 <div id="inner2"></div> |
| 76 </div> |
| 77 </body> |
| 78 </html> |
OLD | NEW |