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 listenForEvents(document.querySelector('#outer')); |
| 10 listenForEvents(document.querySelector('#inner1')); |
| 11 listenForEvents(document.querySelector('#inner2')); |
| 12 listenForEvents(document.querySelector('#inner3')); |
| 13 |
| 14 if (window.testRunner) { |
| 15 eventSender.mouseMoveTo(1, 1); |
| 16 eventSender.mouseMoveTo(90,140); |
| 17 debug("// Entering #outer"); |
| 18 eventSender.mouseMoveTo(110,140); |
| 19 debug("// Entering #inner1"); |
| 20 eventSender.mouseMoveTo(130,140); |
| 21 debug("// Entering #inner3 (and therefore also #inner2)"); |
| 22 eventSender.mouseMoveTo(170,140); |
| 23 debug("// Leaving #inner3 and #inner2, but not #outer"); |
| 24 eventSender.mouseMoveTo(180,140); |
| 25 debug("// Leaving #outer"); |
| 26 eventSender.mouseMoveTo(210,140); |
| 27 } |
| 28 |
| 29 finishJSTest(); |
| 30 }); |
| 31 |
| 32 function handleEvent(e) { |
| 33 var phases = ['', 'capturing', 'at target', 'bubbling']; |
| 34 var target = e.target ? e.target : e.srcElement; |
| 35 if (target.id && target.id != "console") { |
| 36 debug(e.type + " (" + phases[e.eventPhase] + ") on " + target.id
); |
| 37 if (e.relatedTarget && e.relatedTarget.id) |
| 38 debug('- Related target: ' + e.relatedTarget.id); |
| 39 } |
| 40 |
| 41 } |
| 42 |
| 43 function listenForEvents(el) { |
| 44 ['mouseover', 'mouseout', 'mouseenter', 'mouseleave'].forEach(functi
on(type) { |
| 45 el.addEventListener(type, handleEvent); |
| 46 }); |
| 47 } |
| 48 </script> |
| 49 <script src="../js/resources/js-test-post.js"></script> |
| 50 |
| 51 <style> |
| 52 #outer { |
| 53 background: blue; |
| 54 height: 100px; |
| 55 left: 100px; |
| 56 position: absolute; |
| 57 top: 100px; |
| 58 width: 100px; |
| 59 } |
| 60 |
| 61 #inner1 { |
| 62 background: red; |
| 63 height: 50px; |
| 64 left: 20px; |
| 65 position: absolute; |
| 66 top: 20px; |
| 67 width: 50px; |
| 68 } |
| 69 |
| 70 #inner2 { |
| 71 background: yellow; |
| 72 height: 20px; |
| 73 left: 60px; |
| 74 position: absolute; |
| 75 top: 30px; |
| 76 width: 20px; |
| 77 } |
| 78 |
| 79 #inner3 { |
| 80 background-color: green; |
| 81 height: 10px; |
| 82 margin: 5px; |
| 83 width: 10px; |
| 84 } |
| 85 </style> |
| 86 </head> |
| 87 <body> |
| 88 <div id="outer"> |
| 89 <div id="inner1"></div> |
| 90 <div id="inner2"> |
| 91 <div id="inner3"></div> |
| 92 </div> |
| 93 </div> |
| 94 </body> |
| 95 </html> |
OLD | NEW |