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
|
<!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>
#target {
height: 100px;
width: 100px;
overflow-y: scroll;
}
#spacer {
background: green;
height: 200px;
}
</style>
<h1>Verifies that pointerup/down are fired correctly for corresponding mouse events on the scollbar.</h1>
<div id="target">
<div id="spacer"></div>
</div>
<div id="console"></div>
<script>
var receivedEvents = [];
var targetDiv = document.getElementById('target');
function init() {
var eventList = ["mousedown", "mouseup", "pointerdown", "pointerup"];
eventList.forEach(function(eventName) {
targetDiv.addEventListener(eventName, function(event) {
receivedEvents.push(event.type + "@target");
});
});
}
function performActions(x, y){
return new test_driver.Actions()
.pointerMove(0, 0)
.pointerMove(x, y)
.pointerDown(0)
.pointerUp(0)
.send()
.then(()=>resolveWhen(()=>receivedEvents.length == 4));
}
function runTests() {
var rect = targetDiv.getBoundingClientRect();
var x1 = rect.right - 5;
var y1 = rect.top + 20;
test(function(){
assert_equals(targetDiv, document.elementFromPoint(x1,y1),
"Didn't hit the scrollbar as expected");
}, `Test point (${x1},${y1}) is on the scrollbar`);
promise_test(async () => {
await performActions(Math.ceil(x1), Math.ceil(y1));
assert_array_equals(receivedEvents, ["pointerdown@target", "mousedown@target",
"pointerup@target", "mouseup@target"]);
}, "Verifies that pointerup/down are fired correctly for corresponding mouse events on the scollbar.");
}
init();
runTests();
</script>
|