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

Side by Side Diff: third_party/WebKit/LayoutTests/imported/wpt/pointerevents/pointerevent_support.js

Issue 2322083002: Import wpt@e1ad3cc6894b20da0a5d7dddf431c9e7848d0544 (Closed)
Patch Set: Add mac exception and rebase 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 var All_Pointer_Events = [ 1 var All_Pointer_Events = [
2 "pointerdown", 2 "pointerdown",
3 "pointerup", 3 "pointerup",
4 "pointercancel", 4 "pointercancel",
5 "pointermove", 5 "pointermove",
6 "pointerover", 6 "pointerover",
7 "pointerout", 7 "pointerout",
8 "pointerenter", 8 "pointerenter",
9 "pointerleave", 9 "pointerleave",
10 "gotpointercapture", 10 "gotpointercapture",
11 "lostpointercapture"]; 11 "lostpointercapture"];
12 12
13 // Check for conformance to PointerEvent interface 13 // Check for conformance to PointerEvent interface
14 // TA: 1.1, 1.2, 1.6, 1.7, 1.8, 1.9, 1.10, 1.11, 1.12, 1.13 14 // TA: 1.1, 1.2, 1.6, 1.7, 1.8, 1.9, 1.10, 1.11, 1.12, 1.13
15 function check_PointerEvent(event, testNamePrefix) { 15 function check_PointerEvent(event, testNamePrefix) {
16 if (testNamePrefix === undefined) 16 if (testNamePrefix === undefined)
17 testNamePrefix = ""; 17 testNamePrefix = "";
18 var pointerTestName = testNamePrefix + ' ' + event.pointerType + ' ' + event .type; 18
19 // Use expectedPointerType if set otherwise just use the incoming event poin terType in the test name.
20 var pointerTestName = testNamePrefix + ' ' + (expectedPointerType == null ? event.pointerType : expectedPointerType) + ' ' + event.type;
21
22 if (expectedPointerType != null) {
23 test(function () {
24 assert_equals(event.pointerType, expectedPointerType, "pointerType s hould be the same as the requested device.");
25 }, pointerTestName + " event pointerType is correct.");
26 }
27
19 test(function () { 28 test(function () {
20 assert_true(event instanceof event.target.ownerDocument.defaultView.Poin terEvent, "event is a PointerEvent event"); 29 assert_true(event instanceof event.target.ownerDocument.defaultView.Poin terEvent, "event is a PointerEvent event");
21 }, pointerTestName + " event is a PointerEvent event"); 30 }, pointerTestName + " event is a PointerEvent event");
22 31
23 32
24 // Check attributes for conformance to WebIDL: 33 // Check attributes for conformance to WebIDL:
25 // * attribute exists 34 // * attribute exists
26 // * has proper type 35 // * has proper type
27 // * if the attribute is "readonly", it cannot be changed 36 // * if the attribute is "readonly", it cannot be changed
28 // TA: 1.1, 1.2 37 // TA: 1.1, 1.2
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
85 // TA: 1.7, 1.8 94 // TA: 1.7, 1.8
86 if (event.pointerType === "mouse") { 95 if (event.pointerType === "mouse") {
87 if (event.buttons === 0) { 96 if (event.buttons === 0) {
88 assert_equals(event.pressure, 0, "pressure is 0 for mouse with n o buttons pressed"); 97 assert_equals(event.pressure, 0, "pressure is 0 for mouse with n o buttons pressed");
89 } else { 98 } else {
90 assert_equals(event.pressure, 0.5, "pressure is 0.5 for mouse wi th a button pressed"); 99 assert_equals(event.pressure, 0.5, "pressure is 0.5 for mouse wi th a button pressed");
91 } 100 }
92 } 101 }
93 }, pointerTestName + ".pressure value is valid"); 102 }, pointerTestName + ".pressure value is valid");
94 103
95
96 // Check mouse-specific properties 104 // Check mouse-specific properties
97 if (event.pointerType === "mouse") { 105 if (event.pointerType === "mouse") {
98 // TA: 1.9, 1.10, 1.13 106 // TA: 1.9, 1.10, 1.13
99 test(function () { 107 test(function () {
108 assert_equals(event.width, 1, "width of mouse should be 1");
109 assert_equals(event.height, 1, "height of mouse should be 1");
100 assert_equals(event.tiltX, 0, event.type + ".tiltX is 0 for mouse"); 110 assert_equals(event.tiltX, 0, event.type + ".tiltX is 0 for mouse");
101 assert_equals(event.tiltY, 0, event.type + ".tiltY is 0 for mouse"); 111 assert_equals(event.tiltY, 0, event.type + ".tiltY is 0 for mouse");
102 assert_true(event.isPrimary, event.type + ".isPrimary is true for mo use"); 112 assert_true(event.isPrimary, event.type + ".isPrimary is true for mo use");
103 }, pointerTestName + " properties for pointerType = mouse"); 113 }, pointerTestName + " properties for pointerType = mouse");
104 // Check properties for pointers other than mouse 114 // Check properties for pointers other than mouse
105 } 115 }
106 } 116 }
107 117
108 function showPointerTypes() { 118 function showPointerTypes() {
109 var complete_notice = document.getElementById("complete-notice"); 119 var complete_notice = document.getElementById("complete-notice");
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
178 } 188 }
179 189
180 function rPointerCapture(e) { 190 function rPointerCapture(e) {
181 try { 191 try {
182 captureButton.value = 'Set Capture'; 192 captureButton.value = 'Set Capture';
183 target0.releasePointerCapture(e.pointerId); 193 target0.releasePointerCapture(e.pointerId);
184 } 194 }
185 catch(e) { 195 catch(e) {
186 } 196 }
187 } 197 }
198
199 var globalPointerEventTest = null;
200 var expectedPointerType = null;
201 var HOVERABLE_POINTERS = ['mouse', 'pen'];
202
203 function MultiPointerTypeTest(testName, types) {
204 this.testName = testName;
205 this.types = types;
206 this.currentTypeIndex = 0;
207 this.currentTest = null;
208 this.createNextTest();
209 }
210
211 MultiPointerTypeTest.prototype.skip = function() {
212 var prevTest = this.currentTest;
213 this.createNextTest();
214 prevTest.timeout();
215 }
216
217 MultiPointerTypeTest.prototype.done = function() {
218 var prevTest = this.currentTest;
219 this.createNextTest();
220 if (prevTest != null)
221 prevTest.done();
222 }
223
224 MultiPointerTypeTest.prototype.createNextTest = function() {
225 if (this.currentTypeIndex < this.types.length) {
226 var pointerTypeDescription = document.getElementById('pointerTypeDescrip tion');
227 document.getElementById('pointerTypeDescription').innerHTML = "Follow th e test instructions with <span style='color: red'>" + this.types[this.currentTyp eIndex] + "</span>. If you don't have the device <a href='javascript:;' onclick= 'globalPointerEventTest.skip()'>skip it</a>.";
228 this.currentTest = async_test(this.types[this.currentTypeIndex] + ' ' + this.testName);
229 expectedPointerType = this.types[this.currentTypeIndex];
230 this.currentTypeIndex++;
231 } else {
232 document.getElementById('pointerTypeDescription').innerHTML = "";
233 }
234 resetTestState();
235 }
236
237
238 function setup_pointerevent_test(testName, supportedPointerTypes) {
239 return globalPointerEventTest = new MultiPointerTypeTest(testName, supportedP ointerTypes);
240 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698