-
Notifications
You must be signed in to change notification settings - Fork 3k
/
vertical-scroll-programmatic.sub.html
60 lines (56 loc) · 2.07 KB
/
vertical-scroll-programmatic.sub.html
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
<!DOCTYPE html>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/feature-policy/experimental-features/resources/vertical_scroll_common.js"></script>
<style>
html, body {
border: 0;
margin: 0;
padding: 0;
height: 100%;
width: 100%;
}
iframe {
width: 95%;
height: 95%;
border: solid 1px gold;
margin-left: 0px;
margin-top: 0px;
}
</style>
<p> An <iframe> further below which is not allowed to block scroll.</p>
<iframe></iframe>
<p style="margin-top: 10000px"> Making sure there is room for vertical scroll </p>
<script>
"use strict";
test(() => {
window.scrollTo(large_number, large_number);
assert_false(
rect_intersects(visible_rect, iframe().getBoundingClientRect()),
"<iframe> bounds are inside visible rect:" +
JSON.stringify(iframe().getBoundingClientRect().toJSON()));
iframe().contentDocument.body.scrollIntoView({behavior: "instant"});
assert_true(
rect_intersects(visible_rect, iframe().getBoundingClientRect()),
"<iframe> bounds are outside visible rect:" +
JSON.stringify(iframe().getBoundingClientRect().toJSON()));
}, "Sanity-check: element.scrollIntoView() works fine on this page.");
promise_test(async() => {
window.scrollTo(large_number, large_number);
await loadUrlInIframe(same_origin_url + "?q=script");
assert_true(
rect_intersects(visible_rect, iframe().getBoundingClientRect()),
"Expected the <iframe> to scroll into view but its bounds are: " +
JSON.stringify(iframe().getBoundingClientRect().toJSON()));
},
"Verify a same-origin frame can always scroll into view.");
promise_test(async() => {
window.scrollTo(large_number, large_number);
await loadUrlInIframe(cross_origin_url + "?q=script");
assert_false(
rect_intersects(visible_rect, iframe().getBoundingClientRect()),
"Expected the <iframe> not to scroll into view but its bounds are: " +
JSON.stringify(iframe().getBoundingClientRect().toJSON()));
},
"Verify a cross-origin frame cannot scroll into view.");
</script>