diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 00:47:55 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 00:47:55 +0000 |
commit | 26a029d407be480d791972afb5975cf62c9360a6 (patch) | |
tree | f435a8308119effd964b339f76abb83a57c29483 /testing/web-platform/tests/css/css-scroll-snap/scroll-snap-stop-001.html | |
parent | Initial commit. (diff) | |
download | firefox-26a029d407be480d791972afb5975cf62c9360a6.tar.xz firefox-26a029d407be480d791972afb5975cf62c9360a6.zip |
Adding upstream version 124.0.1.upstream/124.0.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'testing/web-platform/tests/css/css-scroll-snap/scroll-snap-stop-001.html')
-rw-r--r-- | testing/web-platform/tests/css/css-scroll-snap/scroll-snap-stop-001.html | 96 |
1 files changed, 96 insertions, 0 deletions
diff --git a/testing/web-platform/tests/css/css-scroll-snap/scroll-snap-stop-001.html b/testing/web-platform/tests/css/css-scroll-snap/scroll-snap-stop-001.html new file mode 100644 index 0000000000..7d2a228688 --- /dev/null +++ b/testing/web-platform/tests/css/css-scroll-snap/scroll-snap-stop-001.html @@ -0,0 +1,96 @@ +<!DOCTYPE html> +<link rel="help" href="https://drafts.csswg.org/css-scroll-snap/#scroll-snap-stop" /> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<style> +div { + position: absolute; +} +#scroller { + width: 400px; + height: 400px; + overflow: scroll; + scroll-snap-type: both mandatory; +} +#space { + left: 0px; + top: 0px; + width: 2100px; + height: 2100px; +} +.target { + width: 50px; + height: 50px; + scroll-snap-align: start; +} +.origin { + left: 0px; + top: 0px; +} +.always-stop { + left: 100px; + top: 0px; + scroll-snap-stop: always; +} +.closer { + left: 200px; + top: 0px; +} +</style> + +<div id="scroller"> + <div id="space"></div> + <div class="target origin"></div> + <div class="target always-stop"></div> + <div class="target closer"></div> +</div> + +<script> +var scroller = document.getElementById("scroller"); +test(() => { + scroller.scrollTo(0, 0); + assert_equals(scroller.scrollLeft, 0); + assert_equals(scroller.scrollTop, 0); + + scroller.scrollBy(300, 0); + assert_equals(scroller.scrollLeft, 100); + assert_equals(scroller.scrollTop, 0); +}, "A scroll with intended direction and end position should not pass a snap " + + "area with scroll-snap-stop: always.") + +test(() => { + scroller.scrollTo(0, 0); + assert_equals(scroller.scrollLeft, 0); + assert_equals(scroller.scrollTop, 0); + + scroller.scrollTo(300, 0); + assert_equals(scroller.scrollLeft, 200); + assert_equals(scroller.scrollTop, 0); +}, "A scroll with intended end position should always choose the closest snap " + + "position regardless of the scroll-snap-stop value.") + +// Tests for programmatic scrolls beyond the scroller bounds. + +test(() => { + scroller.scrollTo(0, 0); + assert_equals(scroller.scrollLeft, 0); + assert_equals(scroller.scrollTop, 0); + + scroller.scrollBy(100000, 0); + assert_equals(scroller.scrollLeft, 100); + assert_equals(scroller.scrollTop, 0); +}, "A scroll outside bounds in the snapping axis with intended direction and " + + "end position should not pass a snap area with scroll-snap-stop: always.") + +test(() => { + scroller.scrollTo(0, 0); + assert_equals(scroller.scrollLeft, 0); + assert_equals(scroller.scrollTop, 0); + + scroller.scrollBy(300, -10); + assert_equals(scroller.scrollLeft, 100); + assert_equals(scroller.scrollTop, 0); +}, "A scroll outside bounds in the non-snapping axis with intended direction " + + "and end position should not pass a snap area with scroll-snap-stop: always.") + +</script> |