From 5ab19b1fde1b57367b4e4901cc8fbf73a92c1c61 Mon Sep 17 00:00:00 2001 From: Alex Jakobi Date: Thu, 28 May 2026 10:27:06 +0200 Subject: [PATCH] Allow relative scrolls in unrelated-gesture-scroll-during-snap.html At the moment, unrelated-gesture-scroll-during-snap.html expects to snap back to 0, which can only be the case for absolute scrolls, because they don't have an intended direction. Relative scrolls however, must have an intended direction and therefore snap forward in that intended direction. See issue: https://github.com/web-platform-tests/interop/issues/1288 --- .../unrelated-gesture-scroll-during-snap.html | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/css/css-scroll-snap/unrelated-gesture-scroll-during-snap.html b/css/css-scroll-snap/unrelated-gesture-scroll-during-snap.html index 0390bdad257c9d..07b1a0bcf1f8bf 100644 --- a/css/css-scroll-snap/unrelated-gesture-scroll-during-snap.html +++ b/css/css-scroll-snap/unrelated-gesture-scroll-during-snap.html @@ -83,8 +83,13 @@ ]; let last_scroll_top = snapcontainer.scrollTop; async function scroll_listener() { - // If we are scrolling back to 0, we are snapping. - if (snapcontainer.scrollTop < last_scroll_top) { + // If scrollTop is decreasing we are snapping back (absolute-scroll + // case). + // If scrollTop is increasing past the initial scroll amount we are + // snapping forward (relative-scroll case). + if (snapcontainer.scrollTop < last_scroll_top || + (snapcontainer.scrollTop > last_scroll_top && + snapcontainer.scrollTop > snap_scroll_amt)) { snapcontainer.removeEventListener("scroll", scroll_listener); await new test_driver.Actions().scroll(0, 0, 0, inputs.scroll_amt, { origin: other_container }).send(); @@ -101,8 +106,12 @@ .send(); await Promise.all(scrollend_promises); - assert_equals(snapcontainer.scrollTop, 0, - "snapcontainer snaps back to 0"); + const second_snap_offset = + snapcontainer.querySelectorAll(".snaparea")[1].offsetTop; + assert_true(snapcontainer.scrollTop === 0 || + snapcontainer.scrollTop === second_snap_offset, + "snapcontainer snaps to a snap point (0 or " + + second_snap_offset + "), got " + snapcontainer.scrollTop); assert_equals(other_container.scrollTop, expectations.expectedScrollTop, `${other_container.id} is at expected scroll offset.`); }