summaryrefslogtreecommitdiffstats
path: root/layout/style/test/test_font_family_serialization.html
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-21 11:44:51 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-21 11:44:51 +0000
commit9e3c08db40b8916968b9f30096c7be3f00ce9647 (patch)
treea68f146d7fa01f0134297619fbe7e33db084e0aa /layout/style/test/test_font_family_serialization.html
parentInitial commit. (diff)
downloadthunderbird-upstream.tar.xz
thunderbird-upstream.zip
Adding upstream version 1:115.7.0.upstream/1%115.7.0upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'layout/style/test/test_font_family_serialization.html')
-rw-r--r--layout/style/test/test_font_family_serialization.html51
1 files changed, 51 insertions, 0 deletions
diff --git a/layout/style/test/test_font_family_serialization.html b/layout/style/test/test_font_family_serialization.html
new file mode 100644
index 0000000000..ad922158f5
--- /dev/null
+++ b/layout/style/test/test_font_family_serialization.html
@@ -0,0 +1,51 @@
+<!DOCTYPE html>
+<meta charset="UTF-8">
+<link rel="author" title="Xidorn Quan" href="https://www.upsuper.org">
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<div id="log"></div>
+<div id="display"></div>
+<script>
+// This cannot be a web-platform test because this doesn't match what
+// the spec says at the moment. Specifically, the spec wants to have
+// all font family serialized to string, while in practice, all browsers
+// serialize simple them to identifiers in some cases.
+// We want to check our current behavior. This can be changed once
+// browsers have an agreement on the exact behavior to spec.
+
+// format: [input, expected serialization]
+const tests = [
+ // Basic cases
+ ['simple', 'simple'],
+ [' simple ', 'simple'],
+ ['multi idents font', 'multi idents font'],
+ [' multi idents font ', 'multi idents font'],
+ ['"wrapped name"', '"wrapped name"'],
+ ['" wrapped name "', '" wrapped name "'],
+
+ // Special whitespaces
+ ['\\ leading ws', '" leading ws"'],
+ [' \\ leading ws', '" leading ws"'],
+ ['\\ \\ leading ws', '" leading ws"'],
+ [' \\ \\ leading ws', '" leading ws"'],
+ ['\\ \\ \\ leading ws', '" leading ws"'],
+ ['trailing ws\\ ', '"trailing ws "'],
+ ['trailing ws\\ ', '"trailing ws "'],
+ ['trailing ws \\ ', '"trailing ws "'],
+ ['trailing ws\\ \\ ', '"trailing ws "'],
+ ['escaped\\ ws', '"escaped ws"'],
+ ['escaped\\ ws', '"escaped ws"'],
+ ['escaped\\ \\ ws', '"escaped ws"'],
+ ['escaped \\ ws', '"escaped ws"'],
+ ['escaped \\ ws', '"escaped ws"'],
+ ['escaped number\\ 5', '"escaped number 5"'],
+];
+
+let el = document.getElementById("display");
+for (let [input, expected] of tests) {
+ test(function() {
+ el.style.fontFamily = input;
+ assert_equals(el.style.fontFamily, expected);
+ }, "Reserialization for " + JSON.stringify(input));
+}
+</script>