Automatic update from web-platform-tests Expose interruption status of programmatic scroll requests. This CL makes ScrollPromiseResolver aware of interrupted scroll requests, and exposes the state through the object returned through a resolved promise. Also updates existing WPTs to cover this status. Bug: 41406914, 40712058 Change-Id: Id1b2363e9ac17f1c579098e953a576e6b66a7d5c Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/7693920 Auto-Submit: Mustaq Ahmed <mustaq@chromium.org> Commit-Queue: Mustaq Ahmed <mustaq@chromium.org> Reviewed-by: Vladimir Levin <vmpstr@chromium.org> Cr-Commit-Position: refs/heads/main@{#1621182} -- wpt-commits: e93033e2938770eb10658cfee8dcc9ac624cf091 wpt-pr: 59490
76 lines
2.6 KiB
HTML
76 lines
2.6 KiB
HTML
<!DOCTYPE html>
|
|
<title>Window scroll promises are interrupted correctly</title>
|
|
<meta name="timeout" content="long">
|
|
<meta name="viewport" content="width=device-width,initial-scale=1">
|
|
<link rel="author" title="Mustaq Ahmed" href="mailto:mustaq@chromium.org">
|
|
<link rel="help" href="https://drafts.csswg.org/cssom-view/#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 }
|
|
</style>
|
|
<div class="filler"></div>
|
|
<script>
|
|
"use strict";
|
|
|
|
function resetScrollPosition() {
|
|
window.scrollTo(0, 0);
|
|
assert_equals(window.scrollY, 0, "Sanity check initial position");
|
|
}
|
|
|
|
promise_setup(async () => {
|
|
await waitForCompositorReady();
|
|
});
|
|
|
|
for (const interrupt_behavior of ["auto", "smooth"]) {
|
|
promise_test(async () => {
|
|
resetScrollPosition();
|
|
|
|
const pos1 = 5000;
|
|
let promise1 = window.scrollTo({ top: pos1, behavior: "smooth" });
|
|
|
|
const pos2 = 6000;
|
|
let promise2 =
|
|
window.scrollTo({ top: pos2, behavior: interrupt_behavior });
|
|
|
|
assert_not_equals(window.scrollY, pos1,
|
|
"Position before first promise wait");
|
|
const result1 = await promise1;
|
|
assert_true(result1.interrupted, "Interruption bit in first promise");
|
|
assert_not_equals(window.scrollY, pos1,
|
|
"Position after first promise wait");
|
|
|
|
const result2 = await promise2;
|
|
assert_false(result2.interrupted, "Interruption bit in second promise");
|
|
assert_equals(window.scrollY, pos2,
|
|
"Position after interrupting promise wait");
|
|
}, `Window.scrollTo: interruption by ${interrupt_behavior} scroll call`);
|
|
|
|
promise_test(async () => {
|
|
resetScrollPosition();
|
|
|
|
const pos1 = 5000;
|
|
let promise1 = window.scrollBy({ top: pos1, behavior: "smooth" });
|
|
|
|
const pos2 = 2000;
|
|
let promise2 =
|
|
window.scrollBy({ top: pos2, behavior: interrupt_behavior });
|
|
|
|
assert_not_equals(window.scrollY, pos1,
|
|
"Position before first promise wait");
|
|
const result1 = await promise1;
|
|
assert_true(result1.interrupted, "Interruption bit in first promise");
|
|
assert_not_equals(window.scrollY, pos1,
|
|
"Position after first promise wait");
|
|
|
|
const result2 = await promise2;
|
|
assert_false(result2.interrupted, "Interruption bit in second promise");
|
|
assert_equals(window.scrollY, pos2,
|
|
"Position after interrupting promise wait");
|
|
}, `Window.scrollBy: interruption by ${interrupt_behavior} scroll call`);
|
|
}
|
|
|
|
|
|
</script>
|