Chromium Code Reviews| Index: LayoutTests/fast/events/touch/touch-pointer-events.html |
| diff --git a/LayoutTests/fast/events/touch/touch-pointer-events.html b/LayoutTests/fast/events/touch/touch-pointer-events.html |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..95c4a81e167809f0239138ca77b89cac6ce366d0 |
| --- /dev/null |
| +++ b/LayoutTests/fast/events/touch/touch-pointer-events.html |
| @@ -0,0 +1,79 @@ |
| +<!DOCTYPE HTML> |
|
Rick Byers
2015/06/11 04:14:56
Ultimately we're going to want to try to bring tes
mustaq
2015/06/12 16:05:23
Done: moved to "pointerevents", at least preservin
Rick Byers
2015/06/16 17:25:38
I'm fine considering the eventSender question as o
|
| +<script src="../../../resources/js-test.js"></script> |
| +<style> |
| +div { |
| + margin: 10px; |
| + padding: 50px; |
| + float: left; |
| +} |
| +#console { |
| + padding: 0px; |
| + float: none; |
| +} |
| +</style> |
| + |
| +<div id="grey" style="background-color:grey"> |
| + <div id="lightgreen" style="background-color:lightgreen"> |
| + <div id="green" style="background-color:green;"> |
| + </div> |
| + </div> |
| +</div> |
| + |
| +<div id="console"></div> |
| + |
| +<script> |
| +description("Verifies that tapping on an element fires appropriate pointer events."); |
| + |
| +var preventDefault = false; |
| + |
| +function getPhaseString(event) { |
| + return event.eventPhase == 0 ? "none" : |
|
Rick Byers
2015/06/11 04:14:56
nit: rather than hard-coding the constants you sho
mustaq
2015/06/12 16:05:23
Done.
|
| + event.eventPhase == 1 ? "capturing" : |
| + event.eventPhase == 2 ? "target" : |
| + event.eventPhase == 3 ? "bubbling" : |
| + "error"; |
| +} |
| + |
| +function init() { |
| + var eventNames = ["touchstart", "touchend", "touchmove", "pointerdown", "pointerup", "pointermove"]; |
| + |
| + ["grey", "lightgreen", "green"].forEach(function(id) { |
| + var targetDiv = document.getElementById(id); |
| + |
| + eventNames.forEach(function(eventName) { |
| + targetDiv.addEventListener(eventName, function(event) { |
| + debug(id + " received " + event.type + " at phase=" + getPhaseString(event)); |
| + if (preventDefault) |
| + event.preventDefault(); |
| + }); |
| + }) |
| + }); |
| +} |
| + |
| +function sendTouch(id) { |
| + var rect = document.getElementById(id).getBoundingClientRect(); |
| + var x = rect.left + 10; |
| + var y = rect.top + 10; |
| + |
| + debug("-- sending touch to " + id + " --"); |
| + |
| + eventSender.clearTouchPoints(); |
| + eventSender.addTouchPoint(x, y); |
| + eventSender.touchStart(); |
| + eventSender.updateTouchPoint(0, x+20, y+20); |
| + eventSender.touchEnd(); |
|
Rick Byers
2015/06/11 04:14:56
I think you need to pass the ID (0) here to get th
mustaq
2015/06/12 16:05:23
Done, missed the "release" calls.
|
| +} |
| + |
| +init(); |
| +if (window.eventSender) { |
| + preventDefault = false; |
| + debug("--- with preventDefault=false ---"); |
| + sendTouch("green"); |
| + |
| + preventDefault = true; |
| + debug("--- with preventDefault=true ---"); |
| + sendTouch("green"); |
| +} else { |
| + debug("This test requires eventSender"); |
| +} |
| +</script> |