2 <script src=
"../../../resources/js-test.js"></script>
6 description("This tests the constructor for the PointerEvent DOM class.");
8 debug("--- tests for intrinsic attributes ---");
10 ["pointerId", "tiltX", "tiltY"].forEach(function (attr
) {
11 debug("-- no init --");
12 shouldBeZero("new PointerEvent('eventType')." + attr
);
14 debug("-- init with valid long values --");
15 shouldBeEqualToNumber("new PointerEvent('eventType', { " + attr
+ ": 123 })." + attr
, 123);
16 shouldBeEqualToNumber("new PointerEvent('eventType', { " + attr
+ ": -123 })." + attr
, -123);
17 shouldBeEqualToNumber("new PointerEvent('eventType', { " + attr
+ ": 2147483647 })." + attr
, 2147483647);
18 shouldBeEqualToNumber("new PointerEvent('eventType', { " + attr
+ ": -2147483648 })." + attr
, -2147483648);
20 debug("-- init with non-long values --");
21 shouldBeZero("new PointerEvent('eventType', { " + attr
+ ": 18446744073709551615 })." + attr
);
22 shouldBeEqualToNumber("new PointerEvent('eventType', {" + attr
+ ": 123.45 })." + attr
, 123);
23 shouldBeZero("new PointerEvent('eventType', { " + attr
+ ": '123abc' })." + attr
);
24 shouldBeZero("new PointerEvent('eventType', { " + attr
+ ": 'dummy' })." + attr
);
25 shouldBeZero("new PointerEvent('eventType', { " + attr
+ ": NaN })." + attr
);
26 shouldBeZero("new PointerEvent('eventType', { " + attr
+ ": null })." + attr
);
27 shouldBeZero("new PointerEvent('eventType', { " + attr
+ ": undefined })." + attr
);
28 shouldBeZero("new PointerEvent('eventType', { " + attr
+ ": [] })." + attr
);
29 shouldBeEqualToNumber("new PointerEvent('eventType', { " + attr
+ ": [12] })." + attr
, 12);
30 shouldBeZero("new PointerEvent('eventType', { " + attr
+ ": [12, 34] })." + attr
);
31 shouldBeZero("new PointerEvent('eventType', { " + attr
+ ": {} })." + attr
);
32 shouldBeZero("new PointerEvent('eventType', { " + attr
+ ": {abc:1} })." + attr
);
33 shouldBeZero("new PointerEvent('eventType', { " + attr
+ ": {} })." + attr
);
34 shouldBeEqualToNumber("new PointerEvent('eventType', { " + attr
+ ": {valueOf: function () { return 123; }} })." + attr
, 123);
37 ["width", "height", "pressure"].forEach(function (attr
) {
38 debug("-- no init --");
39 shouldBeZero("new PointerEvent('eventType')." + attr
);
41 debug("-- init with valid float/double values --");
42 shouldBeEqualToNumber("new PointerEvent('eventType', { " + attr
+ ": 123 })." + attr
, 123);
43 shouldBeEqualToNumber("new PointerEvent('eventType', { " + attr
+ ": -123 })." + attr
, -123);
44 shouldBeCloseTo("new PointerEvent('eventType', { " + attr
+ ": 123.45 })." + attr
, 123.45, 0.00001);
45 shouldBeCloseTo("new PointerEvent('eventType', { " + attr
+ ": -123.45 })." + attr
, -123.45, 0.00001);
46 shouldBeCloseTo("new PointerEvent('eventType', { " + attr
+ ": 1.23e5 })." + attr
, 123000, 0.00001);
47 shouldBeCloseTo("new PointerEvent('eventType', { " + attr
+ ": -1.2e-3 })." + attr
, -0.0012, 0.00001);
49 debug("-- init with non-float/double values --");
50 shouldThrow("new PointerEvent('eventType', { " + attr
+ ": '123abc' })." + attr
);
51 shouldThrow("new PointerEvent('eventType', { " + attr
+ ": 'dummy' })." + attr
);
52 shouldThrow("new PointerEvent('eventType', { " + attr
+ ": NaN })." + attr
);
53 shouldBeZero("new PointerEvent('eventType', { " + attr
+ ": null })." + attr
);
54 shouldBeZero("new PointerEvent('eventType', { " + attr
+ ": undefined })." + attr
);
55 shouldBeZero("new PointerEvent('eventType', { " + attr
+ ": [] })." + attr
);
57 shouldBeEqualToNumber("new PointerEvent('eventType', { " + attr
+ ": [12] })." + attr
, 12);
58 shouldThrow("new PointerEvent('eventType', { " + attr
+ ": [12, 34] })." + attr
);
59 shouldThrow("new PointerEvent('eventType', { " + attr
+ ": {} })." + attr
);
60 shouldThrow("new PointerEvent('eventType', { " + attr
+ ": {abc:1} })." + attr
);
61 shouldThrow("new PointerEvent('eventType', { " + attr
+ ": {} })." + attr
);
62 shouldBeEqualToNumber("new PointerEvent('eventType', { " + attr
+ ": {valueOf: function () { return 123; }} })." + attr
, 123);
65 debug("--- tests for inherited attributes ---");
67 shouldBeFalse("new PointerEvent('eventType').bubbles");
68 shouldBeFalse("new PointerEvent('eventType').cancelable");
69 shouldBeNull("new PointerEvent('eventType').view");
70 shouldBeZero("new PointerEvent('eventType').detail");
71 shouldBeZero("new PointerEvent('eventType').screenX");
72 shouldBeZero("new PointerEvent('eventType').screenY");
73 shouldBeZero("new PointerEvent('eventType').clientX");
74 shouldBeZero("new PointerEvent('eventType').clientY");
75 shouldBeFalse("new PointerEvent('eventType').ctrlKey");
76 shouldBeFalse("new PointerEvent('eventType').shiftKey");
77 shouldBeFalse("new PointerEvent('eventType').altKey");
78 shouldBeFalse("new PointerEvent('eventType').metaKey");
79 shouldBeZero("new PointerEvent('eventType').button");
80 shouldBeZero("new PointerEvent('eventType').buttons");
81 shouldBeNull("new PointerEvent('eventType').relatedTarget");