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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
|
<!DOCTYPE HTML>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/resources/testdriver.js"></script>
<script src="/resources/testdriver-vendor.js"></script>
<script src="/resources/testdriver-actions.js"></script>
<script type="text/javascript" src="../pointerevent_support.js"></script>
<style>
div.box {
margin: 10px;
padding: 50px;
float: left;
}
</style>
<h1>Verifies that pointerup/down are fired correctly for corresponding mouse events</h1>
<div id="lightgreen" class="box" style="background-color:lightgreen">
<div id="green" class="box" style="background-color:green">
</div>
</div>
<div id="console"></div>
<script>
var eventsReceived = [];
function init() {
var eventList = ["mousedown", "mouseup", "pointerdown", "pointerup"];
["green", "lightgreen"].forEach(function(id) {
var targetDiv = document.getElementById(id);
eventList.forEach(function(eventName) {
targetDiv.addEventListener(eventName, function(event) {
eventsReceived.push(`${event.type}@${id}`);
});
});
});
}
function performActions() {
var rect = document.getElementById("green").getBoundingClientRect();
var x1 = Math.ceil(rect.left + 5);
var y1 = Math.ceil(rect.top + 5);
var rect = document.getElementById("lightgreen").getBoundingClientRect();
var x2 = Math.ceil(rect.left + 5);
var y2 = Math.ceil(rect.top + 5);
return new test_driver.Actions()
.pointerMove(x1, y1)
.pointerDown()
.pointerUp()
.pointerDown()
.pointerMove(x2, y2)
.pointerUp()
.pointerDown()
.pointerMove(x1, y1)
.pointerUp()
.send()
.then(()=>resolveWhen(()=>eventsExpected.length === eventsReceived.length));
}
var eventsExpected = ["pointerdown@green", "pointerdown@lightgreen",
"mousedown@green", "mousedown@lightgreen",
"pointerup@green", "pointerup@lightgreen",
"mouseup@green", "mouseup@lightgreen",
"pointerdown@green", "pointerdown@lightgreen",
"mousedown@green", "mousedown@lightgreen",
"pointerup@lightgreen", "mouseup@lightgreen",
"pointerdown@lightgreen", "mousedown@lightgreen",
"pointerup@green", "pointerup@lightgreen",
"mouseup@green", "mouseup@lightgreen"];
function runTests(){
promise_test((test) => {
return new Promise(async (resolve)=>{
await performActions();
test.step(()=>{
assert_array_equals(eventsExpected, eventsReceived);
});
resolve();
});
}, "pointerup/down events are fired correctly for corresponding mouse events");
}
init();
runTests();
</script>
|