Skip to content

createHTMLDocument() should not leave body in parsing state#66024

Merged
webkit-commit-queue merged 1 commit into
WebKit:mainfrom
annevk:eng/createHTMLDocument-should-not-leave-body-in-parsing-state
Jun 1, 2026
Merged

createHTMLDocument() should not leave body in parsing state#66024
webkit-commit-queue merged 1 commit into
WebKit:mainfrom
annevk:eng/createHTMLDocument-should-not-leave-body-in-parsing-state

Conversation

@annevk

@annevk annevk commented May 29, 2026

Copy link
Copy Markdown
Contributor

dd8dcc1

createHTMLDocument() should not leave body in parsing state
https://bugs.webkit.org/show_bug.cgi?id=315847

Reviewed by Ryosuke Niwa.

createHTMLDocument() used to populate the document with a write() call
without a corresponding close() call. This meant that IsParsingChildren
did not get unset, impacting :last-child and friends. A subtest of
shadow-dom/untriaged/shadow-trees/upper-boundary-encapsulation/test-009.html
caught this.

So we re-implement createHTMLDocument() the way the specification
requires. This also impacts readyState (it's now "complete" instead of
"loading") and we take this opportunity to upstream the local tests.

Upstream: web-platform-tests/wpt#60293
Canonical link: https://commits.webkit.org/314295@main

7cbd314

Misc iOS, visionOS, tvOS & watchOS macOS Linux Windows Apple Internal
✅ 🧪 style ✅ 🛠 ios ✅ 🛠 mac ✅ 🛠 wpe ✅ 🛠 win ⏳ 🛠 ios-apple
🧪 bindings ✅ 🛠 ios-sim ✅ 🛠 mac-AS-debug ✅ 🧪 wpe-wk2 ✅ 🧪 win-tests ⏳ 🛠 mac-apple
✅ 🧪 webkitperl ❌ 🧪 ios-wk2 ✅ 🧪 api-mac ✅ 🧪 api-wpe ⏳ 🛠 vision-apple
❌ 🧪 ios-wk2-wpt ✅ 🧪 api-mac-debug ✅ 🛠 gtk3-libwebrtc
✅ 🧪 api-ios ✅ 🧪 mac-wk1 ✅ 🛠 gtk
✅ 🛠 ios-safer-cpp ✅ 🧪 mac-wk2 ✅ 🧪 gtk-wk2
✅ 🛠 vision ✅ 🧪 mac-AS-debug-wk2 ✅ 🧪 api-gtk
✅ 🛠 vision-sim ✅ 🧪 mac-wk2-stress ✅ 🛠 playstation
✅ 🛠 🧪 unsafe-merge ✅ 🧪 vision-wk2 ✅ 🧪 mac-intel-wk2
✅ 🛠 tv ✅ 🛠 mac-safer-cpp
✅ 🛠 tv-sim ✅ 🧪 mac-site-isolation
✅ 🛠 watch
✅ 🛠 watch-sim

@annevk annevk self-assigned this May 29, 2026
@annevk annevk added the DOM For bugs specific to XML/HTML DOM elements (including parsing). label May 29, 2026
@webkit-ews-buildbot webkit-ews-buildbot added the merging-blocked Applied to prevent a change from being merged label May 29, 2026
@annevk annevk removed the merging-blocked Applied to prevent a change from being merged label May 30, 2026
@annevk annevk force-pushed the eng/createHTMLDocument-should-not-leave-body-in-parsing-state branch from cacee3d to 7cbd314 Compare May 30, 2026 07:12
@annevk annevk marked this pull request as ready for review May 30, 2026 07:14
@annevk annevk requested review from cdumez and rniwa as code owners May 30, 2026 07:14
@webkit-ews-buildbot webkit-ews-buildbot added the merging-blocked Applied to prevent a change from being merged label May 30, 2026
@annevk annevk removed the merging-blocked Applied to prevent a change from being merged label May 30, 2026
@webkit-ews-buildbot webkit-ews-buildbot added the merging-blocked Applied to prevent a change from being merged label May 30, 2026
@annevk annevk removed the merging-blocked Applied to prevent a change from being merged label May 30, 2026
@webkit-ews-buildbot webkit-ews-buildbot added the merging-blocked Applied to prevent a change from being merged label May 30, 2026
@annevk annevk removed the merging-blocked Applied to prevent a change from being merged label May 31, 2026
@annevk annevk added the unsafe-merge-queue Applied to send a pull request to merge-queue, but skip building and testing label Jun 1, 2026
https://bugs.webkit.org/show_bug.cgi?id=315847

Reviewed by Ryosuke Niwa.

createHTMLDocument() used to populate the document with a write() call
without a corresponding close() call. This meant that IsParsingChildren
did not get unset, impacting :last-child and friends. A subtest of
shadow-dom/untriaged/shadow-trees/upper-boundary-encapsulation/test-009.html
caught this.

So we re-implement createHTMLDocument() the way the specification
requires. This also impacts readyState (it's now "complete" instead of
"loading") and we take this opportunity to upstream the local tests.

Upstream: web-platform-tests/wpt#60293
Canonical link: https://commits.webkit.org/314295@main
@webkit-commit-queue webkit-commit-queue force-pushed the eng/createHTMLDocument-should-not-leave-body-in-parsing-state branch from 7cbd314 to dd8dcc1 Compare June 1, 2026 17:15
@webkit-commit-queue

Copy link
Copy Markdown
Collaborator

Committed 314295@main (dd8dcc1): https://commits.webkit.org/314295@main

Reviewed commits have been landed. Closing PR #66024 and removing active labels.

@webkit-commit-queue webkit-commit-queue merged commit dd8dcc1 into WebKit:main Jun 1, 2026
@webkit-commit-queue webkit-commit-queue removed the unsafe-merge-queue Applied to send a pull request to merge-queue, but skip building and testing label Jun 1, 2026
@annevk annevk deleted the eng/createHTMLDocument-should-not-leave-body-in-parsing-state branch June 1, 2026 17:17
beckysiegel pushed a commit to chromium/chromium that referenced this pull request Jun 17, 2026
This is basically the same as
WebKit/WebKit#66024

Imperatively building the document tree seems like a much better idea
than using document.write

Fixed: 522868200
Change-Id: Ie29f7b90717064409b17209b463da8f918e1e881
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/7927670
Commit-Queue: Joey Arhar <jarhar@chromium.org>
Reviewed-by: David Baron <dbaron@chromium.org>
Reviewed-by: Joey Arhar <jarhar@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1648491}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

DOM For bugs specific to XML/HTML DOM elements (including parsing).

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants