✅ test(dom): validate source locations against parse5#584
Merged
gaborbernat merged 3 commits intoJul 7, 2026
Conversation
Merging this PR will not alter performance
Comparing Footnotes
|
c4c0a98 to
e1274d8
Compare
The conformance job checks out submodules recursively, so parse5 pulls its own nested html5lib-tests submodule, whose encoding fixtures hold non-UTF-8 bytes. pytest tried to collect them and aborted with a UnicodeDecodeError. Ignore the vendored parse5 directory the same way the unicodetools data submodule is already ignored, and drop the changelog fragment (conformance bug fixes carry none).
e1274d8 to
d156093
Compare
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.
parse(source_locations=True)ships as turbohtml's take on parse5'ssourceCodeLocationInfo, so the spans it stamps only mean something if they land where parse5's do. 🎯 This validates them against the reference implementation on parse5's own location-info corpus: the five real-world documents (CERN, a DX portal, the parse5 GitHub page, the WHATWG HTML spec, and a MediaWiki article) that parse5's suite parses to exercise its location code.parse5 is JavaScript, so a committed Node runner (
tools/bench/node/parse5_location_runner.js, reusing the existing parse5 competitor setup) emits every element's start-tag, end-tag, and per-attribute spans, and a pytest harness parses the same newline-normalized input through turbohtml and compares span-for-span. Both sides key elements by start-tag start offset and normalize to turbohtml's convention (parse5's columns are 1-based, its offsets and lines match), and turbohtml parses withscripting=Trueto line the trees up with parse5's default. The corpus is a pinned shallow submodule undertests/conformance/parse5; the harness skips when Node or the submodule is absent, the way the*_differential.pyoracles do, so it stays out of the coverage gate. All 9767 elements agree on all three span kinds.The corpus surfaced a real bug. 🐛 A
body,html, orformelement that the source closes with its own tag leftsource_location.end_tagatNone: these three close through an insertion-mode switch or an out-of-order stack removal, never the normal pop that stamps the end-tag span, so an explicit</body>,</html>, or</form>went unrecorded. Arecord_end_tag_locationhelper now stamps them from those handlers; the start-tag and per-attribute spans were already byte-exact against parse5 before the fix.Validates #548.