Index: LayoutTests/fast/events/touch/gesture/gesture-tap-div-removed.html |
diff --git a/LayoutTests/fast/events/touch/gesture/gesture-tap-div-removed.html b/LayoutTests/fast/events/touch/gesture/gesture-tap-div-removed.html |
new file mode 100644 |
index 0000000000000000000000000000000000000000..2a1d646cd5dde3511d43a139b84a428342b3735f |
--- /dev/null |
+++ b/LayoutTests/fast/events/touch/gesture/gesture-tap-div-removed.html |
@@ -0,0 +1,76 @@ |
+<!DOCTYPE HTML> |
+<script src="../../../../resources/js-test.js"></script> |
+<style> |
+#target { |
+ position: absolute; |
+ right: 10px; |
+ top: 10px; |
+ border: 1px solid blue; |
+} |
+</style> |
+<div id=target> |
+ Tap me |
+</div> |
+<script> |
+ |
+if (window.testRunner) |
+ testRunner.dumpAsText(); |
+ |
+function eventLogger(e) { |
+ debug("Received " + e.type + " on " + (e.currentTarget.id || e.currentTarget.nodeName)); |
+} |
+ |
+function logAndRemove(e) { |
+ eventLogger(e); |
+ e.currentTarget.parentNode.removeChild(e.currentTarget); |
+ debug("Removed element"); |
+ e = null; |
+ gc(); |
+} |
+ |
+function logAndFail(e) { |
+ eventLogger(e); |
+ testFailed("Received unexpected event."); |
+} |
+ |
+function getTargetPoint() { |
+ // Note that we don't want any reference to the node to escape this function |
+ // so that it's elligble for garbage collection. |
+ var target = document.getElementById('target'); |
+ target.addEventListener('mousemove', logAndRemove); |
+ target.addEventListener('mousedown', eventLogger); |
+ target.addEventListener('mouseup', eventLogger); |
+ target.addEventListener('click', eventLogger); |
+ document.addEventListener('mousemove', eventLogger); |
+ document.addEventListener('mousedown', logAndFail); |
+ document.addEventListener('mouseup', logAndFail); |
+ document.addEventListener('click', logAndFail); |
+ |
+ var rect = target.getBoundingClientRect(); |
+ return { |
+ x: rect.left + rect.width / 2, |
+ y: rect.top + rect.height / 2 |
+ }; |
+} |
+ |
+onload = function() { |
+ description("Verifies that deleting the element being tapped during the event sequence doesn't cause any problems. Succeeds if the expected events are delivered to the div, events after removal don't bubble up, and we don't crash."); |
+ |
+ var point = getTargetPoint(); |
+ |
+ if (!window.eventSender) { |
+ debug("This test requires eventSender"); |
+ return; |
+ } |
+ |
+ debug("Sending GestureTapDown"); |
+ eventSender.gestureTapDown(point.x, point.y); |
+ |
+ debug("Sending GestureShowPress"); |
+ eventSender.gestureShowPress(point.x, point.y); |
+ |
+ debug("Sending GestureTap"); |
+ eventSender.gestureTap(point.x, point.y); |
+} |
+ |
+</script> |