summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/mathml/presentation-markup/operators/mo-axis-height-1.html
blob: 6de6284188772e9309437f43e2dbfdc0e8dd96f0 (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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>mo axis height</title>
<link rel="help" href="https://w3c.github.io/mathml-core/#operator-fence-separator-or-accent-mo">
<meta name="assert" content="Element mo 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/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 = 5;

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

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

  function runTests() {
    test(function() {
      var v1 = 5000 * emToPx;
      var moMiddle = (getBox("mo1").bottom + getBox("mo1").top) / 2;
      assert_approx_equals(getBox("mo1").height,
                           14000 * emToPx, epsilon, "mo: size");
      assert_approx_equals(getBox("baseline1").bottom - moMiddle,
                           v1, epsilon, "mo: axis height");
    }, "AxisHeight (size variant)");

    test(function() {
      var v1 = 5000 * emToPx;
      var moMiddle = (getBox("mo2").bottom + getBox("mo2").top) / 2;
      assert_approx_equals(getBox("mo2").height,
                           2 * (getBox("target2").height - v1),
                           epsilon, "mo: size");
      assert_approx_equals(getBox("baseline2").bottom - moMiddle,
                           v1, epsilon, "mo: axis height");
    }, "AxisHeight (glyph assembly)");

    done();
  }
</script>
</head>
<body>
  <div id="log"></div>
  <p>
    <math style="font-family: axisheight5000-verticalarrow14000;">
      <mrow>
        <mspace id="baseline1" style="background: blue" width="50px" height="1px"/>
        <mpadded voffset="50px"><mspace style="background: cyan" width="50px" height="1px"/></mpadded>
        <mo id="mo1" symmetric="true" style="color: green">&#x21A8;</mo>
        <mspace style="background: gray" width="10px" height="50px"/>
      </mrow>
    </math>
    <math style="font-family: axisheight5000-verticalarrow14000;">
      <mrow>
        <mspace id="baseline2" style="background: blue" width="50px" height="1px"/>
        <mpadded voffset="50px"><mspace style="background: cyan" width="50px" height="1px"/></mpadded>
        <mo id="mo2" symmetric="true" style="color: green">&#x21A8;</mo>
        <mspace id="target2" style="background: gray" width="10px" height="200px"/>
      </mrow>
    </math>
</body>
</html>