✅ test(cssom): validate cascade against jsdom#582
Merged
Conversation
The CSSOM cascade shipped with tox-dev#546 was only covered by its own unit tests, which prove the code runs but not that it resolves the cascade the way the CSS specifications require. WPT's css/ suite is the authority, but those are testharness.js browser tests that cannot run against a Python library. Following the differential pattern the other oracle suites use, this adds a jsdom-backed conformance check: a Node runner resolves getComputedStyle through jsdom while turbohtml resolves the same 39 fixtures, and the two are compared across every axis the cascade implements. A spec-asserted half of each case runs without Node so the coverage gate holds where the oracle is absent. Colors are compared after normalizing both sides to an rgba tuple, since turbohtml keeps the computed value unserialized by design. turbohtml matched jsdom on all 75 oracle-checked properties. The only divergences are the documented boundaries (no user-agent stylesheet, the curated shorthand set) plus one where turbohtml is the more conformant of the two: it expands the overflow shorthand to overflow-x/overflow-y per CSS Overflow 3, which jsdom leaves at its initial value.
Merging this PR will not alter performance
Comparing Footnotes
|
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.
The CSSOM cascade and
getComputedStylethat landed in #546 came with unit tests that prove the code runs, not that it resolves the cascade the way the CSS specifications require. The authority is web-platform-tests'css/suite, but those aretestharness.jsbrowser tests that assert ongetComputedStyleinside a real DOM and never run against a Python library. This validates #546 against a reference implementation instead, the differential pattern the other oracle suites in this repo already use.A Node runner (
tools/bench/node/cssom_jsdom_runner.js) resolves the cascade through jsdom'sgetComputedStyle(backed by cssstyle, which passes most of WPT's CSSOM suite) while the Python side resolves the same 39 fixtures throughturbohtml.cssom.computed_style. The harness then compares the two across every axis the cascade implements: specificity, source order,!important, the style attribute, inheritance,inherit/initial/unset/revert, initial values, and distributive shorthand expansion. Two fixtures come fromcss/css-cascade(inherit-initial,important-vs-inline-001) and carry the value the WPT test itself asserts. 🔍 Each case also runs a spec-asserted check that needs no Node, so the coverage gate holds on the free-threaded, 3.15, and Windows cells where the oracle is absent, and the jsdom half skips cleanly when node or jsdom is missing. For a color the harness folds both sides to an(r, g, b, a)tuple before comparing, sinceturbohtmlkeeps the computed value unserialized by design where jsdom writesrgb(...).turbohtml matched jsdom on all 75 oracle-checked properties. ✅ The remaining divergences trace to boundaries the explanation doc already documents: no user-agent stylesheet (author-origin cascade only) and a curated shorthand set that expands the distributive shorthands but not the grammar-parsed
border/outlinefamily, which the suite pins with a strictxfail. One divergence runs the other way, where turbohtml is the more conformant of the two: it expands theoverflowshorthand tooverflow-x/overflow-yper CSS Overflow 3 §2.1 and matches browsers, while jsdom leaves those longhands at their initialvisible. jsdom also returns the literalrevertkeyword rather than resolving it, so the suite checksrevertandoverflowagainst the spec only.No production code changed, since the cascade resolved every implemented axis correctly. validates #546