Source code
Revision control
Copy as Markdown
Other Tools
Test Info: Warnings
- This test has a WPT meta file that expects 1 subtest issues.
- This WPT test may be referenced by the following Test IDs:
- /css/css-overflow/scroll-marker-activation-scroll.html - WPT Dashboard Interop Dashboard
<!doctype html>
<meta charset="utf-8">
<title>CSS Test: ::scroll-marker only scrolls associated scrolling container</title>
<script src="/dom/events/scrolling/scroll_support.js"></script>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/resources/testdriver.js"></script>
<script src="/resources/testdriver-actions.js"></script>
<script src="/resources/testdriver-vendor.js"></script>
<style>
body {
margin: 0;
}
#ancestor-scroller {
border: 2px solid gray;
width: 600px;
height: 150px;
overflow: auto;
position: relative;
}
#marker-scroller {
height: 300px;
overflow: auto;
scroll-snap-type: x mandatory;
position: relative;
scroll-marker-group: before;
white-space: nowrap;
}
#marker-scroller div {
scroll-snap-align: start;
box-sizing: border-box;
border-radius: 5px;
background: lightgray;
border: 1px solid black;
display: inline-block;
width: 500px;
height: 100%;
}
#marker-scroller::scroll-marker-group {
display: flex;
height: 100px;
}
#marker-scroller div::scroll-marker {
content: "";
width: 100px;
height: 100px;
box-sizing: border-box;
border-radius: 5px;
border: 1px solid black;
display: inline-block;
}
#marker-scroller div::scroll-marker:target-current {
background: blue;
}
</style>
<div id="ancestor-scroller">
<div id="marker-scroller">
<div>1</div>
<div id="target">2</div>
<div>3</div>
</div>
</div>
<script>
promise_test(async t => {
const target = document.querySelector('#target');
const ancestorScroller = document.querySelector('#ancestor-scroller');
const scroller = document.querySelector('#marker-scroller');
const scrollEndPromise = waitForScrollEndFallbackToDelayWithoutScrollEvent(scroller);
actions_promise = new test_driver.Actions()
.pointerMove(150, 50)
.pointerDown()
.pointerUp()
.send();
await actions_promise;
await scrollEndPromise;
assert_equals(scroller.scrollLeft, target.offsetLeft, "::scroll-marker activation scrolls to target");
assert_equals(ancestorScroller.scrollTop, 0, "::scroll-marker activation doesn't scroll ancestors");
});
</script>