Bug 832313 Part 2: Add a mochitest to confirm the default font has increasing line heights for increasing font sizes. r?jfkthame draft
authorBrad Werth <bwerth@mozilla.com>
Mon, 24 Oct 2016 12:30:39 -0700
changeset 429825 caae3df0ec333cea98bba84c76f1c90a1c189456
parent 429824 52effd40245ce4677bb55cc3ff1d65afc65c0fd6
child 535063 16a5839a55d5cbdeffa3860d9181f91f46d124fc
push id33670
push userbwerth@mozilla.com
push dateWed, 26 Oct 2016 16:37:49 +0000
reviewersjfkthame
bugs832313
milestone52.0a1
Bug 832313 Part 2: Add a mochitest to confirm the default font has increasing line heights for increasing font sizes. r?jfkthame MozReview-Commit-ID: 9ULq9Oa2WVI
layout/style/test/mochitest.ini
layout/style/test/test_line_height_continuity.html
--- a/layout/style/test/mochitest.ini
+++ b/layout/style/test/mochitest.ini
@@ -207,16 +207,17 @@ skip-if = (toolkit == 'gonk' && debug) #
 [test_ident_escaping.html]
 [test_inherit_computation.html]
 skip-if = toolkit == 'android'
 [test_inherit_storage.html]
 [test_initial_computation.html]
 skip-if = toolkit == 'android'
 [test_initial_storage.html]
 [test_keyframes_rules.html]
+[test_line_height_continuity.html]
 [test_load_events_on_stylesheets.html]
 [test_logical_properties.html]
 skip-if = (toolkit == 'gonk' && debug) # Bug 1186224
 [test_media_queries.html]
 skip-if = (toolkit == 'gonk' && debug) || android_version == '18' #debug-only failure; timed out #Android 4.3 aws only; bug 1030419
 [test_media_queries_dynamic.html]
 [test_media_queries_dynamic_xbl.html]
 [test_media_query_list.html]
new file mode 100644
--- /dev/null
+++ b/layout/style/test/test_line_height_continuity.html
@@ -0,0 +1,53 @@
+<!DOCTYPE HTML>
+<html>
+<head>
+  <title>Test for continuous line height increase with increasing font size</title>
+  <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
+
+<script>
+'use strict';
+
+SimpleTest.waitForExplicitFinish();
+
+function runTests() {
+  function testFontOfSize(fontSize) {
+    let lineDiv = document.createElement("div");
+    let fontSizeSpan = document.createElement("span");
+    fontSizeSpan.textContent = "font-size " + fontSize + ", ";
+    fontSizeSpan.style.fontSize = fontSize + "px";
+
+    let lineHeight = getComputedStyle(fontSizeSpan).getPropertyValue("line-height");
+
+    let lineHeightSpan = document.createElement("span");
+    lineHeightSpan.style.fontSize = fontSize + "px";
+    lineHeightSpan.textContent = "and line-height is " + lineHeight;
+
+    lineDiv.appendChild(fontSizeSpan);
+    lineDiv.appendChild(lineHeightSpan);
+
+    document.body.appendChild(lineDiv);
+
+    // Return the lineHeight without the "px".
+    return lineHeight.substring(0, lineHeight.length - 2);
+  }
+
+  let minFontSize = 10;
+  let maxFontSize = 32;
+  let stepFontSize = .5;
+
+  let lastLineHeight = 0;
+  for (let i = minFontSize; i <= maxFontSize; i += stepFontSize) {
+    let thisLineHeight = testFontOfSize(i);
+
+    ok(thisLineHeight >= lastLineHeight, "Font size " + i + " line height " + thisLineHeight + " should be at least as large as font size " + (i - stepFontSize) + " line height of " + lastLineHeight + ".");
+    lastLineHeight = thisLineHeight;
+  }
+
+  SimpleTest.finish();
+}
+</script>
+</head>
+<body onLoad="runTests()">
+
+</body></html>
\ No newline at end of file