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-initially-overflowing.html - WPT Dashboard Interop Dashboard
<!DOCTYPE html>
<title>@container: scroll-state(overflowing) matching for initial rendering</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;
}
.auto {
overflow-y: auto;
}
.scroll {
overflow-y: scroll;
}
.clip {
overflow-y: clip;
}
.scrollable::after {
content: " ";
display: block;
height: 10000px;
}
span {
--top: no;
--bottom: no;
--none: no;
}
@container scroll-state(overflowing: top) {
span { --top: yes; }
}
@container scroll-state(overflowing: bottom) {
span { --bottom: yes; }
}
@container scroll-state(overflowing: none) {
span { --none: yes; }
}
</style>
<div class="scroller">
<span id="t1"></span>
</div>
<div class="scroller auto">
<span id="t2"></span>
</div>
<div class="scroller scroll">
<span id="t3"></span>
</div>
<div class="scroller clip">
<span id="t4"></span>
</div>
<div class="scroller scrollable">
<span id="t5"></span>
</div>
<div class="scroller auto scrollable">
<span id="t6"></span>
</div>
<div class="scroller scroll scrollable">
<span id="t7"></span>
</div>
<div class="scroller clip scrollable">
<span id="t8"></span>
</div>
<script>
setup(() => assert_implements_scroll_state_container_queries());
promise_test(async t => {
await waitForAnimationFrames(2);
assert_equals(getComputedStyle(t1).getPropertyValue("--top"), "no");
assert_equals(getComputedStyle(t1).getPropertyValue("--bottom"), "no");
assert_equals(getComputedStyle(t1).getPropertyValue("--none"), "yes");
}, "overflow:visible, no overflowing content - no matches");
promise_test(async t => {
assert_equals(getComputedStyle(t2).getPropertyValue("--top"), "no");
assert_equals(getComputedStyle(t2).getPropertyValue("--bottom"), "no");
assert_equals(getComputedStyle(t2).getPropertyValue("--none"), "yes");
}, "overflow:auto, no overflowing content - no matches");
promise_test(async t => {
assert_equals(getComputedStyle(t3).getPropertyValue("--top"), "no");
assert_equals(getComputedStyle(t3).getPropertyValue("--bottom"), "no");
assert_equals(getComputedStyle(t3).getPropertyValue("--none"), "yes");
}, "overflow:scroll, no overflowing content - no matches");
promise_test(async t => {
assert_equals(getComputedStyle(t4).getPropertyValue("--top"), "no");
assert_equals(getComputedStyle(t4).getPropertyValue("--bottom"), "no");
assert_equals(getComputedStyle(t4).getPropertyValue("--none"), "yes");
}, "overflow:clip, no overflowing content - no matches");
promise_test(async t => {
assert_equals(getComputedStyle(t5).getPropertyValue("--top"), "no");
assert_equals(getComputedStyle(t5).getPropertyValue("--bottom"), "no");
assert_equals(getComputedStyle(t5).getPropertyValue("--none"), "yes");
}, "overflow:visible, overflowing content - no matches");
promise_test(async t => {
assert_equals(getComputedStyle(t6).getPropertyValue("--top"), "no");
assert_equals(getComputedStyle(t6).getPropertyValue("--bottom"), "yes");
assert_equals(getComputedStyle(t6).getPropertyValue("--none"), "no");
}, "overflow:auto, overflowing content - matches overflowing:bottom");
promise_test(async t => {
assert_equals(getComputedStyle(t7).getPropertyValue("--top"), "no");
assert_equals(getComputedStyle(t7).getPropertyValue("--bottom"), "yes");
assert_equals(getComputedStyle(t7).getPropertyValue("--none"), "no");
}, "overflow:scroll, overflowing content - matches overflowing:bottom");
promise_test(async t => {
assert_equals(getComputedStyle(t8).getPropertyValue("--top"), "no");
assert_equals(getComputedStyle(t8).getPropertyValue("--bottom"), "no");
assert_equals(getComputedStyle(t8).getPropertyValue("--none"), "yes");
}, "overflow:clip, overflowing content - no matches");
</script>