summaryrefslogtreecommitdiffstats
path: root/layout/mathml/tests/test_opentype-stack.html
blob: 0cbaabb97714cd0ada9fdbef611d1f0a3f2a64b1 (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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
<!doctype html>
<html>
  <head>
    <title>Open Type MATH - stack</title>
    <script type="application/javascript"
            src="/tests/SimpleTest/SimpleTest.js"></script>
    <script type="application/javascript"
            src="/tests/SimpleTest/EventUtils.js"></script>
    <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
    <meta charset="utf-8"/>
    <style type="text/css">
      math {
        font-size: 10px;
      }
      @font-face {
        font-family: stack-1;
        src: url(/tests/fonts/math/stack-1.otf);
      }
      @font-face {
        font-family: stack-2;
        src: url(/tests/fonts/math/stack-2.otf);
      }
      @font-face {
        font-family: stack-3;
        src: url(/tests/fonts/math/stack-3.otf);
      }
      @font-face {
        font-family: stack-4;
        src: url(/tests/fonts/math/stack-4.otf);
      }
      @font-face {
        font-family: stack-5;
        src: url(/tests/fonts/math/stack-5.otf);
      }
      @font-face {
        font-family: stack-6;
        src: url(/tests/fonts/math/stack-6.otf);
      }
    </style>
    <script type="text/javascript">
      SimpleTest.waitForExplicitFinish();

      function doTest() {
        var epsilon = 5;
        function almostEqual(x, y) { return Math.abs(x - y) < epsilon; }

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

        /* inline style */
        var ref = getBox("ref").height;

        ok(almostEqual(getBox("d1").top - getBox("n1").bottom, ref * 20),
           "Bad StackGapMin");

        ok(almostEqual(getBox("ref").top - getBox("n2").top, ref*3),
           "Bad StackTopShiftMin");

        ok(almostEqual(getBox("d3").bottom - getBox("ref").bottom, ref*3),
           "Bad StackBottomShiftDown");

        /* display style */
        ref = getBox("ref").height;

        ok(almostEqual(getBox("d4").top - getBox("n4").bottom, ref * 20),
           "Bad StackGapDisplayStyleMin");

        ok(almostEqual(getBox("dref").top - getBox("n5").top, ref*3),
           "Bad StackTopDisplayStyleShiftMin");

        ok(almostEqual(getBox("d6").bottom - getBox("dref").bottom, ref*3),
           "Bad StackDisplayStyleBottomShiftDown");

        SimpleTest.finish();
      }
    </script>
  </head>
  <body onload="doTest()">

    <a target="_blank"
       href="https://bugzilla.mozilla.org/show_bug.cgi?id=961365">
      Mozilla Bug 961365
    </a>

    <p id="display"></p>

    <p>
      <math>
        <mspace id="ref" height="1em" width="1em" mathbackground="green"/>
      </math>
      <math style="font-family: stack-1;">
        <mfrac linethickness="0">
          <mspace id="n1" height="1em" width="1em" mathbackground="red"/>
          <mspace id="d1" height="1em" width="1em" mathbackground="red"/>
        </mfrac>
      </math>
      <math style="font-family: stack-2;">
        <mfrac linethickness="0">
          <mspace id="n2" height="1em" width="1em" mathbackground="red"/>
          <mspace id="d2" height="1em" width="1em" mathbackground="red"/>
        </mfrac>
      </math>
      <math style="font-family: stack-3;">
        <mfrac linethickness="0">
          <mspace id="n3" height="1em" width="1em" mathbackground="red"/>
          <mspace id="d3" height="1em" width="1em" mathbackground="red"/>
        </mfrac>
      </math>
    </p>

    <p>
      <math displaystyle="true">
        <mspace id="dref" height="1em" width="1em" mathbackground="green"/>
      </math>
      <math displaystyle="true" style="font-family: stack-4;">
        <mfrac linethickness="0">
          <mspace id="n4" height="1em" width="1em" mathbackground="red"/>
          <mspace id="d4" height="1em" width="1em" mathbackground="red"/>
        </mfrac>
      </math>
      <math displaystyle="true" style="font-family: stack-5;">
        <mfrac linethickness="0">
          <mspace id="n5" height="1em" width="1em" mathbackground="red"/>
          <mspace id="d5" height="1em" width="1em" mathbackground="red"/>
        </mfrac>
      </math>
      <math displaystyle="true" style="font-family: stack-6;">
        <mfrac linethickness="0">
          <mspace id="n6" height="1em" width="1em" mathbackground="red"/>
          <mspace id="d6" height="1em" width="1em" mathbackground="red"/>
        </mfrac>
      </math>
    </p>

  </body>
</html>