Chromium Code Reviews| Index: third_party/WebKit/LayoutTests/virtual/pointerevent/fast/events/pointerevents/touch-capture.html |
| diff --git a/third_party/WebKit/LayoutTests/virtual/pointerevent/fast/events/pointerevents/touch-capture.html b/third_party/WebKit/LayoutTests/virtual/pointerevent/fast/events/pointerevents/touch-capture.html |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..fd5ac0c75a7d0dd29c70ef5f1d68b073dc07098e |
| --- /dev/null |
| +++ b/third_party/WebKit/LayoutTests/virtual/pointerevent/fast/events/pointerevents/touch-capture.html |
| @@ -0,0 +1,141 @@ |
| +<!DOCTYPE HTML> |
| +<script src="../../../../../resources/js-test.js"></script> |
| +<style> |
| +div.box { |
| + margin: 5px; |
| + padding: 20px; |
| + float: left; |
| +} |
| +#grey { |
| + width: 50px; |
| + height: 50px; |
| +} |
| +</style> |
| + |
| +<div id="grey" class="box" style="background-color:grey"> |
| + <div id="green" class="box" style="background-color:green;"> |
| + </div> |
| +</div> |
| +<div id="blue" class="box" style="background-color:blue;"> |
| +</div> |
| + |
| +<div id="console"></div> |
| + |
| +<script> |
| +description("Verifies that pointer capture works for touch."); |
| + |
| +var rect = document.getElementById("green").getBoundingClientRect(); |
| +var x1 = rect.left + 5; |
| +var y1 = rect.top + 5; |
| + |
| +var rect = document.getElementById("grey").getBoundingClientRect(); |
| +var x2 = rect.left + 5; |
|
mustaq
2016/04/04 15:37:26
Unused: x2, y2.
Navid Zolghadr
2016/04/04 16:26:57
Done.
|
| +var y2 = rect.top + 5; |
| + |
| +var rect = document.getElementById("blue").getBoundingClientRect(); |
| +var x3 = rect.left + 5; |
| +var y3 = rect.top + 5; |
| + |
| +function init() { |
| + var eventList = ["touchstart", "touchmove", "touchend", "touchcancel", |
| + "pointerenter", "pointerleave", "pointerover", "pointerout", "pointermove", "pointerdown", "pointerup", "pointercancel", |
| + "gotpointercapture", "lostpointercapture"]; |
| + |
| + document.addEventListener("lostpointercapture", function(event) { |
| + if (event.eventPhase == Event.AT_TARGET) { |
| + debug("document received " + event.type + " " + event.pointerId); |
| + } |
| + }); |
| + ["grey", "green", "blue"].forEach(function(id) { |
| + var targetDiv = document.getElementById(id); |
| + eventList.forEach(function(eventName) { |
| + targetDiv.addEventListener(eventName, function(event) { |
| + if (event.eventPhase == Event.AT_TARGET) { |
| + if (event.type.includes("pointer")) |
| + debug(id + " received " + event.type + " " + event.pointerId); |
| + else |
| + debug(id + " received " + event.type); |
| + } |
| + }); |
| + }); |
| + }); |
| +} |
| + |
| +function singleTouchTestScenario(touchCancel) { |
| + debug(" **** First touch on green box & jiggle ***** "); |
| + eventSender.addTouchPoint(x1, y1) |
| + eventSender.touchStart(); |
| + eventSender.updateTouchPoint(0, x1+1, y1+1); |
| + eventSender.touchMove(); |
| + |
| + debug(" **** Move to blue box & jiggle ****"); |
| + eventSender.updateTouchPoint(0, x3, y3); |
| + eventSender.touchMove(); |
| + eventSender.updateTouchPoint(0, x3+1, y3+1); |
| + eventSender.touchMove(); |
| + |
| + if (touchCancel) { |
| + debug(" **** Cancel touch ***** "); |
| + eventSender.cancelTouchPoint(0); |
| + eventSender.touchCancel(); |
| + } else { |
| + debug(" **** Release touch ***** "); |
| + eventSender.releaseTouchPoint(0); |
| + eventSender.touchEnd(); |
| + } |
| + |
| + debug(""); |
| +} |
| + |
| + |
| +function multiTouchTestScenario(touchCancel) { |
| + debug(" **** First and second touch on green & jiggle ***** "); |
| + eventSender.addTouchPoint(x1, y1) |
| + eventSender.addTouchPoint(x1, y1) |
| + eventSender.touchStart(); |
| + eventSender.updateTouchPoint(0, x1+1, y1+1); |
| + eventSender.updateTouchPoint(1, x1+1, y1+1); |
| + eventSender.touchMove(); |
| + |
| + debug(" **** Move first touch to blue box & jiggle ****"); |
| + eventSender.updateTouchPoint(0, x3, y3); |
| + eventSender.updateTouchPoint(0, x3+1, y3+1); |
| + eventSender.touchMove(); |
| + |
| + if (touchCancel) { |
| + debug(" **** Cancel touches ***** "); |
| + eventSender.cancelTouchPoint(0); |
| + eventSender.cancelTouchPoint(1); |
|
mustaq
2016/04/04 15:37:26
I meant separate end/cancel for 0 & 1, to assert t
Navid Zolghadr
2016/04/04 16:26:57
Does this sound better? I had to send the moves an
mustaq
2016/04/05 15:46:17
I don't think we need to worry about the apparent
|
| + eventSender.touchCancel(); |
| + } else { |
| + debug(" **** Release touches ***** "); |
| + eventSender.releaseTouchPoint(0); |
| + eventSender.releaseTouchPoint(1); |
| + eventSender.touchEnd(); |
| + } |
| + |
| + debug(""); |
| +} |
| + |
| +function runTests() { |
| + debug(" ======= Touch and release ======="); |
| + singleTouchTestScenario(false); |
| + |
| + debug(" ======= Touch and cancel ======="); |
| + singleTouchTestScenario(true); |
| + |
| + debug(" ======= Multitouch and release ======="); |
| + multiTouchTestScenario(false); |
| + |
| + debug(" ======= Multitouch and cancel ======="); |
| + multiTouchTestScenario(true); |
| + |
| +} |
| + |
| +init(); |
| +if (window.eventSender) |
| + runTests(); |
| +else |
| + debug("This test requires eventSender"); |
| + |
| +</script> |