summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/font-access/resources/font-asserts.js
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 01:47:29 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 01:47:29 +0000
commit0ebf5bdf043a27fd3dfb7f92e0cb63d88954c44d (patch)
treea31f07c9bcca9d56ce61e9a1ffd30ef350d513aa /testing/web-platform/tests/font-access/resources/font-asserts.js
parentInitial commit. (diff)
downloadfirefox-esr-0ebf5bdf043a27fd3dfb7f92e0cb63d88954c44d.tar.xz
firefox-esr-0ebf5bdf043a27fd3dfb7f92e0cb63d88954c44d.zip
Adding upstream version 115.8.0esr.upstream/115.8.0esr
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
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