OLD | NEW |
(Empty) | |
| 1 <!DOCTYPE HTML> |
| 2 <script src="../../../../resources/js-test.js"></script> |
| 3 <style> |
| 4 #target { |
| 5 position: absolute; |
| 6 right: 10px; |
| 7 top: 10px; |
| 8 border: 1px solid blue; |
| 9 } |
| 10 </style> |
| 11 <div id=target> |
| 12 Tap me |
| 13 </div> |
| 14 <script> |
| 15 |
| 16 if (window.testRunner) |
| 17 testRunner.dumpAsText(); |
| 18 |
| 19 function eventLogger(e) { |
| 20 debug("Received " + e.type + " on " + (e.currentTarget.id || e.currentTarget
.nodeName)); |
| 21 } |
| 22 |
| 23 function logAndRemove(e) { |
| 24 eventLogger(e); |
| 25 e.currentTarget.parentNode.removeChild(e.currentTarget); |
| 26 debug("Removed element"); |
| 27 e = null; |
| 28 gc(); |
| 29 } |
| 30 |
| 31 function logAndFail(e) { |
| 32 eventLogger(e); |
| 33 testFailed("Received unexpected event."); |
| 34 } |
| 35 |
| 36 function getTargetPoint() { |
| 37 // Note that we don't want any reference to the node to escape this function |
| 38 // so that it's elligble for garbage collection. |
| 39 var target = document.getElementById('target'); |
| 40 target.addEventListener('mousemove', logAndRemove); |
| 41 target.addEventListener('mousedown', eventLogger); |
| 42 target.addEventListener('mouseup', eventLogger); |
| 43 target.addEventListener('click', eventLogger); |
| 44 document.addEventListener('mousemove', eventLogger); |
| 45 document.addEventListener('mousedown', logAndFail); |
| 46 document.addEventListener('mouseup', logAndFail); |
| 47 document.addEventListener('click', logAndFail); |
| 48 |
| 49 var rect = target.getBoundingClientRect(); |
| 50 return { |
| 51 x: rect.left + rect.width / 2, |
| 52 y: rect.top + rect.height / 2 |
| 53 }; |
| 54 } |
| 55 |
| 56 onload = function() { |
| 57 description("Verifies that deleting the element being tapped during the even
t sequence doesn't cause any problems. Succeeds if the expected events are deli
vered to the div, events after removal don't bubble up, and we don't crash."); |
| 58 |
| 59 var point = getTargetPoint(); |
| 60 |
| 61 if (!window.eventSender) { |
| 62 debug("This test requires eventSender"); |
| 63 return; |
| 64 } |
| 65 |
| 66 debug("Sending GestureTapDown"); |
| 67 eventSender.gestureTapDown(point.x, point.y); |
| 68 |
| 69 debug("Sending GestureShowPress"); |
| 70 eventSender.gestureShowPress(point.x, point.y); |
| 71 |
| 72 debug("Sending GestureTap"); |
| 73 eventSender.gestureTap(point.x, point.y); |
| 74 } |
| 75 |
| 76 </script> |
OLD | NEW |