Skip to content

Drop a node the adoption agency cannot reinsert#12709

Open
annevk wants to merge 1 commit into
mainfrom
adoption-agency-drop-node
Open

Drop a node the adoption agency cannot reinsert#12709
annevk wants to merge 1 commit into
mainfrom
adoption-agency-drop-node

Conversation

@annevk

@annevk annevk commented Jul 19, 2026

Copy link
Copy Markdown
Member

Drop a node the adoption agency cannot reinsert

The adoption agency algorithm's "Insert lastNode ... at the adjusted insertion
location" step moves an already-inserted node. Script running during parsing can
reparent that node first, so the move would either form a cycle — including one
that crosses a shadow root or a template's contents, i.e. where lastNode is a
host-including inclusive ancestor of the target — or target a Document that
already has an element child. The step used a low-level insertion with no
validity check, so such a move built a cyclic or otherwise invalid tree.

Tests: web-platform-tests/wpt#61398

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


/infrastructure.html ( diff )
/parsing.html ( diff )

The adoption agency algorithm's "Insert lastNode ... at the adjusted insertion
location" step moves an already-inserted node. Script running during parsing can
reparent that node first, so the move would either form a cycle — including one
that crosses a shadow root or a template's contents, i.e. where lastNode is a
host-including inclusive ancestor of the target — or target a Document that
already has an element child. The step used a low-level insertion with no
validity check, so such a move built a cyclic or otherwise invalid tree.

Tests: web-platform-tests/wpt#61398
brave-builds pushed a commit to brave/chromium that referenced this pull request Jul 20, 2026
Make a few check when moving around nodes with AAA.

The tests are internal temporarily until the upstream WPT and spec PR
land, but that process shouldn't delay fixing the crash.

See whatwg/html#12709

Bug: 536662911
Change-Id: Ia357a2efea8029129b68b7fe647de4d7ba450b42
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/8124514
Commit-Queue: Noam Rosenthal <nrosenthal@google.com>
Reviewed-by: David Baron <dbaron@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1664983}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Development

Successfully merging this pull request may close these issues.

1 participant