Skip to content

✅ test(cssom): validate cascade against jsdom#582

Merged
gaborbernat merged 1 commit into
tox-dev:mainfrom
gaborbernat:test/546-cssom-conformance
Jul 7, 2026
Merged

✅ test(cssom): validate cascade against jsdom#582
gaborbernat merged 1 commit into
tox-dev:mainfrom
gaborbernat:test/546-cssom-conformance

Conversation

@gaborbernat

Copy link
Copy Markdown
Member

The CSSOM cascade and getComputedStyle that 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 are testharness.js browser tests that assert on getComputedStyle inside 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's getComputedStyle (backed by cssstyle, which passes most of WPT's CSSOM suite) while the Python side resolves the same 39 fixtures through turbohtml.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 from css/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, since turbohtml keeps the computed value unserialized by design where jsdom writes rgb(...).

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/outline family, which the suite pins with a strict xfail. One divergence runs the other way, where turbohtml is the more conformant of the two: it expands the overflow shorthand to overflow-x/overflow-y per CSS Overflow 3 §2.1 and matches browsers, while jsdom leaves those longhands at their initial visible. jsdom also returns the literal revert keyword rather than resolving it, so the suite checks revert and overflow against the spec only.

No production code changed, since the cascade resolved every implemented axis correctly. validates #546

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.
@codspeed-hq

codspeed-hq Bot commented Jul 7, 2026

Copy link
Copy Markdown

Merging this PR will not alter performance

✅ 81 untouched benchmarks
⏩ 18 skipped benchmarks1


Comparing gaborbernat:test/546-cssom-conformance (68dccfa) with main (dee9eae)

Open in CodSpeed

Footnotes

  1. 18 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

@gaborbernat gaborbernat merged commit cf7c8c3 into tox-dev:main Jul 7, 2026
48 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant