OLD | NEW |
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) { | 15 function check_PointerEvent(event) { |
| 16 var pointerTestName = event.pointerType + ' ' + event.type; |
16 test(function () { | 17 test(function () { |
17 assert_true(event instanceof PointerEvent, "event is a PointerEvent even
t"); | 18 assert_true(event instanceof PointerEvent, "event is a PointerEvent even
t"); |
18 }, event.type + " event is a PointerEvent event"); | 19 }, pointerTestName + " event is a PointerEvent event"); |
19 | 20 |
20 | 21 |
21 // Check attributes for conformance to WebIDL: | 22 // Check attributes for conformance to WebIDL: |
22 // * attribute exists | 23 // * attribute exists |
23 // * has proper type | 24 // * has proper type |
24 // * if the attribute is "readonly", it cannot be changed | 25 // * if the attribute is "readonly", it cannot be changed |
25 // TA: 1.1, 1.2 | 26 // TA: 1.1, 1.2 |
26 var idl_type_check = { | 27 var idl_type_check = { |
27 "long": function (v) { return typeof v === "number" && Math.round(v) ===
v; }, | 28 "long": function (v) { return typeof v === "number" && Math.round(v) ===
v; }, |
28 "float": function (v) { return typeof v === "number"; }, | 29 "float": function (v) { return typeof v === "number"; }, |
29 "string": function (v) { return typeof v === "string"; }, | 30 "string": function (v) { return typeof v === "string"; }, |
30 "boolean": function (v) { return typeof v === "boolean" } | 31 "boolean": function (v) { return typeof v === "boolean" } |
31 }; | 32 }; |
32 [ | 33 [ |
33 ["readonly", "long", "pointerId"], | 34 ["readonly", "long", "pointerId"], |
34 ["readonly", "float", "width"], | 35 ["readonly", "float", "width"], |
35 ["readonly", "float", "height"], | 36 ["readonly", "float", "height"], |
36 ["readonly", "float", "pressure"], | 37 ["readonly", "float", "pressure"], |
37 ["readonly", "long", "tiltX"], | 38 ["readonly", "long", "tiltX"], |
38 ["readonly", "long", "tiltY"], | 39 ["readonly", "long", "tiltY"], |
39 ["readonly", "string", "pointerType"], | 40 ["readonly", "string", "pointerType"], |
40 ["readonly", "boolean", "isPrimary"] | 41 ["readonly", "boolean", "isPrimary"], |
| 42 ["readonly", "long", "detail", 0] |
41 ].forEach(function (attr) { | 43 ].forEach(function (attr) { |
42 var readonly = attr[0]; | 44 var readonly = attr[0]; |
43 var type = attr[1]; | 45 var type = attr[1]; |
44 var name = attr[2]; | 46 var name = attr[2]; |
45 | 47 var value = attr[3]; |
46 | 48 |
47 // existence check | 49 // existence check |
48 test(function () { | 50 test(function () { |
49 assert_true(name in event, name + " attribute in " + event.type + "
event"); | 51 assert_true(name in event, name + " attribute in " + event.type + "
event"); |
50 }, event.type + "." + name + " attribute exists"); | 52 }, pointerTestName + "." + name + " attribute exists"); |
51 | |
52 | 53 |
53 // readonly check | 54 // readonly check |
54 if (readonly === "readonly") { | 55 if (readonly === "readonly") { |
55 test(function () { | 56 test(function () { |
56 assert_readonly(event.type, name, event.type + "." + name + " ca
nnot be changed"); | 57 assert_readonly(event.type, name, event.type + "." + name + " ca
nnot be changed"); |
57 }, event.type + "." + name + " is readonly"); | 58 }, pointerTestName + "." + name + " is readonly"); |
58 } | 59 } |
59 | 60 |
60 | |
61 // type check | 61 // type check |
62 test(function () { | 62 test(function () { |
63 assert_true(idl_type_check[type](event[name]), name + " attribute of
type " + type); | 63 assert_true(idl_type_check[type](event[name]), name + " attribute of
type " + type); |
64 }, event.type + "." + name + " IDL type " + type + " (JS type was " + ty
peof event[name] + ")"); | 64 }, pointerTestName + "." + name + " IDL type " + type + " (JS type was "
+ typeof event[name] + ")"); |
| 65 |
| 66 // value check if defined |
| 67 if (value != undefined) { |
| 68 test(function () { |
| 69 assert_equals(event[name], value, name + " attribute value"); |
| 70 }, pointerTestName + "." + name + " value is " + value + "."); |
| 71 } |
65 }); | 72 }); |
66 | 73 |
67 | 74 |
68 // Check the pressure value | 75 // Check the pressure value |
69 // TA: 1.6, 1.7, 1.8 | 76 // TA: 1.6, 1.7, 1.8 |
70 test(function () { | 77 test(function () { |
71 // TA: 1.6 | 78 // TA: 1.6 |
72 assert_greater_than_equal(event.pressure, 0, "pressure is greater than o
r equal to 0"); | 79 assert_greater_than_equal(event.pressure, 0, "pressure is greater than o
r equal to 0"); |
73 assert_less_than_equal(event.pressure, 1, "pressure is less than or equa
l to 1"); | 80 assert_less_than_equal(event.pressure, 1, "pressure is less than or equa
l to 1"); |
74 | 81 |
75 | 82 |
76 // TA: 1.7, 1.8 | 83 // TA: 1.7, 1.8 |
77 if (event.pointerType === "mouse") { | 84 if (event.pointerType === "mouse") { |
78 if (event.buttons === 0) { | 85 if (event.buttons === 0) { |
79 assert_equals(event.pressure, 0, "pressure is 0 for mouse with n
o buttons pressed"); | 86 assert_equals(event.pressure, 0, "pressure is 0 for mouse with n
o buttons pressed"); |
80 } else { | 87 } else { |
81 assert_equals(event.pressure, 0.5, "pressure is 0.5 for mouse wi
th a button pressed"); | 88 assert_equals(event.pressure, 0.5, "pressure is 0.5 for mouse wi
th a button pressed"); |
82 } | 89 } |
83 } | 90 } |
84 }, event.type + ".pressure value is valid"); | 91 }, pointerTestName + ".pressure value is valid"); |
85 | 92 |
86 | 93 |
87 // Check mouse-specific properties | 94 // Check mouse-specific properties |
88 if (event.pointerType === "mouse") { | 95 if (event.pointerType === "mouse") { |
89 // TA: 1.9, 1.10, 1.13 | 96 // TA: 1.9, 1.10, 1.13 |
90 test(function () { | 97 test(function () { |
91 assert_equals(event.tiltX, 0, event.type + ".tiltX is 0 for mouse"); | 98 assert_equals(event.tiltX, 0, event.type + ".tiltX is 0 for mouse"); |
92 assert_equals(event.tiltY, 0, event.type + ".tiltY is 0 for mouse"); | 99 assert_equals(event.tiltY, 0, event.type + ".tiltY is 0 for mouse"); |
93 assert_true(event.isPrimary, event.type + ".isPrimary is true for mo
use"); | 100 assert_true(event.isPrimary, event.type + ".isPrimary is true for mo
use"); |
94 }, event.type + " properties for pointerType = mouse"); | 101 }, pointerTestName + " properties for pointerType = mouse"); |
95 // Check properties for pointers other than mouse | 102 // Check properties for pointers other than mouse |
96 } | 103 } |
97 } | 104 } |
98 | 105 |
99 function showPointerTypes() { | 106 function showPointerTypes() { |
100 var complete_notice = document.getElementById("complete-notice"); | 107 var complete_notice = document.getElementById("complete-notice"); |
101 var pointertype_log = document.getElementById("pointertype-log"); | 108 var pointertype_log = document.getElementById("pointertype-log"); |
102 var pointertypes = Object.keys(detected_pointertypes); | 109 var pointertypes = Object.keys(detected_pointertypes); |
103 pointertype_log.innerHTML = pointertypes.length ? | 110 pointertype_log.innerHTML = pointertypes.length ? |
104 pointertypes.join(",") : "(none)"; | 111 pointertypes.join(",") : "(none)"; |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
169 } | 176 } |
170 | 177 |
171 function rPointerCapture(e) { | 178 function rPointerCapture(e) { |
172 try { | 179 try { |
173 captureButton.value = 'Set Capture'; | 180 captureButton.value = 'Set Capture'; |
174 target0.releasePointerCapture(e.pointerId); | 181 target0.releasePointerCapture(e.pointerId); |
175 } | 182 } |
176 catch(e) { | 183 catch(e) { |
177 } | 184 } |
178 } | 185 } |
OLD | NEW |