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

Side by Side Diff: third_party/WebKit/LayoutTests/fast/events/pointerevents/mouse-pointer-event-properties.html

Issue 2314093002: Revert of Make a pen in eraser mode visible thru PointerEvent.buttons (Closed)
Patch Set: Created 4 years, 3 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
1 <!DOCTYPE HTML> 1 <!DOCTYPE HTML>
2 <script src="../../../resources/js-test.js"></script> 2 <script src="../../../resources/js-test.js"></script>
3 <script src="../resources/input-modifiers.js"></script> 3 <script src="../resources/input-modifiers.js"></script>
4 <style> 4 <style>
5 div.box { 5 div.box {
6 margin: 10px; 6 margin: 10px;
7 padding: 50px; 7 padding: 50px;
8 float: left; 8 float: left;
9 } 9 }
10 </style> 10 </style>
11 11
12 <div id="target" class="box" style="background-color:red"> 12 <div id="target" class="box" style="background-color:red">
13 </div> 13 </div>
14 14
15 <div id="console"></div> 15 <div id="console"></div>
16 16
17 <script> 17 <script>
18 window.name = "mainWindow"; 18 window.name = "mainWindow";
19 description("Verifies that pointer event parameters are correct when fired throu gh mouse events."); 19 description("Verifies that pointer event parameters are correct when fired throu gh mouse events.");
20 20
21 var checkKeyModifiers = false; 21 var checkKeyModifiers = false;
22 22
23 var inputPointerType = "";
24
25 var pointerType = ""; 23 var pointerType = "";
26 var penId = 0; 24 var penId = 0;
27 var penPressure = 0; 25 var penPressure = 0;
28 var penTiltX = 0; 26 var penTiltX = 0;
29 var penTiltY = 0; 27 var penTiltY = 0;
30 28
31 var testEventList = ["mouseenter", "mouseleave", "mouseover", "mouseout", "mouse up", "mousedown", "mousemove", 29 var testEventList = ["mouseenter", "mouseleave", "mouseover", "mouseout", "mouse up", "mousedown", "mousemove",
32 "pointerenter", "pointerleave", "pointerover", "pointerout", "pointerup", "pointerdown", "pointermove"]; 30 "pointerenter", "pointerleave", "pointerover", "pointerout", "pointerup", "pointerdown", "pointermove"];
33 var lastPointerEvents = []; 31 var lastPointerEvents = [];
34 32
(...skipping 14 matching lines...) Expand all
49 "y", 47 "y",
50 "button", 48 "button",
51 "buttons", 49 "buttons",
52 "pressure", 50 "pressure",
53 "tiltX", 51 "tiltX",
54 "tiltY", 52 "tiltY",
55 "width", 53 "width",
56 "height", 54 "height",
57 ]; 55 ];
58 56
59 function getExpectedNumericAttributeValueForPE(mouseEvent, attribute) {
60 var expectedValue = eval("mouseEvent." + attribute);
61
62 // Fix expectedValue for the cases where PE & ME differs
63 if (attribute == "button") {
64 if (mouseEvent.type != "mousedown" && mouseEvent.type != "mouseup")
65 expectedValue = -1;
66 else if (inputPointerType == "eraser")
67 expectedValue = 5;
68 } else if (attribute == "buttons") {
69 if (inputPointerType == "eraser" && mouseEvent.type == "mousedown")
70 expectedValue = 32;
71 } else if (attribute == "width" || attribute == "height") {
72 expectedValue = 1;
73 } else if (attribute == "pressure") {
74 if (pointerType == "mouse")
75 expectedValue = (mouseEvent.buttons == 0)? 0.0 : 0.5;
76 else
77 expectedValue = penPressure;
78 } else if (attribute == "tiltX") {
79 expectedValue = (pointerType == "mouse")? 0 : penTiltX;
80 } else if (attribute == "tiltY") {
81 expectedValue = (pointerType == "mouse")? 0 : penTiltY;
82 }
83 return expectedValue;
84 }
85
86 function init() { 57 function init() {
87 var targetDiv = document.getElementById("target"); 58 var targetDiv = document.getElementById("target");
88 59
89 testEventList.forEach(function(eventName) { 60 testEventList.forEach(function(eventName) {
90 61
91 targetDiv.addEventListener(eventName, function(event) { 62 targetDiv.addEventListener(eventName, function(event) {
92 63
93 debug("Received " + event.type); 64 debug("Received " + event.type);
94 65
95 if (event.type.startsWith("pointer")) 66 if (event.type.startsWith("pointer"))
(...skipping 15 matching lines...) Expand all
111 shouldBeTrue("lastPointerEvents[0].bubbles"); 82 shouldBeTrue("lastPointerEvents[0].bubbles");
112 shouldBeTrue("lastPointerEvents[0].cancelable"); 83 shouldBeTrue("lastPointerEvents[0].cancelable");
113 } 84 }
114 85
115 shouldBeEqualToNumber("lastPointerEvents[0].pointerId", 86 shouldBeEqualToNumber("lastPointerEvents[0].pointerId",
116 (pointerType == "mouse")? 1 : penId); 87 (pointerType == "mouse")? 1 : penId);
117 shouldBeEqualToString("lastPointerEvents[0].pointerType", pointerType) ; 88 shouldBeEqualToString("lastPointerEvents[0].pointerType", pointerType) ;
118 shouldBeTrue("lastPointerEvents[0].isPrimary"); 89 shouldBeTrue("lastPointerEvents[0].isPrimary");
119 90
120 numericAttributes.forEach(function(attribute) { 91 numericAttributes.forEach(function(attribute) {
121 var expectedValue = getExpectedNumericAttributeValueForPE(event, att ribute); 92 var expectedValue = eval("event." + attribute);
93 if (attribute == "button" && event.type != "mousedown" && event.type != "mouseup")
94 expectedValue = -1;
95 else if (attribute == "width" || attribute == "height")
96 expectedValue = 1;
97 else if (attribute == "pressure") {
98 if (pointerType == "mouse")
99 expectedValue = (event.buttons == 0)? 0.0 : 0.5;
100 else
101 expectedValue = penPressure;
102 }
103 else if (attribute == "tiltX")
104 expectedValue = (pointerType == "mouse")? 0 : penTiltX;
105 else if (attribute == "tiltY")
106 expectedValue = (pointerType == "mouse")? 0 : penTiltY;
107
122 shouldBeEqualToNumber("lastPointerEvents[0]." + attribute, expectedV alue); 108 shouldBeEqualToNumber("lastPointerEvents[0]." + attribute, expectedV alue);
123 }); 109 });
124
125 shouldBeEqualToString("lastPointerEvents[0].view.name", "mainWindow"); 110 shouldBeEqualToString("lastPointerEvents[0].view.name", "mainWindow");
126 111
127 } else { 112 } else {
128 113
129 forEachModifier(function(attr, modifierName) { 114 forEachModifier(function(attr, modifierName) {
130 var getModifierStateStr = ".getModifierState('" + modifierName + "') ;" 115 var getModifierStateStr = ".getModifierState('" + modifierName + "') ;"
131 if (eval("event" + getModifierStateStr)) 116 if (eval("event" + getModifierStateStr))
132 shouldBeTrue("lastPointerEvents[0]" + getModifierStateStr); 117 shouldBeTrue("lastPointerEvents[0]" + getModifierStateStr);
133 else 118 else
134 shouldBeFalse("lastPointerEvents[0]" + getModifierStateStr); 119 shouldBeFalse("lastPointerEvents[0]" + getModifierStateStr);
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
172 }); 157 });
173 checkKeyModifiers = false; 158 checkKeyModifiers = false;
174 debug(""); 159 debug("");
175 160
176 debug("--- move mouse out of target ---"); 161 debug("--- move mouse out of target ---");
177 eventSender.mouseMoveTo(x - 5, y - 5); 162 eventSender.mouseMoveTo(x - 5, y - 5);
178 163
179 debug(""); 164 debug("");
180 } 165 }
181 166
182 function runPenTests(x, y, id, eraseMode) { 167 function runPenTests(x, y) {
183 debug("===== pen tests " + (eraseMode? "(erase mode)" : "(draw mode)") + " === =="); 168 debug("===== pen tests =====");
184 pointerType = "pen"; 169 pointerType = "pen";
185 inputPointerType = eraseMode? "eraser" : "pen"; 170 penId = 2;
186 penId = id;
187 penPressure = 0.0; 171 penPressure = 0.0;
188 penTiltX = 0; 172 penTiltX = 0;
189 penTiltY = 0; 173 penTiltY = 0;
190 174
191 debug("--- move pen into target ---"); 175 debug("--- move pen into target ---");
192 eventSender.mouseMoveTo(x + 5, y + 5, [], inputPointerType, penId, penPressure , penTiltX, penTiltY); 176 eventSender.mouseMoveTo(x + 5, y + 5, [], "pen", penId, penPressure, penTiltX, penTiltY);
193 debug(""); 177 debug("");
194 178
195 debug("--- move within target & tap ---"); 179 debug("--- move within target & tap ---");
196 penTiltX = 45; 180 penTiltX = 45;
197 penTiltY = -34; 181 penTiltY = -34;
198 eventSender.mouseMoveTo(x + 15, y + 15, [], inputPointerType, penId, penPressu re, penTiltX, penTiltY); 182 eventSender.mouseMoveTo(x + 15, y + 15, [], "pen", penId, penPressure, penTilt X, penTiltY);
199 penPressure = 0.75; 183 penPressure = 0.75;
200 eventSender.mouseDown(0, [], inputPointerType, penId, penPressure, penTiltX, p enTiltY); 184 eventSender.mouseDown(0, [], "pen", penId, penPressure, penTiltX, penTiltY);
201 penPressure = 0.0; 185 penPressure = 0.0;
202 eventSender.mouseUp(0, [], inputPointerType, penId, penPressure, penTiltX, pen TiltY); 186 eventSender.mouseUp(0, [], "pen", penId, penPressure, penTiltX, penTiltY);
203 187
204 debug("--- move pen out of target ---"); 188 debug("--- move pen out of target ---");
205 eventSender.mouseMoveTo(x - 5, y - 5, [], inputPointerType, penId, penPressure , penTiltX, penTiltY); 189 eventSender.mouseMoveTo(x - 5, y - 5, [], "pen", penId, penPressure, penTiltX, penTiltY);
206 190
207 debug(""); 191 debug("");
208 } 192 }
209 193
210 function runAllTests() { 194 function runAllTests() {
211 var rect = document.getElementById("target").getBoundingClientRect(); 195 var rect = document.getElementById("target").getBoundingClientRect();
212 196
213 runMouseTests(rect.left, rect.top); 197 runMouseTests(rect.left, rect.top);
214 runPenTests(rect.left, rect.top, 2, false); 198 runPenTests(rect.left, rect.top);
215 runPenTests(rect.left, rect.top, 3, true);
216 } 199 }
217 200
218 init(); 201 init();
219 if (window.eventSender) 202 if (window.eventSender)
220 runAllTests(); 203 runAllTests();
221 else 204 else
222 debug("This test requires eventSender"); 205 debug("This test requires eventSender");
223 206
224 </script> 207 </script>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698