Skip to content

Truly independent web browser

Tests/LibWeb: Add test for line gap in normal line height

Andreas Kling098b5e9e4c60
diff --git a/Tests/LibWeb/Assets/SerenitySans-with-line-gap.ttf b/Tests/LibWeb/Assets/SerenitySans-with-line-gap.ttf
new file mode 100644
index 00000000000..e49c45ec2a7
Binary files /dev/null and b/Tests/LibWeb/Assets/SerenitySans-with-line-gap.ttf differ
diff --git a/Tests/LibWeb/Text/expected/css/line-height-normal-includes-line-gap.txt b/Tests/LibWeb/Text/expected/css/line-height-normal-includes-line-gap.txt
new file mode 100644
index 00000000000..c1db1fc988e
--- /dev/null
+++ b/Tests/LibWeb/Text/expected/css/line-height-normal-includes-line-gap.txt
@@ -0,0 +1,3 @@
+line box height: 100
+inline box height: 100
+line box height at 768px: 768
diff --git a/Tests/LibWeb/Text/input/css/line-height-normal-includes-line-gap.html b/Tests/LibWeb/Text/input/css/line-height-normal-includes-line-gap.html
new file mode 100644
index 00000000000..b7903e2ad8d
--- /dev/null
+++ b/Tests/LibWeb/Text/input/css/line-height-normal-includes-line-gap.html
@@ -0,0 +1,26 @@
+<!DOCTYPE html>
+<style>
+ @font-face {
+ font-family: LineGapFont;
+ src: url("../../../Assets/SerenitySans-with-line-gap.ttf");
+ }
+ div {
+ font: 100px LineGapFont;
+ }
+ #large-block {
+ font-size: 768px;
+ }
+</style>
+<!-- The font has an ascent of 819, a descent of 205 and a line gap of 94 font units, at 1024 units per em. -->
+<div id="block"><span id="text">x</span></div>
+<!-- At 768px, the line gap is exactly 70.5px, which rounds to even like the other metrics. -->
+<div id="large-block">x</div>
+<script src="../include.js"></script>
+<script>
+ promiseTest(async () => {
+ await document.fonts.load("100px LineGapFont");
+ println(`line box height: ${block.getBoundingClientRect().height}`);
+ println(`inline box height: ${text.getBoundingClientRect().height}`);
+ println(`line box height at 768px: ${document.getElementById("large-block").getBoundingClientRect().height}`);
+ });
+</script>