-
Notifications
You must be signed in to change notification settings - Fork 3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
NavigateEvent.restoreScroll() should throw if repeated or called afte…
…r transition completes Fixed: 1310014 Change-Id: I7bd395d69b39117b981a24fb2da0e4f8d1045f86 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3564998 Auto-Submit: Nate Chapin <japhet@chromium.org> Reviewed-by: Domenic Denicola <domenic@chromium.org> Commit-Queue: Domenic Denicola <domenic@chromium.org> Cr-Commit-Position: refs/heads/main@{#987951}
- Loading branch information
1 parent
80bb197
commit 360fe71
Showing
2 changed files
with
27 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 25 additions & 0 deletions
25
navigation-api/scroll-restoration/manual-restoreScroll-repeated.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<!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); | ||
await navigation.navigate("#frag").finished; | ||
assert_not_equals(window.scrollY, 0); | ||
navigation.onnavigate = t.step_func(e => { | ||
e.transitionWhile(Promise.resolve(), { scrollRestoration: "manual" }); | ||
e.restoreScroll(); | ||
assert_equals(window.scrollY, 0); | ||
assert_throws_dom("InvalidStateError", () => e.restoreScroll()); | ||
}); | ||
await navigation.back().finished; | ||
assert_equals(window.scrollY, 0); | ||
}, "scrollRestoration: restoreScroll() should throw if called a second time"); | ||
</script> | ||
</body> |