summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/mathml/presentation-markup/tables/table-axis-height.html
blob: 58f9d64c21d27e4a3a91ba66f87f5635f69c48c1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>table axis height</title>
<link rel="help" href="https://w3c.github.io/mathml-core/#table-or-matrix-mtable">
<meta name="assert" content="Element mtable correctly uses the axis height parameter from the MATH table.">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/mathml/support/feature-detection.js"></script>
<script src="/mathml/support/fonts.js"></script>
<style>
  math, mspace {
    font-size: 10px;
  }
  @font-face {
    font-family: axisheight5000-verticalarrow14000;
    src: url("/fonts/math/axisheight5000-verticalarrow14000.woff");
  }
</style>
<script>
  var emToPx = 10 / 1000; // font-size: 10px, font.em = 1000
  var epsilon = 1;

  function getBox(aId) {
    return document.getElementById(aId).getBoundingClientRect();
  }

  setup({ explicit_done: true });
  window.addEventListener("load", () => { loadAllFonts().then(runTests); });

  function runTests() {
    test(function() {
      assert_true(MathMLFeatureDetection.has_mspace());

      var v1 = 5000 * emToPx;
      var tableMiddle = (getBox("table").bottom + getBox("table").top) / 2;
      assert_approx_equals(getBox("baseline").bottom - tableMiddle,
                           v1, epsilon, "mtable: axis height");
    }, "AxisHeight");

    done();
  }
</script>
</head>
<body>
  <div id="log"></div>
  <p>
    <math style="font-family: axisheight5000-verticalarrow14000">
      <mspace id="baseline" style="background: green" width="50px" height="1px"/>
      <mtable id="table" style="background: blue"><mtr><mtd><mspace width="100px" height="1px"/></mtd></mtr></mtable>
    </math>
  </p>
</body>
</html>