Source code

Revision control

Copy as Markdown

Other Tools

Test Info:

<!DOCTYPE html>
<title>@container: scroll-state(overflowing) changed after scroll</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/css/css-conditional/container-queries/support/cq-testcommon.js"></script>
<script src="/css/css-transitions/support/helper.js"></script>
<style>
#scroller {
width: 200px;
height: 200px;
container-type: scroll-state;
overflow-y: scroll;
}
#filler {
height: 600px;
}
#target {
--top: no;
--bottom: no;
@container scroll-state(overflowing: top) {
--top: yes;
}
@container scroll-state(overflowing: bottom) {
--bottom: yes;
}
}
</style>
<div id="scroller">
<div id="filler">
<div id="target"></div>
</div>
</div>
<script>
setup(() => assert_implements_scroll_state_container_queries());
promise_test(async t => {
await waitForAnimationFrames(2);
assert_equals(getComputedStyle(target).getPropertyValue("--top"), "no");
assert_equals(getComputedStyle(target).getPropertyValue("--bottom"), "yes");
assert_equals(scroller.scrollTop, 0);
}, "Check that scroll-state(overflowing) matches bottom before scroll");
promise_test(async t => {
scroller.scrollTop = 200;
await waitForAnimationFrames(2);
assert_equals(getComputedStyle(target).getPropertyValue("--top"), "yes");
assert_equals(getComputedStyle(target).getPropertyValue("--bottom"), "yes");
assert_equals(scroller.scrollTop, 200);
}, "Check that scroll-state(overflowing) matches both top and bottom in a middle position");
promise_test(async t => {
scroller.scrollTop = 400;
await waitForAnimationFrames(2);
assert_equals(getComputedStyle(target).getPropertyValue("--top"), "yes");
assert_equals(getComputedStyle(target).getPropertyValue("--bottom"), "no");
assert_equals(scroller.scrollTop, 400);
}, "Check that scroll-state(overflowing) matches both top when scrolled to the end");
</script>