blob: 2cc8741f5ef2e02afa1e313fc918fef00c12adb5 (
plain)
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
|
<!DOCTYPE html>
<html>
<head>
<link rel="help" href="https://drafts.csswg.org/css-scroll-snap-1/#scroll-snap-type" />
<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>
<script src="/dom/events/scrolling/scroll_support.js"></script>
</head>
<body>
<style>
#scroller {
overflow: scroll;
height: 500px;
width: 500px;
background-color: blue;
scroll-snap-type: y mandatory;
position: absolute;
}
.snap_point {
scroll-snap-align: start;
width: 40%;
position: relative;
left: 30%;
}
.big {
height: 1000%;
background-color: pink;
border: solid 1px red;
}
.small {
height: 50%;
background-color: purple;
border: solid 1px black;
}
</style>
<div id="scroller">
<div class="big snap_point" id="big_snap_point"></div>
<div class="small snap_point">
<button id="scrollerButton">scrollerButton</button>
</div>
</div>
<script>
promise_test(async(t) => {
const x = scroller.clientWidth / 2;
const y = scroller.clientHeight / 2;
// Scroll all the way down to the smaller snap area which doesn't cover
// the snapport.
let scrollend_promise = new Promise((resolve) => {
scroller.addEventListener("scrollend", resolve);
});
scroller.scrollTop = scroller.scrollHeight;
await scrollend_promise;
// Scroll up with one press of the arrow-up button.
scrollend_promise = new Promise((resolve) => {
scroller.addEventListener("scrollend", resolve);
});
const arrowUp = '\uE013';
await test_driver.send_keys(scrollerButton, arrowUp);
await scrollend_promise;
assert_equals(scroller.scrollTop, big_snap_point.offsetHeight - scroller.clientHeight,
"scroller is snapped to the bottom of the larger snap area, not the top");
});
</script>
</body>
</html>
|