Source code
Revision control
Copy as Markdown
Other Tools
Test Info:
- This WPT test may be referenced by the following Test IDs:
- /css/css-conditional/container-queries/scroll-state/scroll-state-overflowing-layout-change.html - WPT Dashboard Interop Dashboard
<!DOCTYPE html>
<title>@container: scroll-state(overflowing) 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;
--overflowing: no;
@container scroll-state(overflowing) {
--overflowing: 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("--overflowing"), "yes");
}, "Check scroll-state(overflowing) initially matching");
promise_test(async t => {
t.add_cleanup(async () => target.className = "");
target.className = "small";
await waitForAnimationFrames(2);
assert_equals(getComputedStyle(target).getPropertyValue("--overflowing"), "no",
"#target not overflowing #scroller");
target.className = "";
await waitForAnimationFrames(2);
assert_equals(getComputedStyle(target).getPropertyValue("--overflowing"), "yes",
"#target overflowing #scroller again");
}, "Check scroll-state(overflowing) not matching after layout change no longer causing overflow");
</script>