2 <script src=
"../../../resources/testharness.js"></script>
3 <script src=
"../../../resources/testharnessreport.js"></script>
4 <h1>Test that pointer properties propagates from touches to PointerEvents
</h1>
5 <div id=
"target0" style=
"height: 100px;"></div>
7 async_test(function() {
8 if (!window
.eventSender
) {
12 var POINTER_PROPERTIES
= [
13 { width
: 1.125, height
: 1.25, pressure
: .1875, tiltX
: 0, tiltY
: 0, pointerType
: "mouse", isPrimary
: true },
14 { width
: 2.125, height
: 2.25, pressure
: .2500, tiltX
: 25, tiltY
: 26, pointerType
: "pen", isPrimary
: true },
15 { width
: 3.125, height
: 3.25, pressure
: .3125, tiltX
: 0, tiltY
: 0, pointerType
: "touch", isPrimary
: true },
16 { width
: 4.125, height
: 4.25, pressure
: .4375, tiltX
: 0, tiltY
: 0, pointerType
: "touch", isPrimary
: false }
18 var receivedPointerEvents
= [];
19 var target0
= document
.getElementById("target0");
20 function checkPointerEvent(event
) {
21 receivedPointerEvents
.push(event
);
23 assert_between_inclusive(event
.pointerId
, 0, POINTER_PROPERTIES
.length
- 1);
24 var pp
= POINTER_PROPERTIES
[event
.pointerId
];
26 assert_equals(event
[i
], pp
[i
], "" + i
);
27 }, "Pointer event properties for pointer " + event
.pointerId
+ " on " + event
.type
);
29 on_event(target0
, "pointerdown", this.step_func(checkPointerEvent
));
30 on_event(target0
, "pointermove", this.step_func(checkPointerEvent
));
31 on_event(target0
, "pointerup", this.step_func(checkPointerEvent
));
32 on_event(window
, "load", this.step_func_done(function() {
33 assert_not_equals(window
.PointerEvent
, undefined, "window.PointerEvent");
34 var x
= target0
.offsetLeft
+ 2;
35 var y
= target0
.offsetTop
+ 2;
37 for ( var i
= 0 ; i
< POINTER_PROPERTIES
.length
; ++i
) {
38 var pp
= POINTER_PROPERTIES
[i
];
39 eventSender
.addTouchPoint(x
+ i
, y
+ i
, pp
["width"], pp
["height"], pp
["pressure"], pp
["tiltX"], pp
["tiltY"], pp
["pointerType"]);
41 eventSender
.touchStart();
43 for ( var i
= 0 ; i
< POINTER_PROPERTIES
.length
; ++i
) {
44 var pp
= POINTER_PROPERTIES
[i
];
45 eventSender
.updateTouchPoint(i
, x
+ i
+ 20, y
+ i
+ 20);
48 eventSender
.touchMove();
49 for ( var i
= 0 ; i
< POINTER_PROPERTIES
.length
; ++i
)
50 eventSender
.releaseTouchPoint(i
);
51 eventSender
.touchEnd();
55 receivedPointerEvents
.map(function(event
) { return event
.type
; }),
56 ["pointerdown", "pointerdown", "pointerdown", "pointerdown",
57 "pointermove", "pointermove", "pointermove", "pointermove",
58 "pointerup", "pointerup", "pointerup", "pointerup"]);
59 }, "Received pointer events");
61 }, "Pointer property propagation from touches to PointerEvents");