Source code
Revision control
Copy as Markdown
Other Tools
Test Info: Warnings
- This test has a WPT meta file that expects 12 subtest issues.
- This WPT test may be referenced by the following Test IDs:
- /css/css-conditional/container-queries/scroll-state/scroll-direction-wm.html - WPT Dashboard Interop Dashboard
<!DOCTYPE html>
<title>@container: scroll-state(scroll-state) matching for writing direction</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>
.direction {
container-type: scroll-state;
width: 100px;
height: 100px;
overflow: scroll;
}
.filler {
height: 600px;
width: 600px;
}
.target {
@container scroll-state(direction: block-start) { --block-start: yes }
@container scroll-state(direction: block-end) { --block-end: yes }
@container scroll-state(direction: inline-start) { --inline-start: yes }
@container scroll-state(direction: inline-end) { --inline-end: yes }
@container scroll-state(direction: top) { --top: yes }
@container scroll-state(direction: left) { --left: yes }
@container scroll-state(direction: bottom) { --bottom: yes }
@container scroll-state(direction: right) { --right: yes }
}
.ltr { direction: ltr; }
.rtl { direction: rtl; }
.htb { writing-mode: horizontal-tb; }
.vlr { writing-mode: vertical-lr; }
.vrl { writing-mode: vertical-rl; }
</style>
<div class="direction h htb ltr"><div class="filler"><span class="target"></span></div></div>
<div class="direction h htb rtl"><div class="filler"><span class="target"></span></div></div>
<div class="direction h vlr ltr"><div class="filler"><span class="target"></span></div></div>
<div class="direction h vlr rtl"><div class="filler"><span class="target"></span></div></div>
<div class="direction h vrl ltr"><div class="filler"><span class="target"></span></div></div>
<div class="direction h vrl rtl"><div class="filler"><span class="target"></span></div></div>
<div class="direction v htb ltr"><div class="filler"><span class="target"></span></div></div>
<div class="direction v htb rtl"><div class="filler"><span class="target"></span></div></div>
<div class="direction v vlr ltr"><div class="filler"><span class="target"></span></div></div>
<div class="direction v vlr rtl"><div class="filler"><span class="target"></span></div></div>
<div class="direction v vrl ltr"><div class="filler"><span class="target"></span></div></div>
<div class="direction v vrl rtl"><div class="filler"><span class="target"></span></div></div>
<script>
setup(() => assert_implements_scroll_state_container_queries());
function match_scroll_direction(container_selector, expected_matches) {
let scroller = document.querySelector(container_selector + " .target");
let style = getComputedStyle(scroller);
for (let custom_prop of [ "--block-start",
"--block-end",
"--inline-start",
"--inline-end",
"--top",
"--left",
"--bottom",
"--right" ]) {
assert_equals(style.getPropertyValue(custom_prop) === "yes",
expected_matches[custom_prop] === true, custom_prop);
}
}
promise_test(async t => {
let scroller = document.querySelector(".direction.h.htb.ltr");
scroller.scrollBy(150, 0);
await waitForAnimationFrames(2);
match_scroll_direction(".direction.h.htb.ltr", { "--inline-end": true, "--right": true });
}, "scroll-state(direction) horizontal scrollbar horizontal-tb/ltr");
promise_test(async t => {
let scroller = document.querySelector(".direction.h.htb.rtl");
scroller.scrollBy(-150, 0);
await waitForAnimationFrames(2);
match_scroll_direction(".direction.h.htb.rtl", { "--inline-end": true, "--left": true });
}, "scroll-state(direction) horizontal scrollbar horizontal-tb/rtl");
promise_test(async t => {
let scroller = document.querySelector(".direction.h.vlr.ltr");
scroller.scrollBy(150, 0);
await waitForAnimationFrames(2);
match_scroll_direction(".direction.h.vlr.ltr", { "--block-end": true, "--right": true });
}, "scroll-state(direction) horizontal scrollbar vertical-lr/ltr");
promise_test(async t => {
let scroller = document.querySelector(".direction.h.vlr.rtl");
scroller.scrollBy(150, 0);
await waitForAnimationFrames(2);
match_scroll_direction(".direction.h.vlr.rtl", { "--block-end": true, "--right": true });
}, "scroll-state(direction) horizontal scrollbar vertical-lr/rtl");
promise_test(async t => {
let scroller = document.querySelector(".direction.h.vrl.ltr");
scroller.scrollBy(-150, 0);
await waitForAnimationFrames(2);
match_scroll_direction(".direction.h.vrl.ltr", { "--block-end": true, "--left": true });
}, "scroll-state(direction) horizontal scrollbar vertical-rl/ltr");
promise_test(async t => {
let scroller = document.querySelector(".direction.h.vrl.rtl");
scroller.scrollBy(-150, 0);
await waitForAnimationFrames(2);
match_scroll_direction(".direction.h.vrl.rtl", { "--block-end": true, "--left": true });
}, "scroll-state(direction) horizontal scrollbar vertical-rl/rtl");
promise_test(async t => {
let scroller = document.querySelector(".direction.v.htb.ltr");
scroller.scrollBy(0, 150);
await waitForAnimationFrames(2);
match_scroll_direction(".direction.v.htb.ltr", { "--block-end": true, "--bottom": true });
}, "scroll-state(direction) vertical scrollbar horizontal-tb/ltr");
promise_test(async t => {
let scroller = document.querySelector(".direction.v.htb.rtl");
scroller.scrollBy(0, 150);
await waitForAnimationFrames(2);
match_scroll_direction(".direction.v.htb.rtl", { "--block-end": true, "--bottom": true });
}, "scroll-state(direction) vertical scrollbar horizontal-tb/rtl");
promise_test(async t => {
let scroller = document.querySelector(".direction.v.vlr.ltr");
scroller.scrollBy(0, 150);
await waitForAnimationFrames(2);
match_scroll_direction(".direction.v.vlr.ltr", { "--inline-end": true, "--bottom": true });
}, "scroll-state(direction) vertical scrollbar vertical-lr/ltr");
promise_test(async t => {
let scroller = document.querySelector(".direction.v.vlr.rtl");
scroller.scrollBy(0, -150);
await waitForAnimationFrames(2);
match_scroll_direction(".direction.v.vlr.rtl", { "--inline-end": true, "--top": true });
}, "scroll-state(direction) vertical scrollbar vertical-lr/rtl");
promise_test(async t => {
let scroller = document.querySelector(".direction.v.vrl.ltr");
scroller.scrollBy(0, 150);
await waitForAnimationFrames(2);
match_scroll_direction(".direction.v.vrl.ltr", { "--inline-end": true, "--bottom": true });
}, "scroll-state(direction) vertical scrollbar vertical-rl/ltr");
promise_test(async t => {
let scroller = document.querySelector(".direction.v.vrl.rtl");
scroller.scrollBy(0, -150);
await waitForAnimationFrames(2);
match_scroll_direction(".direction.v.vrl.rtl", { "--inline-end": true, "--top": true });
}, "scroll-state(direction) vertical scrollbar vertical-rl/rtl");
</script>