summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/mathml/presentation-markup/tables/table-001.html
blob: 91e99184df56bc7c42c29a7704a652c85bf27c1a (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
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Basic table layout</title>
<link rel="help" href="https://w3c.github.io/mathml-core/#table-or-matrix-mtable">
<meta name="assert" content="Verify position of cells in basic 2x2, 4x3 and 3x4 math tables.">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/mathml/support/feature-detection.js"></script>
<script>
  setup({ explicit_done: true });
  window.addEventListener("load", runTests);
  function runTests() {
      Array.from(document.getElementsByTagName("mtable")).forEach(table => {
          const id = table.getAttribute("id");
          const rtl = window.getComputedStyle(table).direction === "rtl";
          test(function() {
              assert_true(MathMLFeatureDetection.has_mspace());
              const rows = Array.from(table.getElementsByTagName("mtr"));
              for (var j = 0; j < rows.length; j++) {
                  var cells = Array.from(rows[j].getElementsByTagName("mtd"));
                  for (var i = 0; i < cells.length - 1; i++) {
                      var space1 = cells[i].firstElementChild.getBoundingClientRect();
                      var space2 = cells[i + 1].firstElementChild.getBoundingClientRect();
                      assert_equals(space1.top, space2.top,
                                    `Cells (${i},${j}) and (${i + 1},${j}) should have same vertical position`);
                      if (rtl) {
                          assert_greater_than(space1.left, space2.right,
                                              `Cell (${i},${j}) should be on the right of (${i + 1},${j})`);
                      } else {
                          assert_less_than(space1.right, space2.left,
                                           `Cell (${i},${j}) should be on the left of (${i + 1},${j})`);
                      }
                  }
              }

              for (var j = 0; j < rows.length - 1; j++) {
                  var cells1 = Array.from(rows[j].getElementsByTagName("mtd"));
                  var cells2 = Array.from(rows[j + 1].getElementsByTagName("mtd"));
                  for (var i = 0; i < cells1.length; i++) {
                      var space1 = cells1[i].firstElementChild.getBoundingClientRect();
                      var space2 = cells2[i].firstElementChild.getBoundingClientRect();
                      assert_equals(space1.left, space2.left,
                                    `Cells (${i},${j}) and (${i},${j + 1}) should have same horizontal position`);
                      assert_less_than(space1.bottom, space2.top,
                                       `Cell (${i},${j}) should be above (${i},${j + 1})`);
                  }
              }
          }, `Layout of ${id}`);

      });
      done();
  }
</script>
</head>
<body>
  <div id="log"></div>
  <p>
    <math>
      <mtable id="table-001">
        <mtr>
          <mtd>
            <mspace width="20px" height="10px" style="background: lightblue;"></mspace>
          </mtd>
          <mtd>
            <mspace width="20px" height="10px" style="background: lightgreen;"></mspace>
          </mtd>
        </mtr>
        <mtr>
          <mtd>
            <mspace width="20px" height="10px" style="background: blue;"></mspace>
          </mtd>
          <mtd>
            <mspace width="20px" height="10px" style="background: green;"></mspace>
          </mtd>
        </mtr>
      </mtable>
      <mtable id="table-002">
        <mtr>
          <mtd>
            <mspace width="20px" height="10px" style="background: lightblue;"></mspace>
          </mtd>
          <mtd>
            <mspace width="20px" height="10px" style="background: lightgreen;"></mspace>
          </mtd>
          <mtd>
            <mspace width="20px" height="10px" style="background: cyan;"></mspace>
          </mtd>
          <mtd>
            <mspace width="20px" height="10px" style="background: purple;"></mspace>
          </mtd>
        </mtr>
        <mtr>
          <mtd>
            <mspace width="20px" height="10px" style="background: blue;"></mspace>
          </mtd>
          <mtd>
            <mspace width="20px" height="10px" style="background: green;"></mspace>
          </mtd>
          <mtd>
            <mspace width="20px" height="10px" style="background: yellow;"></mspace>
          </mtd>
          <mtd>
            <mspace width="20px" height="10px" style="background: orange;"></mspace>
          </mtd>
        </mtr>
        <mtr>
          <mtd>
            <mspace width="20px" height="10px" style="background: black;"></mspace>
          </mtd>
          <mtd>
            <mspace width="20px" height="10px" style="background: red;"></mspace>
          </mtd>
          <mtd>
            <mspace width="20px" height="10px" style="background: gray;"></mspace>
          </mtd>
          <mtd>
            <mspace width="20px" height="10px" style="background: maroon;"></mspace>
          </mtd>
        </mtr>
      </mtable>
      <mtable id="table-003">
        <mtr>
          <mtd>
            <mspace width="20px" height="10px" style="background: lightblue;"></mspace>
          </mtd>
          <mtd>
            <mspace width="20px" height="10px" style="background: lightgreen;"></mspace>
          </mtd>
          <mtd>
            <mspace width="20px" height="10px" style="background: cyan;"></mspace>
          </mtd>
        </mtr>
        <mtr>
          <mtd>
            <mspace width="20px" height="10px" style="background: blue;"></mspace>
          </mtd>
          <mtd>
            <mspace width="20px" height="10px" style="background: green;"></mspace>
          </mtd>
          <mtd>
            <mspace width="20px" height="10px" style="background: orange;"></mspace>
          </mtd>
        </mtr>
        <mtr>
          <mtd>
            <mspace width="20px" height="10px" style="background: black;"></mspace>
          </mtd>
          <mtd>
            <mspace width="20px" height="10px" style="background: maroon;"></mspace>
          </mtd>
          <mtd>
            <mspace width="20px" height="10px" style="background: gray;"></mspace>
          </mtd>
        </mtr>
        <mtr>
          <mtd>
            <mspace width="20px" height="10px" style="background: red;"></mspace>
          </mtd>
          <mtd>
            <mspace width="20px" height="10px" style="background: purple;"></mspace>
          </mtd>
          <mtd>
            <mspace width="20px" height="10px" style="background: yellow;"></mspace>
          </mtd>

        </mtr>
      </mtable>
    </math>
  </p>
  <p>
    <math dir="rtl">
      <mtable id="table-011">
        <mtr>
          <mtd>
            <mspace width="20px" height="10px" style="background: lightblue;"></mspace>
          </mtd>
          <mtd>
            <mspace width="20px" height="10px" style="background: lightgreen;"></mspace>
          </mtd>
        </mtr>
        <mtr>
          <mtd>
            <mspace width="20px" height="10px" style="background: blue;"></mspace>
          </mtd>
          <mtd>
            <mspace width="20px" height="10px" style="background: green;"></mspace>
          </mtd>
        </mtr>
      </mtable>
      <mtable id="table-012">
        <mtr>
          <mtd>
            <mspace width="20px" height="10px" style="background: lightblue;"></mspace>
          </mtd>
          <mtd>
            <mspace width="20px" height="10px" style="background: lightgreen;"></mspace>
          </mtd>
          <mtd>
            <mspace width="20px" height="10px" style="background: cyan;"></mspace>
          </mtd>
          <mtd>
            <mspace width="20px" height="10px" style="background: purple;"></mspace>
          </mtd>
        </mtr>
        <mtr>
          <mtd>
            <mspace width="20px" height="10px" style="background: blue;"></mspace>
          </mtd>
          <mtd>
            <mspace width="20px" height="10px" style="background: green;"></mspace>
          </mtd>
          <mtd>
            <mspace width="20px" height="10px" style="background: yellow;"></mspace>
          </mtd>
          <mtd>
            <mspace width="20px" height="10px" style="background: orange;"></mspace>
          </mtd>
        </mtr>
        <mtr>
          <mtd>
            <mspace width="20px" height="10px" style="background: black;"></mspace>
          </mtd>
          <mtd>
            <mspace width="20px" height="10px" style="background: red;"></mspace>
          </mtd>
          <mtd>
            <mspace width="20px" height="10px" style="background: gray;"></mspace>
          </mtd>
          <mtd>
            <mspace width="20px" height="10px" style="background: maroon;"></mspace>
          </mtd>
        </mtr>
      </mtable>
      <mtable id="table-013">
        <mtr>
          <mtd>
            <mspace width="20px" height="10px" style="background: lightblue;"></mspace>
          </mtd>
          <mtd>
            <mspace width="20px" height="10px" style="background: lightgreen;"></mspace>
          </mtd>
          <mtd>
            <mspace width="20px" height="10px" style="background: cyan;"></mspace>
          </mtd>
        </mtr>
        <mtr>
          <mtd>
            <mspace width="20px" height="10px" style="background: blue;"></mspace>
          </mtd>
          <mtd>
            <mspace width="20px" height="10px" style="background: green;"></mspace>
          </mtd>
          <mtd>
            <mspace width="20px" height="10px" style="background: orange;"></mspace>
          </mtd>
        </mtr>
        <mtr>
          <mtd>
            <mspace width="20px" height="10px" style="background: black;"></mspace>
          </mtd>
          <mtd>
            <mspace width="20px" height="10px" style="background: maroon;"></mspace>
          </mtd>
          <mtd>
            <mspace width="20px" height="10px" style="background: gray;"></mspace>
          </mtd>
        </mtr>
        <mtr>
          <mtd>
            <mspace width="20px" height="10px" style="background: red;"></mspace>
          </mtd>
          <mtd>
            <mspace width="20px" height="10px" style="background: purple;"></mspace>
          </mtd>
          <mtd>
            <mspace width="20px" height="10px" style="background: yellow;"></mspace>
          </mtd>

        </mtr>
      </mtable>
    </math>
  </p>
</body>
</html>