Skip to content

Don't update active document too early for same-origin navigations#12421

Open
shannonbooth wants to merge 1 commit into
whatwg:mainfrom
shannonbooth:active
Open

Don't update active document too early for same-origin navigations#12421
shannonbooth wants to merge 1 commit into
whatwg:mainfrom
shannonbooth:active

Conversation

@shannonbooth

@shannonbooth shannonbooth commented May 5, 2026

Copy link
Copy Markdown
Member

The active document was previously derived from the active window's
associated Document, which changes during create-and-initialize for
an initial about:blank same-origin navigation before the new document
is made active. By making active document a variable of browsing context
only set by the make active algorithm, this allows the document to be
updated at the right time.

One note - I have uncertainties here about how this interacts with "queue a global task" for tasks which are queued in the time between create-and-intialize and the point which make-active is made. But this is a little beyond my mental model for lifecycle of queued tasks. A potential fix there might be to change some instances of "queue a global task on the navigation and traversal task source given navigable's active window" to instead use "queue a task on the navigation and traversal task source given navigable's active document" - see: #12415 (comment). Even without that, I think this is an improvement anyhow, but let me know if I should investigate that more / improve my mental model of intended behavior.

(See WHATWG Working Mode: Changes for more details.)


/browsing-the-web.html ( diff )
/document-sequences.html ( diff )

@shannonbooth shannonbooth changed the title Defer updating the reused window's associated document until activation Don't update active document too early for same-origin navigations Jun 3, 2026
The active document was previously derived from the active window's
associated Document, which changes during create-and-initialize for
an initial about:blank same-origin navigation before the new document
is made active. By making active document a variable of browsing context
only set by the make active algorithm, this allows the document to be
updated at the right time.
@shannonbooth shannonbooth marked this pull request as ready for review June 3, 2026 20:36
@shannonbooth

Copy link
Copy Markdown
Member Author

Okay, I have marked this as undraft, as I'm now thinking that this may be the correct fix and it's ready for review. But my concern is that this fix might be incomplete, as it perhaps changes (or maybe more accurately, highlights) a fundamental invariant that this same-origin navigation path has.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant