Skip to content

Commit

Permalink
[navigation API] Fix flaky scroll restoration test
Browse files Browse the repository at this point in the history
after-transition-intercept-handler-modifies.html sometimes fails
because the scroll restoration is being overridden if the layout
changes from the previous same document navigation have not yet been
applied. This becomes more consistent when same document navigation IPCs
are prioritized (see crrev.com/c/4981177).

This CL changes the test to ensure rendering happens between the forward
and back navigations, which in turn ensures the new layout and scroll
position were updated before navigating back.

Bug: 1042118
Change-Id: Ia6a3768f8780f9ddaff80f7fd877ddca5c6184b7
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5080962
Commit-Queue: Scott Haseley <[email protected]>
Reviewed-by: Nate Chapin <[email protected]>
Cr-Commit-Position: refs/heads/main@{#1232997}
  • Loading branch information
shaseley authored and chromium-wpt-export-bot committed Dec 4, 2023
1 parent b88b515 commit ff2032f
Showing 1 changed file with 4 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@
}
);
await navigation.navigate("?go").finished;
// Ensure the layout changes and scroll position update from the first
// navigation are processed before navigating back, otherwise the restored
// scroll postion can be overwritten.
await new Promise(resolve => requestAnimationFrame(resolve));
await navigation.back().finished;
assert_equals(window.scrollY, 100);
}, "scroll: state should be saved before intercept handlers run");
Expand Down

0 comments on commit ff2032f

Please sign in to comment.