summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/css/css-scroll-snap/scroll-on-large-element-not-covering-snapport.tentative.html
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 09:22:09 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 09:22:09 +0000
commit43a97878ce14b72f0981164f87f2e35e14151312 (patch)
tree620249daf56c0258faa40cbdcf9cfba06de2a846 /testing/web-platform/tests/css/css-scroll-snap/scroll-on-large-element-not-covering-snapport.tentative.html
parentInitial commit. (diff)
downloadfirefox-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/scroll-on-large-element-not-covering-snapport.tentative.html')
-rw-r--r--testing/web-platform/tests/css/css-scroll-snap/scroll-on-large-element-not-covering-snapport.tentative.html91
1 files changed, 91 insertions, 0 deletions
diff --git a/testing/web-platform/tests/css/css-scroll-snap/scroll-on-large-element-not-covering-snapport.tentative.html b/testing/web-platform/tests/css/css-scroll-snap/scroll-on-large-element-not-covering-snapport.tentative.html
new file mode 100644
index 0000000000..2db00d414a
--- /dev/null
+++ b/testing/web-platform/tests/css/css-scroll-snap/scroll-on-large-element-not-covering-snapport.tentative.html
@@ -0,0 +1,91 @@
+<!DOCTYPE html>
+<title>
+ A test case that scrolling to a point on large element where the snap area
+ doesn't cover over the snapport
+</title>
+<link rel="help" href="https://drafts.csswg.org/css-scroll-snap-1/#snap-overflow"/>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<style>
+div {
+ position: absolute;
+ width: 100%;
+}
+#scroller {
+ left: 10px;
+ height: 200px;
+ width: 100px;
+ overflow-y: scroll;
+ overflow-x: hidden;
+ scroll-snap-type: y mandatory;
+}
+.snap {
+ scroll-snap-align: start;
+ background-color: green;
+}
+.target {
+ background-color: red;
+ border-radius: 100%;
+ height: 88px;
+ top: 536px;
+}
+</style>
+<div id="scroller">
+ <div style="height: 2000px;"></div>
+ <div class="snap" style="top: 0px; height: 40px;">1</div>
+ <div class="snap" style="top: 40px; height: 40px;">2</div>
+ <div class="snap" style="top: 80px; height: 1000px;">3</div>
+ <div class="snap" style="top: 1080px; height: 40px;">4</div>
+ <div class="snap" style="top: 1120px; height: 40px;">5</div>
+ <div class="target"></div>
+</div>
+<script>
+test(() => {
+ const scroller = document.getElementById("scroller");
+
+ scroller.scrollBy(0, 10);
+ // Snap to the first snap point.
+ assert_equals(scroller.scrollLeft, 0);
+ assert_equals(scroller.scrollTop, 40);
+
+ scroller.scrollBy(0, 10);
+ // Snap to the second snap point.
+ assert_equals(scroller.scrollLeft, 0);
+ assert_equals(scroller.scrollTop, 80);
+
+ scroller.scrollBy(0, 100);
+ // Snap to the given scrolling position since the third snap target element
+ // is larger than the snapport.
+ assert_equals(scroller.scrollLeft, 0);
+ assert_equals(scroller.scrollTop, 180);
+
+ scroller.scrollBy(0, 100);
+ // Again, snap to the given scrolling position.
+ assert_equals(scroller.scrollLeft, 0);
+ assert_equals(scroller.scrollTop, 280);
+
+ // Scroll to a point where the third target element is still covering over the
+ // snapport.
+ scroller.scrollBy(0, 600);
+ assert_equals(scroller.scrollLeft, 0);
+ // Again, snap to the given scrolling position.
+ assert_equals(scroller.scrollTop, 880);
+
+ // Scroll to a point where the third target element is no longer convering
+ // over the snapport, rather the forth snap point is in the snapport.
+ scroller.scrollBy(0, 10);
+ // Now, snap to the forth snap point.
+ assert_equals(scroller.scrollLeft, 0);
+ assert_equals(scroller.scrollTop, 1080);
+
+ // Scroll back a bit.
+ scroller.scrollBy(0, -10);
+ // Now, snap back to the third snap point because at the moment when scrolling
+ // up by 10px, the large third snap target element isn't covering over the
+ // snapport, i.e. only bottom 10px of the large element is in the snapport.
+ // See https://github.com/w3c/csswg-drafts/issues/7262
+ assert_equals(scroller.scrollLeft, 0);
+ assert_equals(scroller.scrollTop, 80);
+}, 'There\'s no valid snap positions on large element if it doesn\'t cover ' +
+ 'the snapport');
+</script>