diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 09:22:09 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 09:22:09 +0000 |
commit | 43a97878ce14b72f0981164f87f2e35e14151312 (patch) | |
tree | 620249daf56c0258faa40cbdcf9cfba06de2a846 /testing/web-platform/tests/css/css-scroll-snap/snap-to-transformed-target.html | |
parent | Initial commit. (diff) | |
download | firefox-upstream.tar.xz firefox-upstream.zip |
Adding upstream version 110.0.1.upstream/110.0.1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'testing/web-platform/tests/css/css-scroll-snap/snap-to-transformed-target.html')
-rw-r--r-- | testing/web-platform/tests/css/css-scroll-snap/snap-to-transformed-target.html | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/testing/web-platform/tests/css/css-scroll-snap/snap-to-transformed-target.html b/testing/web-platform/tests/css/css-scroll-snap/snap-to-transformed-target.html new file mode 100644 index 0000000000..b8604269b4 --- /dev/null +++ b/testing/web-platform/tests/css/css-scroll-snap/snap-to-transformed-target.html @@ -0,0 +1,56 @@ +<!DOCTYPE html> +<link rel="help" href="https://drafts.csswg.org/css-scroll-snap-1/#scroll-snap-type" /> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<style> +div { + position: absolute; +} +#scroller { + overflow: hidden; /* TODO: Use scrollbar-width: none */ + scroll-snap-type: x mandatory; + width: 500px; + height: 500px; +} +.space { + width: 2000px; + height: 2000px; +} +#target { + height: 200px; + width: 200px; + left: 50px; + background-color: blue; +} +</style> +<div id="scroller"> + <div class="space"></div> + <div id="target"></div> +</div> +<script> +test(() => { + target.style.scrollSnapAlign = "start"; + target.style.transform = "translateX(300px)"; + scroller.scrollTo(10, 0); + assert_equals(scroller.scrollLeft, 350 /* left + translateX(300px) */); + assert_equals(scroller.scrollTop, 0); +}, "Snaps to the transformed snap start position"); + +test(() => { + target.style.scrollSnapAlign = "end"; + target.style.transform = "translateX(300px)"; + scroller.scrollTo(10, 0); + assert_equals(scroller.scrollLeft, + 50 /* left + width + translateX(300px) - scroller.width */); + assert_equals(scroller.scrollTop, 0); +}, "Snaps to the transformed snap end position"); + +test(() => { + target.style.scrollSnapAlign = "start"; + target.style.transform = "translateX(-100px)"; + scroller.scrollTo(10, 0); + assert_equals(scroller.scrollLeft, 0); + assert_equals(scroller.scrollTop, 0); +}, "Snaps to visible top left position of the transformed box"); + +</script> |