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
61 lines
2.1 KiB
HTML
61 lines
2.1 KiB
HTML
<!DOCTYPE html>
|
|
<title>Window.scroll* methods returning promises</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/#extensions-to-the-window-interface">
|
|
<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";
|
|
|
|
const scroll_methods = ["scroll", "scrollTo", "scrollBy"];
|
|
|
|
function reset() {
|
|
window.scrollTo({ top: 0 });
|
|
assert_equals(window.scrollY, 0, "Sanity check starting position");
|
|
}
|
|
|
|
promise_setup(async () => {
|
|
await waitForCompositorReady();
|
|
});
|
|
|
|
for (const scroll_method of scroll_methods) {
|
|
for (const behavior of ["auto", "instant", "smooth"]) {
|
|
const test_label = `Window.${scroll_method}(${behavior})`;
|
|
|
|
promise_test(async () => {
|
|
let result = window[scroll_method]({ behavior: behavior });
|
|
assert_true(result instanceof Promise);
|
|
const result_value = await result;
|
|
assert_equals(typeof result_value, "object");
|
|
assert_equals(typeof result_value.interrupted, "boolean");
|
|
}, `${test_label}: return type`);
|
|
|
|
promise_test(async () => {
|
|
reset();
|
|
const offset = 5000;
|
|
|
|
let promise = window[scroll_method]({ top: offset, behavior: behavior });
|
|
|
|
if (behavior != "smooth") {
|
|
assert_equals(window.scrollY, offset, "Position before await");
|
|
} else {
|
|
assert_true(0 <= window.scrollY && window.scrollY < offset,
|
|
"Position before await");
|
|
}
|
|
|
|
const result_value = await promise;
|
|
assert_equals(window.scrollY, offset, "Position after await");
|
|
assert_equals(typeof result_value, "object");
|
|
assert_equals(typeof result_value.interrupted, "boolean");
|
|
}, `${test_label}: promise behavior`);
|
|
}
|
|
}
|
|
</script>
|