Navigation API: Don't run navigation handlers until entry is committed.#12256
Open
farre wants to merge 1 commit intowhatwg:mainfrom
Open
Navigation API: Don't run navigation handlers until entry is committed.#12256farre wants to merge 1 commit intowhatwg:mainfrom
farre wants to merge 1 commit intowhatwg:mainfrom
Conversation
Currently per spec, #update-the-navigation-api-entries-for-a-same-document-navigation will be called in different order to the #wait-for-all navigation handler list depending on if the navigation is intercepted or not. This is not ideal, but even more so, in case of a "traverse" navigation, the callback passed to the #wait-for-all and the might be called before the call to #update-the-navigation-api-entries-for-a-same-document-navigation has happened. This means that we'll run the finish steps with the wrong session history entry. Since all same document navigations, intercepted or otherwise, eventually call #update-the-navigation-api-entries-for-a-same-document-navigation we can ensure that we never run the navigation handlers with bad state. This patch also reverts the patch that introduced always having a method tracker, since that was intended to solve this issue but failed doing so. Fixes whatwg#12222, and whatwg#12165. Reverts whatwg#11814.
noamr
approved these changes
Mar 16, 2026
Collaborator
noamr
left a comment
There was a problem hiding this comment.
LGTM, thanks for digging in to this!
|
|
||
| <li><p>Let <var>navigateEvent</var> be <var>navigation</var>'s <span>ongoing <code | ||
| data-x="event-navigate">navigate</code> event</span>.</p></li> | ||
| <li><p>Let <var>apiMethodTracker</var> be <var>navigation</var>'s <span>ongoing API method tracker</span></p></li> |
Collaborator
There was a problem hiding this comment.
Suggested change
| <li><p>Let <var>apiMethodTracker</var> be <var>navigation</var>'s <span>ongoing API method tracker</span></p></li> | |
| <li><p>Let <var>apiMethodTracker</var> be <var>navigation</var>'s <span>ongoing API method tracker</span></p></li> |
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Currently per spec, #update-the-navigation-api-entries-for-a-same-document-navigation will be called in different order to the #wait-for-all navigation handler list depending on if the navigation is intercepted or not. This is not ideal, but even more so, in case of a "traverse" navigation, the callback passed to the #wait-for-all and the might be called before the call to #update-the-navigation-api-entries-for-a-same-document-navigation has happened.
This means that we'll run the finish steps with the wrong session history entry.
Since all same document navigations, intercepted or otherwise, eventually call #update-the-navigation-api-entries-for-a-same-document-navigation we can ensure that we never run the navigation handlers with bad state.
This patch also reverts the patch that introduced always having a method tracker, since that was intended to solve this issue but failed doing so.
Fixes #12222, and #12165. Reverts #11814.
(See WHATWG Working Mode: Changes for more details.)
/nav-history-apis.html ( diff )