fune/testing/web-platform/tests/navigation-api/scroll-behavior/manual-scroll-replace.html
Nate Chapin 87192c6c70 Bug 1780442 [wpt PR 34919] - Navigation API: Revamp intercepted-navigation scroll handling, a=testonly
Automatic update from web-platform-tests
Navigation API: Revamp intercepted-navigation scroll handling

Follows https://github.com/WICG/navigation-api/pull/239

Intent to Ship: https://groups.google.com/a/chromium.org/g/blink-dev/c/DKeklNbLG5s

Bug: 1345507
Change-Id: Id5c1b9d77953388dbe287f6403b0a49c8359d51b
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3758902
Reviewed-by: Chris Harrelson <chrishtr@chromium.org>
Reviewed-by: Domenic Denicola <domenic@chromium.org>
Commit-Queue: Nate Chapin <japhet@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1026382}

--

wpt-commits: 5fb15e04adca47cc972a2e4c665853aca6a1a5b9
wpt-pr: 34919
2022-07-22 02:09:17 +00:00

31 lines
1 KiB
HTML

<!doctype html>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<body>
<div style="height: 1000px; width: 1000px;"></div>
<div id="frag"></div>
<script>
promise_test(async t => {
// Wait for after the load event so that the navigation doesn't get converted
// into a replace navigation.
await new Promise(resolve => window.onload = () => t.step_timeout(resolve, 0));
assert_equals(window.scrollY, 0);
let intercept_resolve;
let navigate_event;
navigation.onnavigate = e => {
navigate_event = e;
e.intercept({ handler: () => new Promise(r => intercept_resolve = r),
scroll: "manual" });
};
let promises = navigation.navigate("#frag", { history: "replace" });
await promises.committed;
assert_equals(window.scrollY, 0);
navigate_event.scroll();
assert_not_equals(window.scrollY, 0);
intercept_resolve();
await promises.finished;
assert_not_equals(window.scrollY, 0);
}, "scroll: scroll() should work on a replace navigation");
</script>
</body>