summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/mathml/presentation-markup/tables/table-cell-mrow-layout.html
blob: 1e76e3949a5bb1db505fd1c841d69431f5423281 (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
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Table cell mrow layout</title>
<link rel="help" href="https://w3c.github.io/mathml-core/#table-or-matrix-mtable">
<meta name="assert" content="Table cell relies on the mrow layout for their children.">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/mathml/support/feature-detection.js"></script>
<script src="/mathml/support/layout-comparison.js"></script>
<style>
  /* Remove default padding, since there is none on reference mrow element. */
  mtd { padding: 0; }
</style>
</head>
<body>
  <div id="log"></div>
  <p>
    <math>
      <mtable id="mtable">
        <mtr>
          <mtd id="mtd">
            <mspace width="10px" depth="20px" height="20px" style="background: blue"/>
            <mspace width="10px" depth="10px" height="30px" style="background: lightblue"/>
            <mspace width="10px" depth="30px" height="10px" style="background: black"/>
          </mtd>
        </mtr>
      </mtable>
    </math>
  </p>
  <p>
    <math>
      <mrow id="mtd-reference">
        <mspace width="10px" depth="20px" height="20px" style="background: blue"/>
        <mspace width="10px" depth="10px" height="30px" style="background: lightblue"/>
        <mspace width="10px" depth="30px" height="10px" style="background: black"/>
      </mrow>
    </math>
  </p>
  <p>
    <math>
      <mtable id="mtable-reference">
        <mtr>
          <mtd>
            <mrow>
              <mspace width="10px" depth="20px" height="20px" style="background: blue"/>
              <mspace width="10px" depth="10px" height="30px" style="background: lightblue"/>
              <mspace width="10px" depth="30px" height="10px" style="background: black"/>
            </mrow>
          </mtd>
        </mtr>
      </mtable>
    </math>
  </p>
  <script>
    const epsilon = 1;

    test(function() {
      assert_true(MathMLFeatureDetection.has_mspace());
      let mtd = document.getElementById("mtd");
      let reference = document.getElementById("mtd-reference");
      compareLayout(mtd, reference, epsilon);
    }, "<mtd> relies on mrow algorithm to layout its children");

    test(function() {
      assert_true(MathMLFeatureDetection.has_mspace());
      let mtable = document.getElementById("mtable");
      let reference = document.getElementById("mtable-reference");
      compareLayout(mtable, reference, epsilon);
    }, "<mtable> layout does not change if children of <mtd> elements are wrapped in an explicit <mrow>");
  </script>
</body>
</html>