1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
|
<!DOCTYPE html>
<meta charset="utf-8">
<title>TestDriver actions: pointerevent properties of touch type</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/resources/testdriver.js"></script>
<script src="/resources/testdriver-actions.js"></script>
<script src="/resources/testdriver-vendor.js"></script>
<style>
div#test {
position: fixed;
touch-action: none;
top: 5px;
left: 5px;
width: 100px;
height: 100px;
background-color: blue;
}
</style>
<div id="test">
</div>
<script>
let pointerDownEvent;
let pointerMoveEvent;
let receivedPointerDown = false;
async_test(t => {
let test = document.getElementById("test");
var eventList = ['pointermove', 'pointerdown'];
for (eventType of eventList) {
test.addEventListener(eventType, e => {
if (e.type == 'pointerdown') {
receivedPointerDown = true;
pointerDownEvent = e;
}
if (e.type == 'pointermove' && receivedPointerDown)
pointerMoveEvent = e;
});
}
let div = document.getElementById("test");
let actions = new test_driver.Actions()
.addPointer("touchPointer1", "touch")
.pointerMove(0, 0, {origin: test})
.pointerDown({width:23, height:31, pressure:0.78})
.pointerMove(15, 0, {origin: test, width:39, height:35, pressure:0.91})
.pointerUp()
.send()
.then(t.step_func_done(() => {
assert_equals(pointerDownEvent.type, "pointerdown");
assert_equals(pointerDownEvent.pointerType, "touch");
assert_equals(pointerDownEvent.width, 23);
assert_equals(pointerDownEvent.height, 31);
assert_equals(Math.round(pointerDownEvent.pressure * 100) / 100, 0.78);
assert_equals(pointerDownEvent.tiltX, 0);
assert_equals(pointerDownEvent.tiltY, 0);
assert_equals(pointerDownEvent.twist, 0);
assert_equals(pointerMoveEvent.type, "pointermove");
assert_equals(pointerMoveEvent.pointerType, "touch");
assert_equals(pointerMoveEvent.width, 39);
assert_equals(pointerMoveEvent.height, 35);
assert_equals(Math.round(pointerMoveEvent.pressure * 100) / 100, 0.91);
assert_equals(pointerMoveEvent.tiltX, 0);
assert_equals(pointerMoveEvent.tiltY, 0);
assert_equals(pointerMoveEvent.twist, 0);
})).catch(e => t.step_func(() => assert_unreached("Actions sequence failed " + e)));
});
</script>
|