Files
sousa-gecko/testing/web-platform/tests/css/cssom-view/scroll-behavior-smooth.html
T
Mustaq Ahmed e123b14b4f Bug 2015207 [wpt PR 57631] - [CodeHealth] Fix a missing scrollTo call in scroll-behavior-smooth.html, a=testonly
Automatic update from web-platform-tests
[CodeHealth] Fix a missing scrollTo call in scroll-behavior-smooth.html

The missing window.scrollTo call went unnoticed because the following
assertion have been passing trivially!

This CL also ports the test to promise_tests and fix the promise_setup
call.

Bug: 41406914
Change-Id: I347e2b24609dad3b01c798d7033c86cadb7a6bb5
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/7546975
Auto-Submit: Mustaq Ahmed <mustaq@chromium.org>
Commit-Queue: Mustaq Ahmed <mustaq@chromium.org>
Commit-Queue: David Awogbemila <awogbemila@chromium.org>
Reviewed-by: David Awogbemila <awogbemila@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1581136}

--

wpt-commits: 8cb3092d165a0fb22c9dd80785f6e89c5ab13da2
wpt-pr: 57631
2026-02-12 13:03:38 +00:00

67 lines
2.2 KiB
HTML

<!DOCTYPE html>
<title>cssom-view - scroll-behavior: smooth</title>
<meta name="timeout" content="long">
<meta name="viewport" content="width=device-width,initial-scale=1">
<link rel="author" title="Rune Lillesveen" href="mailto:futhark@chromium.org">
<link rel="help" href="https://drafts.csswg.org/cssom-view/#smooth-scrolling">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/dom/events/scrolling/scroll_support.js"></script>
<style>
.filler { height: 10000px }
.smooth {
scroll-behavior: smooth;
}
#scrollable {
overflow: scroll;
width: 100px;
height: 100px;
}
</style>
<div id="testContainer">
<div id="scrollable">
<div class="filler"></div>
</div>
<div class="filler"></div>
</div>
<script>
promise_setup(async () => {
await waitForCompositorReady();
});
promise_test(async () => {
scrollable.scrollTo(0, 5000);
assert_equals(scrollable.scrollTop, 5000, "Initially scrolls instantly");
scrollable.scrollTo(0, 0);
scrollable.className = "smooth";
scrollable.scrollTo(0, 5000);
assert_less_than(scrollable.scrollTop, 5000, "scroll-behavior:smooth should not scroll instantly");
scrollable.className = "";
scrollable.scrollTo(0, 0);
}, "scroll-behavior: smooth on DIV element");
promise_test(async () => {
window.scrollTo(0, 5000);
assert_equals(window.scrollY, 5000, "Initially scrolls instantly");
window.scrollTo(0, 0);
document.documentElement.className = "smooth";
window.scrollTo(0, 5000);
assert_less_than(window.scrollY, 5000, "scroll-behavior:smooth should not scroll instantly");
document.documentElement.className = "";
window.scrollTo(0, 0);
}, "HTML element scroll-behavior should propagate to viewport");
promise_test(async () => {
window.scrollTo(0, 5000);
assert_equals(window.scrollY, 5000, "Initially scrolls instantly");
window.scrollTo(0, 0);
document.body.className = "smooth";
window.scrollTo(0, 5000);
assert_equals(window.scrollY, 5000, "scroll-behavior:smooth on BODY should scroll viewport instantly");
document.body.className = "";
window.scrollTo(0, 0);
}, "BODY element scroll-behavior should not propagate to viewport");
</script>