Rendering stylesheets over one document in a headless Chromium and reporting where the renders differ.
The oracle is the browser's raster and nothing else. The document is loaded afresh under each sheet, at every viewport width a media condition in either sheet names and under every interaction state either sheet names, a state applied to every element at once; every animation is held at its start and every transition finished, and the whole page is captured and compared pixel for pixel. Two sheets render the same when every capture is the same picture. Where one differs, the computed styles of the elements under the differing pixels are read under both sheets and what they disagree on is listed, so a difference names a property; a computed value that differs over pixels that do not is not a difference, since what a script reads back is not what the browser renders.
The document's own style elements and stylesheet links are removed and its inline style attributes kept. A width or state named only by rules no element of the document can match is not rendered, since such a rule can change nothing on the page; the rules are judged as cascade prune judges them, so a selector the matcher has no model for, :hover among them, counts as matching. The sheets themselves are rendered as written.
What was rendered, as pairs keyed "browser" (its version), "browser_path", "elements", "properties", "pseudos", "states", "viewports", "captures" (how many renders were taken), "renders" (how many differed), "samples" and "differences" (the computed values read under differing renders, and how many differed), "document_styles_removed", "doctype_added" and, when the listing stopped short, "truncated".
The computed values that differ under them, in the order read.
*)
}
Sourceval run : html:string ->(string * string) list->(t, string)result
run ~html sheets renders html under the two (name, css) of sheets and compares them to each other. The report carries one first and one second, so exactly two sheets are taken; fewer or more is Error. It is Error with the reason, too, when no node or no headless Chromium is found, when the driver fails, when the page reports an error, and when nothing was rendered: a run that compared nothing never reads as an equivalence.
to_string ~first ~second ~html report is report for a reader: what was rendered, each render that differs with where, then each computed difference once with the viewports and states it holds under, a pseudo-element that repeats its element's difference counted rather than listed. first, second and html name the sheets and the document.