nx_wpt_reftest.nx
buildroot/runtime/nx_wpt_reftest.nx
about
nx_wpt_reftest.nx -- BR1 vNext: THE SOVEREIGN WPT REFTEST RUNNER (2026-08-19).
The css half of the BR1 slice. A WPT reftest declares <link rel="match" href="ref.html"> (or
rel="mismatch"): the test PASSES when its render is pixel-identical to (match) / different from
(mismatch) the reference. This runner paints BOTH files through the browser's own render core
(br_layout + br_draw_fb) into FIXED 800x600 framebuffers -- the WPT viewport semantic, so a
legitimately different full-page height cannot fail two identical viewports -- and compares the
raw pixel buffers byte-for-byte. No PNG, no OCR, no tolerance: the engine is bit-deterministic,
so equality is exact and every failure names a real render difference.
Telemetry rides the shared spine (nx_wpt_spine): content-addressed (engine sha, corpus sha)
skip with --force, one TSV row per counted run (own history file -- reftest columns are NOT the
testharness columns; overloading them would be a bucket named for the wrong thing), REGRESSION
vs the newest same-corpus row exits 4, and every verdict exit CARRIES its code via sys_exit
(the runner's own regression bite caught the bare-return-blesses-failure defect on day one).
CONTROLS FIRST, synthesized at runtime: a self-match (same bytes twice) MUST pass and a
known-mismatch (two different pages) MUST differ, or the harness refuses to count.
DECLARED v1 imprecisions (each a named bucket or counter, never silent):
- first rel=match link only (WPT any-of alternates: files with >1 counted in multi_ref);
- <meta name=fuzzy> tolerance is UNIMPLEMENTED -- fuzzy tests are compared EXACT and the
fuzzy_meta counter travels with the claim so a fail there reads as "stricter than spec";
- .xht/.xml tests are out of scope (html only); scripts in reftests do not run (static lane).
row: epoch dir engine16 corpus16 files with_ref match_pass match_fail mism_pass
mism_fail no_ref ref_missing render_fail fuzzy_meta dur_ms verdict
usage: nx_wpt_reftest <dir> [historyfile] [--force]
exit: 0 counted | 2 harness unproven | 3 usage | 4 REGRESSION
license_tier: ORIGINAL expect_exit: 0
dependencies 2 imports · 0 importers
imports: nx_browser_render.nxnx_wpt_spine.nx
imported by: nobody (leaf or entry point)
structs
| none |
consts
| 35 | const RT_VW: i64 = 800 // the WPT screenshot viewport, both dimensions fixed for BOTH sides |
| 36 | const RT_VH: i64 = 600 |
functions
| 38 | func rw(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } sys_write(1, s, n); return 0 } |
| 39 | func rwn(v: i64) -> i64 |
| 46 | func rcat(dst: *u8, off: i64, src: *u8) -> i64 { var i: i64 = 0; while src[i] != (0 as u8) { dst[off+i] = src[i]; i = i + 1 } return off + i } |
| 47 | func rcatnum(dst: *u8, off: i64, v: i64) -> i64 |
| 55 | func rlower(c: i64) -> i64 { if c >= 65 { if c <= 90 { return c + 32 } } return c } |
| 57 | func rfind_ci(hay: *u8, from: i64, n: i64, needle: *u8) -> i64 |
| 72 | func rt_extract_ref(html: *u8, n: i64, hrefout: *u8, hcap: i64, kindout: *i64, nlinks: *i64, fuzzy: *i64) -> i64 |
| 128 | func rt_resolve(dir: *u8, href: *u8, out: *u8) -> i64 |
| 179 | func rt_render(html: *u8, hlen: i64, px: *u8) -> i64 |
| 190 | func rt_px_equal(a: *u8, b: *u8) -> i64 |
| 197 | func main(argc: i64, argv: *i64) -> i64 |