-
Notifications
You must be signed in to change notification settings - Fork 3.8k
Expand file tree
/
Copy pathoverscroll-behavior-keyboard-scroll.html
More file actions
202 lines (175 loc) · 6.7 KB
/
overscroll-behavior-keyboard-scroll.html
File metadata and controls
202 lines (175 loc) · 6.7 KB
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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
<!doctype html>
<meta charset="utf-8">
<title>overscroll-behavior for keyboard scroll</title>
<meta name="timeout" content="long">
<link rel="help" href="https://drafts.csswg.org/css-overscroll-behavior">
<link rel="author" title="Peng Zhou" href="mailto:zhoupeng.1996@bytedance.com">
<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>
<script src="/css/css-scroll-snap/support/common.js"></script>
<style>
body {
margin: 0px;
}
.outer {
height: 400px;
width: 1000px;
background: white
}
.content {
height: 600px;
width: 1200px;
}
#root {
overflow: scroll;
height: 600px;
width: 800px;
background: white;
}
#container {
overflow: scroll;
}
#non_scrollable {
overflow: clip;
}
#green {
background: repeating-linear-gradient(to bottom right, green 15%, white 30%);
}
#blue {
background: repeating-linear-gradient(to bottom right, blue 15%, white 30%);
}
</style>
<div id='root'>
<div id='non_scrollable' class='outer'>
<div id='green' class='content'></div>
</div>
<div id='container' class='outer'>
<div id='blue' class='content'></div>
</div>
</div>
<!--
Tests that overscroll-behavior prevents scroll-propagation in the area and
direction as specified.
Manual Steps:
1. Make two scrolls on blue, in this order: scroll UP (or drag down), then
scroll LEFT (or drag right). Scroll (or drag) until nothing is
scrolling.
2. Call verify_y_prevented_and_set_boundary_prevents_x() from console
3. Repeat the same scrolls as in step 1
4. Call verify_x_prevented_and_set_boundary_allows_inner() from console
5. Repeat the same scrolls as in step 1
6. Call verify_inner_allowed_and_set_nonscrollable_allows_propagation()
from console
7. Make two separate scrolls on green, in this order: scroll UP
(or drag down), then scroll LEFT (or drag right). Scroll (or drag) until
nothing is scrolling.
8. Call verify_non_scrollable_allows_propagation() from console
</ol> -->
<script>
function setScrollPosition(scroller, offset) {
scroller.scrollTop = offset;
scroller.scrollLeft = offset;
}
async function scrollWithKeyboardWait(scrollElement, overflowScroller) {
const scrollerRect = scrollElement.getBoundingClientRect();
// Move pointer to scroll_element.
await new test_driver.Actions()
.pointerMove(scrollerRect.left + 200, scrollerRect.top + 100)
.pointerDown()
.pointerUp()
.send();
// Perform vertical scroll.
let scrollEndPromise = waitForScrollEndOrTimeout(overflowScroller, 1000);
await scrollElementByKeyboard('ArrowUp');
await scrollEndPromise;
// Perform horizontal scroll.
scrollEndPromise = waitForScrollEndOrTimeout(overflowScroller, 1000);
await scrollElementByKeyboard('ArrowLeft');
await scrollEndPromise;
}
promise_test(async t => {
await waitForCompositorReady();
container.style.overscrollBehaviorX = 'auto';
container.style.overscrollBehaviorY = 'none';
setScrollPosition(root, 100);
setScrollPosition(container, 0);
window.scrollTo(0, 0);
await scrollWithKeyboardWait(container, root);
assert_approx_equals(root.scrollTop, 100, 0.5,
"root got unexpected scroll on Y axis");
assert_approx_equals(root.scrollLeft, 0, 0.5,
"root expected to scroll on X axis");
}, "overscroll-behavior-y: none prevents scroll propagation on y axis");
promise_test(async t => {
await waitForCompositorReady();
container.style.overscrollBehaviorX = 'none';
container.style.overscrollBehaviorY = 'auto';
setScrollPosition(root, 100);
setScrollPosition(container, 0);
window.scrollTo(0, 0);
await scrollWithKeyboardWait(container, root);
assert_approx_equals(root.scrollTop, 0, 0.5,
"root expected to scroll on Y axis");
assert_approx_equals(root.scrollLeft, 100, 0.5,
"root got unexpected scroll on X axis");
}, "overscroll-behavior-x: none prevents scroll propagation on x axis");
promise_test(async t => {
await waitForCompositorReady();
container.style.overscrollBehaviorX = 'chain';
container.style.overscrollBehaviorY = 'none';
setScrollPosition(root, 100);
setScrollPosition(container, 0);
window.scrollTo(0, 0);
await scrollWithKeyboardWait(container, root);
assert_approx_equals(root.scrollTop, 100, 0.5,
"root got unexpected scroll on Y axis");
assert_approx_equals(root.scrollLeft, 0, 0.5,
"root expected to scroll on X axis");
}, "overscroll-behavior-x: chain allows scroll propagation on x axis");
promise_test(async t => {
await waitForCompositorReady();
container.style.overscrollBehaviorX = 'none';
container.style.overscrollBehaviorY = 'chain';
setScrollPosition(root, 100);
setScrollPosition(container, 0);
window.scrollTo(0, 0);
await scrollWithKeyboardWait(container, root);
assert_approx_equals(root.scrollTop, 0, 0.5,
"root expected to scroll on Y axis");
assert_approx_equals(root.scrollLeft, 100, 0.5,
"root got unexpected scroll on X axis");
}, "overscroll-behavior-y: chain allows scroll propagation on y axis");
promise_test(async t => {
await waitForCompositorReady();
container.style.overscrollBehaviorX = 'none';
container.style.overscrollBehaviorY = 'none';
setScrollPosition(root, 100);
setScrollPosition(container, 100);
window.scrollTo(0, 0);
await scrollWithKeyboardWait(container, container);
assert_approx_equals(container.scrollTop, 0, 0.5,
"inner container expected to scroll on Y axis");
assert_approx_equals(container.scrollLeft, 0, 0.5,
"inner container expected to scroll on X axis");
assert_approx_equals(root.scrollTop, 100, 0.5,
"root got unexpected scroll on Y axis");
assert_approx_equals(root.scrollLeft, 100, 0.5,
"root got unexpected scroll on X axis");
}, "overscroll-behavior allows inner scrolling when both axes are none");
promise_test(async t => {
await waitForCompositorReady();
non_scrollable.style.overscrollBehaviorX = 'none';
non_scrollable.style.overscrollBehaviorY = 'none';
setScrollPosition(root, 100);
window.scrollTo(0, 0);
await scrollWithKeyboardWait(non_scrollable, root);
assert_approx_equals(root.scrollLeft, 0, 0.5,
"root expected to scroll on X axis");
assert_approx_equals(root.scrollTop, 0, 0.5,
"root expected to scroll on Y axis");
}, "overscroll-behavior on non-scrollable area allows scroll propagation");
</script>