summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/mathml/presentation-markup/scripts/subsup-6.html
blob: 9666c80f9f60bd2cfd10437d9273777f11c3e2cb (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
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>mprescripts</title>
<link rel="help" href="https://w3c.github.io/mathml-core/#subscripts-and-superscripts-msub-msup-msubsup">
<meta name="assert" content="Position and size of mprescripts in mmultiscript element.">
<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>
<link rel="stylesheet" type="text/css" href="/fonts/ahem.css" />
<style>
  math, mspace {
    font: 25px/1 Ahem;
  }
</style>
<script>
  /* This test does not use a font with a MATH table and does not verify layout
     rules in a very strict way. */

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

  function runTests() {
      Array.from(document.getElementsByTagName("mprescripts")).
          forEach(prescript => {
              let prescript_box = prescript.getBoundingClientRect();
              let mmultiscripts = prescript.parentNode;
              let name = mmultiscripts.getAttribute("data-name");
              test(function() {
                  assert_true(MathMLFeatureDetection.has_mspace());
                  var e = 1;
                  let base_box = mmultiscripts.firstElementChild.getBoundingClientRect();
                  assert_approx_equals(prescript_box.left, base_box.left, e, `${name}, left`);
                  assert_approx_equals((prescript_box.top + prescript_box.bottom) / 2, (base_box.top + base_box.bottom) / 2, e, `${name}, top`);

                  if (name == "prescripts with padding/border/margin") {
                      assert_approx_equals(prescript_box.width, 2*(15 + 25), e, `${name}, width`);
                      assert_approx_equals(prescript_box.height, 2*(10 + 20), e, `${name}, height`);
                  } else {
                      assert_approx_equals(prescript_box.width, 0, e, `${name}, width`);
                      assert_approx_equals(prescript_box.height, 0, e, `${name}, height`);
                  }
              }, `mprescripts coordinates and sizes (${name})`);
          });

      done();
  }
</script>
</head>
<body>
  <div id="log"></div>
  <p>
    <math>
      <mmultiscripts data-name="2 postscripts">
        <mspace width="30px" height="15px" depth="15px" style="background: black"/>
        <mspace width="30px" height="15px" depth="15px" style="background: black"/>
        <mspace width="30px" height="15px" depth="15px" style="background: black"/>
        <mprescripts/>
      </mmultiscripts>
    </math>
  </p>
  <p>
    <math>
      <mmultiscripts data-name="2 prescripts">
        <mspace width="30px" height="15px" depth="15px" style="background: black"/>
        <mprescripts/>
        <mspace width="30px" height="15px" depth="15px" style="background: black"/>
        <mspace width="30px" height="15px" depth="15px" style="background: black"/>
      </mmultiscripts>
    </math>
  </p>
  <p>
    <math>
      <mmultiscripts data-name="2 prescripts, 4 postscripts">
        <mspace width="30px" height="15px" depth="15px" style="background: black"/>
        <mspace width="30px" height="15px" depth="15px" style="background: black"/>
        <mspace width="30px" height="15px" depth="15px" style="background: black"/>
        <mspace width="30px" height="15px" depth="15px" style="background: black"/>
        <mspace width="30px" height="15px" depth="15px" style="background: black"/>
        <mprescripts/>
        <mspace width="30px" height="15px" depth="15px" style="background: black"/>
        <mspace width="30px" height="15px" depth="15px" style="background: black"/>
      </mmultiscripts>
    </math>
  </p>
  <p>
    <math>
      <mmultiscripts data-name="4 prescripts, 2 postscripts">
        <mspace width="30px" height="15px" depth="15px" style="background: black"/>
        <mspace width="30px" height="15px" depth="15px" style="background: black"/>
        <mspace width="30px" height="15px" depth="15px" style="background: black"/>
        <mprescripts/>
        <mspace width="30px" height="15px" depth="15px" style="background: black"/>
        <mspace width="30px" height="15px" depth="15px" style="background: black"/>
        <mspace width="30px" height="15px" depth="15px" style="background: black"/>
        <mspace width="30px" height="15px" depth="15px" style="background: black"/>
      </mmultiscripts>
    </math>
  </p>
  <p>
    <math>
      <mmultiscripts data-name="prescripts with padding/border/margin">
        <mspace width="30px" height="15px" depth="15px" style="background: black"/>
        <mspace width="30px" height="15px" depth="15px" style="background: black"/>
        <mspace width="30px" height="15px" depth="15px" style="background: black"/>
        <mprescripts style="background: blue;
                            padding-top: 10px; border-top: 20px solid green;
                            padding-bottom: 10px; border-bottom: 20px solid green;
                            padding-left: 15px; border-left: 25px solid green;
                            padding-right: 15px; border-right: 25px solid green;
                            margin-top: 50px;"/>
        <mspace width="30px" height="15px" depth="15px" style="background: black"/>
        <mspace width="30px" height="15px" depth="15px" style="background: black"/>
      </mmultiscripts>
    </math>
  </p>
</body>
</html>