summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/font-access/resources/font-asserts.js
diff options
context:
space:
mode:
Diffstat (limited to 'testing/web-platform/tests/font-access/resources/font-asserts.js')
-rw-r--r--testing/web-platform/tests/font-access/resources/font-asserts.js38
1 files changed, 38 insertions, 0 deletions
diff --git a/testing/web-platform/tests/font-access/resources/font-asserts.js b/testing/web-platform/tests/font-access/resources/font-asserts.js
new file mode 100644
index 0000000000..7094d8f0bf
--- /dev/null
+++ b/testing/web-platform/tests/font-access/resources/font-asserts.js
@@ -0,0 +1,38 @@
+'use strict';
+
+function assert_font_equals(actualFont, expectedFont) {
+ assert_equals(
+ actualFont.postscriptName, expectedFont.postscriptName,
+ `${actualFont.postscriptName}: postscriptName should match`);
+ assert_equals(
+ actualFont.fullName, expectedFont.fullName,
+ `${actualFont.postscriptName}: fullName should match`);
+ assert_equals(
+ actualFont.family, expectedFont.family,
+ `${actualFont.postscriptName}: family should match`);
+ assert_equals(
+ actualFont.style, expectedFont.style,
+ `${actualFont.postscriptName}: style should match`);
+}
+
+function assert_font_has_tables(fontName, actualTables, expectedTables) {
+ for (const expectedTable of expectedTables) {
+ assert_equals(
+ expectedTable.length, 4, 'Table names are always 4 characters long.');
+ assert_true(
+ actualTables.has(expectedTable),
+ `Font ${fontName} did not have required table ${expectedTable}.`);
+ assert_greater_than(
+ actualTables.get(expectedTable).size, 0,
+ `Font ${fontName} has table ${expectedTable} of size 0.`);
+ }
+}
+
+function assert_version_info(versionTag) {
+ // Spec: https://docs.microsoft.com/en-us/typography/opentype/spec/otff#organization-of-an-opentype-font
+ assert_true(versionTag === '\x00\x01\x00\x00' ||
+ versionTag === 'true' ||
+ versionTag === 'typ1' ||
+ versionTag === 'OTTO',
+ `Invalid sfnt version tag: ${versionTag}`);
+} \ No newline at end of file