Source code

Revision control

Copy as Markdown

Other Tools

Test Info:

<!DOCTYPE html>
<title>@container: scroll-state(scrollable) layout change</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 {
container-type: scroll-state;
overflow: auto;
width: 100px;
height: 100px;
}
#target {
width: 200px;
height: 200px;
--scrollable: no;
@container scroll-state(scrollable) {
--scrollable: yes;
}
}
#target.small {
width: 10px;
height: 10px;
}
</style>
<div id="scroller">
<div id="target"></div>
</div>
<script>
setup(() => assert_implements_scroll_state_container_queries());
promise_test(async t => {
await waitForAnimationFrames(2);
assert_equals(getComputedStyle(target).getPropertyValue("--scrollable"), "yes");
}, "Check scroll-state(scrollable) initially matching");
promise_test(async t => {
t.add_cleanup(async () => target.className = "");
target.className = "small";
await waitForAnimationFrames(2);
assert_equals(getComputedStyle(target).getPropertyValue("--scrollable"), "no",
"#target not scrollable #scroller");
target.className = "";
await waitForAnimationFrames(2);
assert_equals(getComputedStyle(target).getPropertyValue("--scrollable"), "yes",
"#target scrollable #scroller again");
}, "Check scroll-state(scrollable) not matching after layout change no longer causing overflow");
</script>