Skip to content

Conformance

Parsec is tested against the public suites that browsers and other parsers use: html5lib’s tokenizer and encoding tests, the tree-construction tests now kept in web-platform-tests, the web-platform-tests encoding data and URL tests, Unicode’s normalization tests, css-parsing-tests and the CSS tokenizer tests, and web-platform-tests’ CSS parsing tests. All of them run in cargo test, and CI runs cargo test --workspace on Linux, macOS and Windows for every pull request.

Every number on this page is what the test runners print, on main. CI writes the same counts into every run’s summary, so you can check them against the latest run (Counts from CI).

Suite Data Passed Failed Skipped
html5lib tokenizer crates/parsec/tests/html5lib-tests/tokenizer, html5lib-tests at commit c5495c5 7,042 0 4
WPT tree construction crates/parsec/tests/tree-construction, web-platform-tests at commit c119765 3,898 0 6
html5lib encoding crates/parsec/tests/html5lib-tests/encoding, same commit as the tokenizer tests 82 0 1
WPT encoding labels crates/parsec-encoding/tests/wpt, web-platform-tests at commit 0c423ab 228 0 0
WPT single-byte decoders the same 168 0 0
WPT ISO-2022-JP decoder the same 38 0 0
WPT GB18030 and GBK decoders the same 357 0 0
WPT legacy multi-byte pages the same 62,352 0 0
WPT DOM selector suite crates/parsec/tests/wpt-selectors, web-platform-tests at commit 1a2a0c5: querySelectorAll, matches and closest over selectors.js 1,719 0 8
WPT css/selectors, static cases the same commit; cases a browser isn’t needed for, extracted by scripts/wpt-selectors-cases.js 461 0 668
WPT URL parsing crates/parsec-url/tests/wpt/urltestdata.json, web-platform-tests at commit 6dac967 904 0 0
WPT URL origins the same file’s origin fields 421 0 0
WPT URL setters setters_tests.json, same commit 284 0 0
WPT ToASCII toascii.json, same commit 261 0 522
WPT IDNA IdnaTestV2.json, same commit 2,675 0 1
WPT IDNA, removed cases IdnaTestV2-removed.json, same commit 20 0 0
Unicode normalization crates/parsec-url/tests/unicode/NormalizationTest.txt, Unicode 18.0.0 20,172 0 0
css-parsing-tests crates/parsec-css/tests/css-parsing-tests, CourtBouillon/css-parsing-tests at commit 203ce36 5,096 3,270 0
css-parsing-tests <urange> crates/parsec-css/tests/urange, from rust-cssparser at commit 4765111 12 0 0
CSS tokenizer tests crates/parsec-css/tests/css-tokenizer-tests, romainmenke/css-tokenizer-tests at commit 0db1d12 287 0 0
WPT CSS parsing crates/parsec-css/tests/wpt-values, the static cases of web-platform-tests’ css/*/parsing at commit 1a2a0c5 14,758 135 129
WPT media queries crates/parsec-css/tests/wpt-media, the static cases of css/mediaqueries, mostly the Mozilla suite, at the same commit 1,370 0 14
WPT computed values crates/parsec-css/tests/wpt-computed, test_computed_value, the colour tests and the inheritance tests of css/*/parsing and css/*/inheritance*, with the files, at the same commit 11,356 755 355
WPT cascade, at-rules and pseudo-elements crates/parsec-css/tests/wpt-cascade, the static cases of css/css-cascade, css/css-conditional/container-queries, css/css-properties-values-api, css/css-counter-styles/counter-style-at-rule and css/css-pseudo, with the files, at the same commit 1,343 131 199

The runners print exactly this:

tokenizer: 7042 passed, 0 failed, 4 skipped (lone surrogates)
tree construction: 3898 passed, 0 failed, 6 skipped (need JavaScript)
html5lib encoding: 82 passed, 0 failed, 1 skipped (scripted); 75 of 82 decided by the sniffing alone
wpt-encoding-labels: 228 passed, 0 failed
wpt-encoding-single-byte: 168 passed, 0 failed
wpt-encoding-iso-2022-jp: 38 passed, 0 failed
wpt-encoding-gb18030: 357 passed, 0 failed
wpt-encoding-legacy-multi-byte: 62352 passed, 0 failed
encoding-legacy-multi-byte-encoder: 53813 passed, 0 failed
urltestdata.json: 904 passed, 0 failed, 0 skipped
urltestdata.json origin: 421 passed, 0 failed, 0 skipped
setters_tests.json: 284 passed, 0 failed, 0 skipped
toascii.json: 261 passed, 0 failed, 522 skipped (the <a> and <area> halves test HTML elements, not URL parsing)
IdnaTestV2.json: 2675 passed, 0 failed, 1 skipped (an empty input can't go through new URL())
IdnaTestV2-removed.json: 20 passed, 0 failed, 0 skipped
NormalizationTest.txt: 20172 passed, 0 failed, 0 skipped
css-parsing-tests: 5096 passed, 3270 failed, 0 skipped
6 color cases fail because custom color spaces need @color-profile, which isn't parsed yet
4 color cases fail because light-dark() is a pair of colors in the suite, and a color here
2760 color cases fail because the draft now clamps lightness and chroma when parsing them
488 color cases fail because the draft now writes a legacy color with `none` in its own function
urange: 12 passed, 0 failed
css-tokenizer-tests: 287 passed, 0 failed
wpt css parsing: 14758 passed, 135 failed, 129 skipped
invalid: 4920 passed, 150 failed
shorthand: 227 passed, 167 failed
valid: 8760 passed, 669 failed
wpt media queries: 1370 passed, 0 failed, 14 skipped
wpt computed values: 11356 passed, 755 failed, 355 skipped
computed: 10835 passed, 728 failed
inherited: 230 passed, 9 failed
initial: 222 passed, 17 failed
pseudo: 69 passed, 1 failed
wpt cascade: 1343 passed, 131 failed, 199 skipped

The encoding suites, what each case checks and why one html5lib case is skipped are on Encoding. The last line isn’t a WPT count: it’s an encoder round trip over the same pages, since WPT’s own encoder tests need a browser. The streaming parser’s tests, which cut the same inputs into pieces and compare with the whole, are on Encoding too: 418,818 cuts, 0 differ.

The CSS suite’s 12 failures are all cases where the current CSS Syntax draft parses differently from the older one css-parsing-tests was written for: nine expect a unicode-range token outside a unicode-range descriptor, one has U+0080 as an ident code point, and two are parse a declaration before nesting made it stop at ;. They’re listed in the runner with their reasons. CSS has the details.

The suite’s color_* files, skipped until typed values, now run: 4,803 of their 8,061 cases pass, and the runner checks each of the other 3,258 against one of four ways CSS Color has changed since the suite was written, counting it under that, so an unexplained failure fails the run. 2,760 are lightness and chroma, which the current draft clamps when parsing and the suite doesn’t. CSS values has the details.

The WPT CSS parsing cases are every test_valid_value, test_invalid_value and test_shorthand_value call in css/*/parsing/*.html, extracted by running each file in a Node sandbox: 14,893 cases from 777 files. The 135 failures are listed in known-failures.txt, and the run fails if anything else fails or a listed case passes. 73 are shorthands, CSS Gaps’ repeat() lists the most of them; 55 are values the current drafts don’t have or rule out; 6 are legacy quirks; and one canonical form is a test at odds with its neighbours. The 129 skipped are tests in files that otherwise run that need a DOM or computed values. CSS values breaks them all down.

The media query, computed-value and cascade cases are extracted the same way, each with its own probe in the sandbox, and the computed and cascade runners parse the vendored test file itself with Parsec for its elements and <style>. All 1,370 media query cases pass. Of the computed values, 754 fail, most of them values that need layout (grid-template-columns as track sizes, transform-origin as pixels) or a property’s own computed form not done yet; the cascade’s 204 are mostly style() container queries, shadow DOM and container query units. Cascade has them.

The URL suites don’t fail any more. They used to: parsec-url was built on the url crate, which fails 875 of the 4,565 URL cases, 795 of them one IDNA rule from June 2026. Its own parser passes them all (#82), so the known-failures list is gone and any URL failure fails the run. The normalization count is the 20,171 lines of NormalizationTest.txt, each checked ten ways, plus one for the file’s rule that every code point it doesn’t list stays as it is. URL has what each suite counts.

What the HTML counts count is worth spelling out, because it differs between the two.

The suite has 14 .test files holding 6,820 tests. A test can list several initial states (data, PLAINTEXT, RCDATA, RAWTEXT, script data, CDATA section), and the runner runs it once per state, which makes 7,046 runs. 7,042 pass. The other 4 are skipped: they’re doubleEscaped tests whose input contains a lone surrogate, which a Rust &str can’t hold, so there’s no way to give them to Parsec.

The runner (crates/parsec/tests/tokenizer.rs) preprocesses each input, sets the initial state and lastStartTag where the test gives them, collects tokens through a Sink, merges adjacent character tokens as the suite’s README says, and compares with the expected output. With Options::errors on it also checks the errors field, code, line and column, exactly: all 7,042 cases match (Parsing).

Tree construction: 3,898 runs of 1,967 cases

Section titled “Tree construction: 3,898 runs of 1,967 cases”

The tree-construction tests moved from html5lib-tests to web-platform-tests in 2026. The pinned copy has 62 .dat files and 1,973 test cases, 206 of them fragment cases. Each case can say it’s for scripting on (#script-on), off (#script-off), or say neither:

Cases Run with Runs
1,931 that say neither scripting off, and again with it on 3,862
28 marked #script-off scripting off 28
8 marked #script-on scripting on 8
6 marked #script-on in scripted_* files skipped 0

That’s 3,898 runs, all passing. Put the other way: of 1,973 cases, the 1,967 a parser without JavaScript can run all pass, in every mode they apply to.

The 6 skipped cases are in scripted_adoption01.dat, scripted_ark.dat, scripted_foster01.dat and scripted_webkit01.dat, and they run script during the parse (document.write, DOM calls), which needs a JavaScript engine. Parsec doesn’t run scripts.

The runner (crates/parsec/tests/tree.rs) parses each case with parse or, for fragment cases, parse_fragment with the given context (svg x and math x become Ns::Svg and Ns::MathMl). It writes the tree in the suite’s | <tag> format, with attributes sorted, template contents under content, and namespaced attributes as xlink href, and compares that with #document. The #errors and #new-errors sections aren’t checked, for the same reason as above.

You don’t have to take this page’s word for the numbers. With CONFORMANCE_DIR set, the tokenizer, tree-construction, encoding, URL and CSS runners each write their counts to <suite>.json in that directory, and CI sets it on every run.

Each file holds one suite. This is the tokenizer’s, from CI:

{
"failed": 0,
"passed": 7042,
"skipped": 4,
"skipped_because": "lone surrogates, which a Rust string can't hold",
"suite": "html5lib-tokenizer",
"test_data_commit": "c5495c539ca8a79c3c5107f5f14010bcff9a35d5"
}
Field What it is
suite html5lib-tokenizer, html5lib-tree-construction, one of the URL suites (wpt-url-parsing, wpt-url-origin, wpt-url-setters, wpt-url-toascii, wpt-url-idna and wpt-url-idna-removed), one of the CSS ones (css-parsing-tests, css-parsing-tests-urange, css-tokenizer-tests, wpt-css-parsing, wpt-media-queries, wpt-computed-values and wpt-cascade), or unicode-normalization. It’s also the file’s name.
passed, failed, skipped The counts the runner prints.
skipped_because Why the skipped ones can’t run here, in words.
test_data_commit Which version of the suite ran: the COMMIT file beside the test data if there is one, else the commit checked out there, else unknown.

In CI, the test job runs cargo test --workspace with CONFORMANCE_DIR set. On Linux, two more steps follow, and both run even when a suite fails:

  • The Conformance summary step turns the files into a table on the run’s summary page: suite, passed, failed, skipped with the reason, and the first 12 characters of the test data’s commit.
  • The upload step keeps the files as the run’s conformance artifact. It fails if there are none, so a runner that stops writing them shows up.

To find them, open a run of the ci workflow from the Actions tab. The table is on the summary, and the artifact is at the bottom of the same page.

To get the same files locally:

Terminal window
CONFORMANCE_DIR=out cargo test
cat out/*.json

A relative CONFORMANCE_DIR is read from where each test runs, which for Cargo is the crate’s directory, so out lands in crates/parsec/out and crates/parsec-url/out. Give an absolute path to put it anywhere else.

Conformance counts from CI arrived in #70, for #4.

Terminal window
git clone --recurse-submodules https://github.com/parsec-html/parsec
cd parsec
cargo test

The tokenizer tests read html5lib-tests, which is a git submodule. If you cloned without --recurse-submodules, fetch it first:

Terminal window
git submodule update --init

To see the counts, which the runners print to stderr, run one suite with output on:

Terminal window
cargo test --test tokenizer -- --nocapture
cargo test --test tree -- --nocapture
cargo test -p parsec-web-encoding --test html5lib -- --nocapture
cargo test -p parsec-web-encoding --test wpt -- --nocapture
cargo test -p parsec-url --test wpt -- --nocapture
cargo test -p parsec-url --test normalization -- --nocapture
cargo test -p parsec-web-css -- --nocapture

Two environment variables help when a tree-construction case fails:

  • TREE_TEST=adoption runs only the files whose names contain adoption.
  • TREE_BRIEF=1 prints one line per failure (file, scripting, fragment context and input) before the full report of the first 15.
Terminal window
TREE_TEST=template TREE_BRIEF=1 cargo test --test tree -- --nocapture

The WPT files aren’t a submodule; they’re copied into crates/parsec/tests/tree-construction with the commit in COMMIT beside them. To move them, from crates/parsec, with gh and curl installed:

Terminal window
scripts/fetch-tree-tests.sh WPT_COMMIT

It replaces the directory with that commit’s html/syntax/parsing/resources/*.dat files and the WPT licence.

The WPT encoding files in crates/parsec-encoding/tests/wpt are copied the same way, by hand: each file keeps its path under WPT’s encoding/, and COMMIT says which commit they came from. To move them, fetch the same paths at the new commit and update COMMIT. Note that crates/parsec/scripts is synced from Netweir, so a change to the script itself starts there (see Contributing).

  • crates/parsec/tests/css.rs: 24 tests for the selector engine, covering every feature in Selectors, the selectors that must be refused, and the nesting limit.
  • In crates/parsec-css, 12 unit tests and 9 doctests: borrowing and escapes, CR LF and NUL, a million nested brackets parsed and dropped on an ordinary stack, spans, block contents parsed later matching parsing at once, and serialization. Its suite runner also serializes every suite input and parses it back.
  • 49 unit tests inside crates/parsec/src: the budget, the depth limit, linear memory on a known hostile input, serialization on a small stack, edits that keep strings in place, the tokenizer’s fast path against its state machine, and more.

How much of the code those tests run, from the first coverage run on main, at commit adc2dcc:

Covered Total Missed
Lines 94.31% 5,062 288
Regions 93.78% 6,177 384
Functions 94.36% 532 30
Branches 85.30% 1,476 217

The coverage workflow runs cargo llvm-cov --workspace --branch on nightly (branch coverage needs it) on every push to main. It fails if lines drop under 90% or branches under 80%, the OpenSSF Best Practices gold thresholds, so a slide shows up on the change that caused it. The full report and an lcov file are kept as the run’s coverage artifact.

To get the same table locally, with cargo-llvm-cov installed:

Terminal window
cargo +nightly llvm-cov --workspace --branch --summary-only

Coverage in CI was added by @foothillsdigital in #61.

Suite Why not Issue
html5lib serializer/ Needs the serializer options those tests use. #9
WPT css/selectors No runner yet. #19
WPT encoding cases that need a browser XMLHttpRequest, form submission, TextDecoder’s API.
WPT url/resources/percent-encoding.json It needs the legacy encodings. #25
WPT urltestdata-javascript-only.json Every case is a lone surrogate, which only JavaScript strings hold.

Lexbor’s README says it “passes all tree construction tests” but doesn’t publish a count (README). Lexbor vendors 1,851 html5lib tree-construction cases in its own format (test files) and has an opt-in runner for the WPT files that skips the scripted ones (test README). The independent JustHTML project measured selectolax, which uses Lexbor, passing 1,880 of 1,880 WPT cases without scripting fixtures, at WPT commit 4830edb (comparison).

Those numbers aren’t directly comparable with Parsec’s: they’re from a different WPT commit and count cases once rather than once per scripting mode. By those measures, both pass everything they run. Lexbor vendors the html5lib tokenizer tests too but doesn’t publish a pass rate.