Skip to content

Commit ec7200b

Browse files
committed
test: read the generic families from the table that states them
The comparison had its own copy of the list, which is the one table in this change a dataset already answers — `lib/css/data.js` generates it, so it is passed into the page rather than written a second time.
1 parent 118a558 commit ec7200b

3 files changed

Lines changed: 13 additions & 19 deletions

File tree

‎test/helpers/syntaxEquivalence.js‎

Lines changed: 8 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,11 @@ const benchmarkDocuments = (minify) => {
192192
* inline `<style>` is held to exactly the same standard as a `.css` file.
193193
* @returns {void}
194194
*/
195-
const installHelpers = () => {
195+
/**
196+
* @param {string[]} generics the generic font families, from `lib/css/data.js`
197+
* @returns {void}
198+
*/
199+
const installHelpers = (generics) => {
196200
const NS_HTML = "http://www.w3.org/1999/xhtml";
197201
const NS_SVG = "http://www.w3.org/2000/svg";
198202
const probe = document.createElement("div");
@@ -583,22 +587,9 @@ const installHelpers = () => {
583587
);
584588

585589
// A generic family is a keyword, so quoting one names a font of that name
586-
// instead — the quoting is what tells the two apart and is never dropped.
587-
const GENERIC_FAMILIES = new Set([
588-
"cursive",
589-
"emoji",
590-
"fangsong",
591-
"fantasy",
592-
"math",
593-
"monospace",
594-
"sans-serif",
595-
"serif",
596-
"system-ui",
597-
"ui-monospace",
598-
"ui-rounded",
599-
"ui-sans-serif",
600-
"ui-serif"
601-
]);
590+
// instead, and the quoting is what tells the two apart. `CssSyntax.unittest`
591+
// holds the printer to the same rule.
592+
const GENERIC_FAMILIES = new Set(generics);
602593

603594
/**
604595
* The one spelling of a value the spec gives several names: an easing keyword

‎test/specCases/syntaxEquivalence.spectest.js‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@
77
// DOM oracle, held to that corpus's expected trees by html5lib.spectest.js.
88

99
const path = require("path");
10+
// The comparison has to know which family names are keywords, and the table
11+
// that says so is generated rather than written twice.
12+
const { GENERIC_FONT_FAMILIES } = require("../../lib/css/data");
1013
const {
1114
SourceProcessor: CssSourceProcessor,
1215
readToken
@@ -428,7 +431,7 @@ describe(`printer output in real ${ENGINE === "firefox" ? "Firefox" : "Chrome"}`
428431
await opened.setContent(
429432
"<!doctype html><html><head></head><body></body></html>"
430433
);
431-
await opened.evaluate(installHelpers);
434+
await opened.evaluate(installHelpers, [...GENERIC_FONT_FAMILIES]);
432435
return opened;
433436
};
434437

‎test/wpt‎

Submodule wpt updated 921 files

0 commit comments

Comments
 (0)