Bug 1642664 [wpt PR 23916] - MathML: check that spacing is not added unless mrow layout is used., a=testonly draft
authorFrédéric Wang <fwang@igalia.com>
Mon, 08 Jun 2020 20:07:46 +0000
changeset 2968295 39304429c9f6330dc9f578d11d632b3b3da3822b
parent 2968294 fbc0857ae38ee6af5e82029e0a20d24b0865af4b
child 2968296 6ca7a08a8c18b3e7fad42e69fd8507d5daeb542e
push id550673
push userreviewbot
push dateMon, 08 Jun 2020 20:08:18 +0000
treeherdertry@5ad8b739e55a [default view] [failures only]
reviewerstestonly
bugs1642664, 23916
milestone79.0a1
Bug 1642664 [wpt PR 23916] - MathML: check that spacing is not added unless mrow layout is used., a=testonly Automatic update from web-platform-tests MathML: check that spacing is not added unless mrow layout is used. (#23916) This is different from MathML3 which uses "inferred mrow", although the MathML3 spec is not clear how spacing would be handled anyway and whether <inferredmrow><mo></inferredmrow> is embellihed. -- wpt-commits: 6fba8fd9df16c5152392595e6e4f255628b99c74 wpt-pr: 23916 Differential Diff: PHID-DIFF-k6xpyyvtivm7s2rmlvo7
testing/web-platform/tests/mathml/presentation-markup/mrow/no-spacing.html
new file mode 100644
--- /dev/null
+++ b/testing/web-platform/tests/mathml/presentation-markup/mrow/no-spacing.html
@@ -0,0 +1,138 @@
+<!DOCTYPE html>
+<html>
+<head>
+<meta charset="utf-8">
+<title>No spacing in elements</title>
+<meta name="assert" content="Spacing is not added around operators when an element does not use mrow layout. However, when the element is embellished, spacing of the core mo is added around it.">
+<link rel="help" href="https://mathml-refresh.github.io/mathml-core/#embellished-operators">
+<link rel="help" href="https://mathml-refresh.github.io/mathml-core/#fractions-mfrac">
+<link rel="help" href="https://mathml-refresh.github.io/mathml-core/#horizontally-group-sub-expressions-mrow">
+<link rel="help" href="https://mathml-refresh.github.io/mathml-core/#operator-fence-separator-or-accent-mo">
+<link rel="help" href="https://mathml-refresh.github.io/mathml-core/#prescripts-and-tensor-indices-mmultiscripts">
+<link rel="help" href="https://mathml-refresh.github.io/mathml-core/#radicals-msqrt-mroot">
+<link rel="help" href="https://mathml-refresh.github.io/mathml-core/#subscripts-and-superscripts-msub-msup-msubsup">
+<link rel="help" href="https://mathml-refresh.github.io/mathml-core/#underscripts-and-overscripts-munder-mover-munderover">
+<script src="/mathml/support/feature-detection.js"></script>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<link rel="stylesheet" type="text/css" href="/fonts/ahem.css" />
+<script type="text/javascript">
+  setup({ explicit_done: true });
+  window.addEventListener("load", () => { document.fonts.ready.then(runTests); });
+  function runTests()
+  {
+      Array.from(document.getElementsByClassName("testedElement")).forEach((e) => {
+          test(function() {
+              assert_true(MathMLFeatureDetection.has_operator_spacing());
+              let box = e.getBoundingClientRect();
+              let spacing = 100;
+              assert_less_than_equal(box.width, spacing);
+          }, `Spacing inside <${e.tagName}>.`);
+
+          test(function() {
+              assert_true(MathMLFeatureDetection.has_operator_spacing());
+              let box = e.parentNode.getBoundingClientRect();
+              let spacing = 100;
+              if (e.classList.contains("embellished"))
+                  assert_greater_than_equal(box.width, spacing * 2);
+              else
+                  assert_less_than_equal(box.width, spacing);
+          }, `Spacing around <${e.tagName}>.`);
+      });
+      done();
+  }
+</script>
+<style>
+  .testedElement {
+      background: lightgreen;
+  }
+  math {
+      background: lightblue;
+  }
+  math, math * {
+      font: 25px/1 Ahem;
+  }
+</style>
+</head>
+<body>
+  <div id="log"></div>
+  <p>
+    <math>
+      <mfrac class="testedElement embellished">
+        <mo lspace="100px" rspace="100px">X</mo>
+        <mo lspace="100px" rspace="100px">X</mo>
+      </mfrac>
+    </math>
+  </p>
+  <p>
+    <math>
+      <msub class="testedElement embellished">
+        <mo lspace="100px" rspace="100px">X</mo>
+        <mo lspace="100px" rspace="100px">X</mo>
+      </msub>
+    </math>
+  </p>
+  <p>
+    <math>
+      <msup class="testedElement embellished">
+        <mo lspace="100px" rspace="100px">X</mo>
+        <mo lspace="100px" rspace="100px">X</mo>
+      </msup>
+    </math>
+  </p>
+  <p>
+    <math>
+      <msubsup class="testedElement embellished">
+        <mo lspace="100px" rspace="100px">X</mo>
+        <mo lspace="100px" rspace="100px">X</mo>
+        <mo lspace="100px" rspace="100px">X</mo>
+      </msubsup>
+    </math>
+  </p>
+  <p>
+    <math>
+      <mmultiscripts class="testedElement embellished">
+        <mo lspace="100px" rspace="100px">X</mo>
+        <mo lspace="100px" rspace="100px">X</mo>
+        <mo lspace="100px" rspace="100px">X</mo>
+        <mprescripts/>
+        <mo lspace="100px" rspace="100px">X</mo>
+        <mo lspace="100px" rspace="100px">X</mo>
+      </mmultiscripts>
+    </math>
+  </p>
+  <p>
+    <math>
+      <munder class="testedElement embellished">
+        <mo lspace="100px" rspace="100px">X</mo>
+        <mo lspace="100px" rspace="100px">X</mo>
+      </munder>
+    </math>
+  </p>
+  <p>
+    <math>
+      <mover class="testedElement embellished">
+        <mo lspace="100px" rspace="100px">X</mo>
+        <mo lspace="100px" rspace="100px">X</mo>
+      </mover>
+    </math>
+  </p>
+  <p>
+    <math>
+      <munderover class="testedElement embellished">
+        <mo lspace="100px" rspace="100px">X</mo>
+        <mo lspace="100px" rspace="100px">X</mo>
+        <mo lspace="100px" rspace="100px">X</mo>
+      </munderover>
+    </math>
+  </p>
+  <p>
+    <math>
+      <mroot class="testedElement">
+        <mtext>X</mtext>
+        <mo lspace="100px" rspace="100px">X</mo>
+      </mroot>
+    </math>
+  </p>
+</body>
+</html>