Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(80)

Side by Side Diff: third_party/WebKit/LayoutTests/virtual/pointerevent/fast/events/pointerevents/touch-capture.html

Issue 1838973003: Send lostpointercapture on touch capturing (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Updating the test and implicit capture on touchPressed Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 <!DOCTYPE HTML>
2 <script src="../../../../../resources/js-test.js"></script>
3 <style>
4 div.box {
5 margin: 5px;
6 padding: 20px;
7 float: left;
8 }
9 #grey {
10 width: 50px;
11 height: 50px;
12 }
13 </style>
14
15 <div id="grey" class="box" style="background-color:grey">
16 <div id="green" class="box" style="background-color:green;">
17 </div>
18 </div>
19 <div id="blue" class="box" style="background-color:blue;">
20 </div>
21
22 <div id="console"></div>
23
24 <script>
25 description("Verifies that pointer capture works for touch.");
26
27 var rect = document.getElementById("green").getBoundingClientRect();
28 var x1 = rect.left + 5;
29 var y1 = rect.top + 5;
30
31 var rect = document.getElementById("grey").getBoundingClientRect();
32 var x2 = rect.left + 5;
mustaq 2016/04/04 15:37:26 Unused: x2, y2.
Navid Zolghadr 2016/04/04 16:26:57 Done.
33 var y2 = rect.top + 5;
34
35 var rect = document.getElementById("blue").getBoundingClientRect();
36 var x3 = rect.left + 5;
37 var y3 = rect.top + 5;
38
39 function init() {
40 var eventList = ["touchstart", "touchmove", "touchend", "touchcancel",
41 "pointerenter", "pointerleave", "pointerover", "pointerout", "pointermove", "pointerdown", "pointerup", "pointercancel",
42 "gotpointercapture", "lostpointercapture"];
43
44 document.addEventListener("lostpointercapture", function(event) {
45 if (event.eventPhase == Event.AT_TARGET) {
46 debug("document received " + event.type + " " + event.pointerId);
47 }
48 });
49 ["grey", "green", "blue"].forEach(function(id) {
50 var targetDiv = document.getElementById(id);
51 eventList.forEach(function(eventName) {
52 targetDiv.addEventListener(eventName, function(event) {
53 if (event.eventPhase == Event.AT_TARGET) {
54 if (event.type.includes("pointer"))
55 debug(id + " received " + event.type + " " + event.pointerId);
56 else
57 debug(id + " received " + event.type);
58 }
59 });
60 });
61 });
62 }
63
64 function singleTouchTestScenario(touchCancel) {
65 debug(" **** First touch on green box & jiggle ***** ");
66 eventSender.addTouchPoint(x1, y1)
67 eventSender.touchStart();
68 eventSender.updateTouchPoint(0, x1+1, y1+1);
69 eventSender.touchMove();
70
71 debug(" **** Move to blue box & jiggle ****");
72 eventSender.updateTouchPoint(0, x3, y3);
73 eventSender.touchMove();
74 eventSender.updateTouchPoint(0, x3+1, y3+1);
75 eventSender.touchMove();
76
77 if (touchCancel) {
78 debug(" **** Cancel touch ***** ");
79 eventSender.cancelTouchPoint(0);
80 eventSender.touchCancel();
81 } else {
82 debug(" **** Release touch ***** ");
83 eventSender.releaseTouchPoint(0);
84 eventSender.touchEnd();
85 }
86
87 debug("");
88 }
89
90
91 function multiTouchTestScenario(touchCancel) {
92 debug(" **** First and second touch on green & jiggle ***** ");
93 eventSender.addTouchPoint(x1, y1)
94 eventSender.addTouchPoint(x1, y1)
95 eventSender.touchStart();
96 eventSender.updateTouchPoint(0, x1+1, y1+1);
97 eventSender.updateTouchPoint(1, x1+1, y1+1);
98 eventSender.touchMove();
99
100 debug(" **** Move first touch to blue box & jiggle ****");
101 eventSender.updateTouchPoint(0, x3, y3);
102 eventSender.updateTouchPoint(0, x3+1, y3+1);
103 eventSender.touchMove();
104
105 if (touchCancel) {
106 debug(" **** Cancel touches ***** ");
107 eventSender.cancelTouchPoint(0);
108 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
109 eventSender.touchCancel();
110 } else {
111 debug(" **** Release touches ***** ");
112 eventSender.releaseTouchPoint(0);
113 eventSender.releaseTouchPoint(1);
114 eventSender.touchEnd();
115 }
116
117 debug("");
118 }
119
120 function runTests() {
121 debug(" ======= Touch and release =======");
122 singleTouchTestScenario(false);
123
124 debug(" ======= Touch and cancel =======");
125 singleTouchTestScenario(true);
126
127 debug(" ======= Multitouch and release =======");
128 multiTouchTestScenario(false);
129
130 debug(" ======= Multitouch and cancel =======");
131 multiTouchTestScenario(true);
132
133 }
134
135 init();
136 if (window.eventSender)
137 runTests();
138 else
139 debug("This test requires eventSender");
140
141 </script>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698