<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Embellished operators</title>
<link rel="stylesheet" type="text/css" href="/fonts/ahem.css" />
<link rel="help" href="https://w3c.github.io/mathml-core/#embellished-operators">
<link rel="help" href="https://w3c.github.io/mathml-core/#definition-of-space-like-elements">
<link rel="help" href="https://w3c.github.io/mathml-core/#layout-of-mrow">
<meta name="assert" content="Verify definition of embellished operators">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/mathml/support/feature-detection.js"></script>
<script src="/mathml/support/box-navigation.js"></script>
<style>
  /* Default spacing of operator 'X' is 0.2777777777777778em so quite different
     from the measured/specified 0em and 1em. */
  math, math * {
      font: 25px/1 Ahem;
  }
  mn {
      color: black;
  }
  mtext.space-like {
      color: lightblue !important;
  }
  .testedElement mo {
      color: yellow !important;
  }
  .testedElement, .testedElement * {
      color: blue !important;
      background: blue !important;
  }
  .oof1 {
      position: absolute;
  }
  .oof2 {
      position: fixed;
  }
  .nobox {
      display: none;
  }
</style>
<script>
  function spaceBeforeElement(element) {
      var mnBefore = previousInFlowSibling(element);
      return element.getBoundingClientRect().left - mnBefore.getBoundingClientRect().right;
  }

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

  function runTests() {
      var epsilon = 1;
      var emToPx = 25;

      ["msub", "msup", "msubsup", "munder", "mover", "munderover",
       "mmultiscripts", "mfrac"].forEach(tag => {
           test(function() {
               assert_true(MathMLFeatureDetection.has_operator_spacing());
               var element = document.getElementsByTagName(tag)[0];
               assert_approx_equals(spaceBeforeElement(element), 2 * emToPx, epsilon);
           }, `${tag} (embellished operator)`);

           test(function() {
               assert_true(MathMLFeatureDetection.has_operator_spacing());
               var element = document.getElementsByTagName(tag)[1];
               assert_approx_equals(spaceBeforeElement(element), 2 * emToPx, epsilon);
           }, `${tag} (embellished operator, from in-flow children)`);

           test(function() {
               assert_true(MathMLFeatureDetection.has_operator_spacing());
               var element = document.getElementsByTagName(tag)[2];
               assert_approx_equals(spaceBeforeElement(element), 0, epsilon);
           }, `${tag} (not embellished operator)`);

           test(function() {
               assert_true(MathMLFeatureDetection.has_operator_spacing());
               var element = document.getElementsByTagName(tag)[3];
               assert_approx_equals(spaceBeforeElement(element), 0, epsilon);
           }, `${tag} (not embellished operator, from in-flow children)`);
      });
      done();
  }
</script>
</head>
<body>
  <div id="log"></div>
  <!-- <msub>, <msup>, <msubsup>, <munder>, <mover>, <munderover>,
       <mmultiscripts>, <mfrac> are embellished
       operators if their first in-flow
       child exists and is an embellished operator -->
  <p>
    <math>
      <mn>X</mn>
      <msub class="testedElement">
        <mo lspace="2em" rspace="0em">X</mo>
        <mn>X</mn>
      </msub>
      <mn>X</mn>
    </math>
  </p>
  <p>
    <math>
      <mn>X</mn>
      <msup class="testedElement">
        <mo lspace="2em" rspace="0em">X</mo>
        <mn>X</mn>
      </msup>
      <mn>X</mn>
    </math>
  </p>
  <p>
    <math>
      <mn>X</mn>
      <msubsup class="testedElement">
        <mo lspace="2em" rspace="0em">X</mo>
        <mn>X</mn>
        <mn>X</mn>
      </msubsup>
      <mn>X</mn>
    </math>
  </p>
  <p>
    <math>
      <mn>X</mn>
      <munder class="testedElement">
        <mo lspace="2em" rspace="0em">X</mo>
        <mn>X</mn>
      </munder>
      <mn>X</mn>
    </math>
  </p>
  <p>
    <math>
      <mn>X</mn>
      <mover class="testedElement">
        <mo lspace="2em" rspace="0em">X</mo>
        <mn>X</mn>
      </mover>
      <mn>X</mn>
    </math>
  </p>
  <p>
    <math>
      <mn>X</mn>
      <munderover class="testedElement">
        <mo lspace="2em" rspace="0em">X</mo>
        <mn>X</mn>
      </munderover>
      <mn>X</mn>
    </math>
  </p>
  <p>
    <math>
      <mn>X</mn>
      <mmultiscripts class="testedElement">
        <mo lspace="2em" rspace="0em">X</mo>
        <mn>X</mn>
        <mn>X</mn>
        <mn>X</mn>
        <mn>X</mn>
      </mmultiscripts>
      <mn>X</mn>
    </math>
  </p>
  <p>
    <math>
      <mn>X</mn>
      <mfrac class="testedElement">
        <mo lspace="2em" rspace="0em">X</mo>
        <mn>X</mn>
      </mfrac>
      <mn>X</mn>
    </math>
  </p>

  <!-- Only in-flow children affect determination of embellished operators. -->
  <p>
    <math>
      <mn class="oof1">0</mn><mn class="oof2">1</mn><mn class="nobox">2</mn>
      <mn>X</mn>
      <mn class="oof1">0</mn><mn class="oof2">1</mn><mn class="nobox">2</mn>
      <msub class="testedElement">
        <mn class="oof1">0</mn><mn class="oof2">1</mn><mn class="nobox">2</mn>
        <mo lspace="2em" rspace="0em">X</mo>
        <mn class="oof1">0</mn><mn class="oof2">1</mn><mn class="nobox">2</mn>
        <mn>X</mn>
        <mn class="oof1">0</mn><mn class="oof2">1</mn><mn class="nobox">2</mn>
      </msub>
      <mn class="oof1">0</mn><mn class="oof2">1</mn><mn class="nobox">2</mn>
      <mn>X</mn>
      <mn class="oof1">0</mn><mn class="oof2">1</mn><mn class="nobox">2</mn>
    </math>
  </p>
  <p>
    <math>
      <mn class="oof1">0</mn><mn class="oof2">1</mn><mn class="nobox">2</mn>
      <mn>X</mn>
      <mn class="oof1">0</mn><mn class="oof2">1</mn><mn class="nobox">2</mn>
      <msup class="testedElement">
        <mn class="oof1">0</mn><mn class="oof2">1</mn><mn class="nobox">2</mn>
        <mo lspace="2em" rspace="0em">X</mo>
        <mn class="oof1">0</mn><mn class="oof2">1</mn><mn class="nobox">2</mn>
        <mn>X</mn>
        <mn class="oof1">0</mn><mn class="oof2">1</mn><mn class="nobox">2</mn>
      </msup>
      <mn class="oof1">0</mn><mn class="oof2">1</mn><mn class="nobox">2</mn>
      <mn>X</mn>
      <mn class="oof1">0</mn><mn class="oof2">1</mn><mn class="nobox">2</mn>
    </math>
  </p>
  <p>
    <math>
      <mn class="oof1">0</mn><mn class="oof2">1</mn><mn class="nobox">2</mn>
      <mn>X</mn>
      <mn class="oof1">0</mn><mn class="oof2">1</mn><mn class="nobox">2</mn>
      <msubsup class="testedElement">
        <mn class="oof1">0</mn><mn class="oof2">1</mn><mn class="nobox">2</mn>
        <mo lspace="2em" rspace="0em">X</mo>
        <mn class="oof1">0</mn><mn class="oof2">1</mn><mn class="nobox">2</mn>
        <mn>X</mn>
        <mn class="oof1">0</mn><mn class="oof2">1</mn><mn class="nobox">2</mn>
        <mn>X</mn>
        <mn class="oof1">0</mn><mn class="oof2">1</mn><mn class="nobox">2</mn>
      </msubsup>
      <mn class="oof1">0</mn><mn class="oof2">1</mn><mn class="nobox">2</mn>
      <mn>X</mn>
      <mn class="oof1">0</mn><mn class="oof2">1</mn><mn class="nobox">2</mn>
    </math>
  </p>
  <p>
    <math>
      <mn class="oof1">0</mn><mn class="oof2">1</mn><mn class="nobox">2</mn>
      <mn>X</mn>
      <mn class="oof1">0</mn><mn class="oof2">1</mn><mn class="nobox">2</mn>
      <munder class="testedElement">
        <mn class="oof1">0</mn><mn class="oof2">1</mn><mn class="nobox">2</mn>
        <mo lspace="2em" rspace="0em">X</mo>
        <mn class="oof1">0</mn><mn class="oof2">1</mn><mn class="nobox">2</mn>
        <mn>X</mn>
        <mn class="oof1">0</mn><mn class="oof2">1</mn><mn class="nobox">2</mn>
      </munder>
      <mn class="oof1">0</mn><mn class="oof2">1</mn><mn class="nobox">2</mn>
      <mn>X</mn>
      <mn class="oof1">0</mn><mn class="oof2">1</mn><mn class="nobox">2</mn>
    </math>
  </p>
  <p>
    <math>
      <mn class="oof1">0</mn><mn class="oof2">1</mn><mn class="nobox">2</mn>
      <mn>X</mn>
      <mn class="oof1">0</mn><mn class="oof2">1</mn><mn class="nobox">2</mn>
      <mover class="testedElement">
        <mn class="oof1">0</mn><mn class="oof2">1</mn><mn class="nobox">2</mn>
        <mo lspace="2em" rspace="0em">X</mo>
        <mn class="oof1">0</mn><mn class="oof2">1</mn><mn class="nobox">2</mn>
        <mn>X</mn>
        <mn class="oof1">0</mn><mn class="oof2">1</mn><mn class="nobox">2</mn>
      </mover>
      <mn class="oof1">0</mn><mn class="oof2">1</mn><mn class="nobox">2</mn>
      <mn>X</mn>
      <mn class="oof1">0</mn><mn class="oof2">1</mn><mn class="nobox">2</mn>
    </math>
  </p>
  <p>
    <math>
      <mn class="oof1">0</mn><mn class="oof2">1</mn><mn class="nobox">2</mn>
      <mn>X</mn>
      <mn class="oof1">0</mn><mn class="oof2">1</mn><mn class="nobox">2</mn>
      <munderover class="testedElement">
        <mn class="oof1">0</mn><mn class="oof2">1</mn><mn class="nobox">2</mn>
        <mo lspace="2em" rspace="0em">X</mo>
        <mn class="oof1">0</mn><mn class="oof2">1</mn><mn class="nobox">2</mn>
        <mn>X</mn>
        <mn class="oof1">0</mn><mn class="oof2">1</mn><mn class="nobox">2</mn>
      </munderover>
      <mn class="oof1">0</mn><mn class="oof2">1</mn><mn class="nobox">2</mn>
      <mn>X</mn>
      <mn class="oof1">0</mn><mn class="oof2">1</mn><mn class="nobox">2</mn>
    </math>
  </p>
  <p>
    <math>
      <mn class="oof1">0</mn><mn class="oof2">1</mn><mn class="nobox">2</mn>
      <mn>X</mn>
      <mn class="oof1">0</mn><mn class="oof2">1</mn><mn class="nobox">2</mn>
      <mmultiscripts class="testedElement">
        <mn class="oof1">0</mn><mn class="oof2">1</mn><mn class="nobox">2</mn>
        <mo lspace="2em" rspace="0em">X</mo>
        <mn class="oof1">0</mn><mn class="oof2">1</mn><mn class="nobox">2</mn>
        <mn>X</mn>
        <mn class="oof1">0</mn><mn class="oof2">1</mn><mn class="nobox">2</mn>
        <mn>X</mn>
        <mn class="oof1">0</mn><mn class="oof2">1</mn><mn class="nobox">2</mn>
        <mn>X</mn>
        <mn class="oof1">0</mn><mn class="oof2">1</mn><mn class="nobox">2</mn>
        <mn>X</mn>
        <mn class="oof1">0</mn><mn class="oof2">1</mn><mn class="nobox">2</mn>
      </mmultiscripts>
      <mn class="oof1">0</mn><mn class="oof2">1</mn><mn class="nobox">2</mn>
      <mn>X</mn>
      <mn class="oof1">0</mn><mn class="oof2">1</mn><mn class="nobox">2</mn>
    </math>
  </p>
  <p>
    <math>
      <mn class="oof1">0</mn><mn class="oof2">1</mn><mn class="nobox">2</mn>
      <mn>X</mn>
      <mn class="oof1">0</mn><mn class="oof2">1</mn><mn class="nobox">2</mn>
      <mfrac class="testedElement">
        <mn class="oof1">0</mn><mn class="oof2">1</mn><mn class="nobox">2</mn>
        <mo lspace="2em" rspace="0em">X</mo>
        <mn class="oof1">0</mn><mn class="oof2">1</mn><mn class="nobox">2</mn>
        <mn>X</mn>
        <mn class="oof1">0</mn><mn class="oof2">1</mn><mn class="nobox">2</mn>
      </mfrac>
      <mn class="oof1">0</mn><mn class="oof2">1</mn><mn class="nobox">2</mn>
      <mn>X</mn>
      <mn class="oof1">0</mn><mn class="oof2">1</mn><mn class="nobox">2</mn>
    </math>
  </p>

  <!-- <msub>, <msup>, <msubsup>, <munder>, <mover>, <munderover>,
       <mmultiscripts>, <mfrac> are not embellished
       operators if their first in-flow child is not an embellished operator -->
  <p>
    <math>
      <mn>X</mn>
      <msub class="testedElement">
        <mn>X</mn>
        <mo lspace="2em" rspace="0em">X</mo>
      </msub>
      <mn>X</mn>
    </math>
  </p>
  <p>
    <math>
      <mn>X</mn>
      <msup class="testedElement">
        <mn>X</mn>
        <mo lspace="2em" rspace="0em">X</mo>
      </msup>
      <mn>X</mn>
    </math>
  </p>
  <p>
    <math>
      <mn>X</mn>
      <msubsup class="testedElement">
        <mn>X</mn>
        <mo lspace="2em" rspace="0em">X</mo>
        <mn>X</mn>
      </msubsup>
      <mn>X</mn>
    </math>
  </p>
  <p>
    <math>
      <mn>X</mn>
      <munder class="testedElement">
        <mn>X</mn>
        <mo lspace="2em" rspace="0em">X</mo>
      </munder>
      <mn>X</mn>
    </math>
  </p>
  <p>
    <math>
      <mn>X</mn>
      <mover class="testedElement">
        <mn>X</mn>
        <mo lspace="2em" rspace="0em">X</mo>
      </mover>
      <mn>X</mn>
    </math>
  </p>
  <p>
    <math>
      <mn>X</mn>
      <munderover class="testedElement">
        <mn>X</mn>
        <mo lspace="2em" rspace="0em">X</mo>
      </munderover>
      <mn>X</mn>
    </math>
  </p>
  <p>
    <math>
      <mn>X</mn>
      <mmultiscripts class="testedElement">
        <mn>X</mn>
        <mo lspace="2em" rspace="0em">X</mo>
        <mn>X</mn>
        <mn>X</mn>
        <mn>X</mn>
      </mmultiscripts>
      <mn>X</mn>
    </math>
  </p>
  <p>
    <math>
      <mn>X</mn>
      <mfrac class="testedElement">
        <mn>X</mn>
        <mo lspace="2em" rspace="0em">X</mo>
      </mfrac>
      <mn>X</mn>
    </math>
  </p>

  <!-- Only in-flow children affect determination of embellished operators. -->
  <p>
    <math>
      <mn class="oof1">0</mn><mn class="oof2">1</mn><mn class="nobox">2</mn>
      <mn>X</mn>
      <mn class="oof1">0</mn><mn class="oof2">1</mn><mn class="nobox">2</mn>
      <msub class="testedElement">
        <mn class="oof1">0</mn><mn class="oof2">1</mn><mn class="nobox">2</mn>
        <mn>X</mn>
        <mn class="oof1">0</mn><mn class="oof2">1</mn><mn class="nobox">2</mn>
        <mo lspace="2em" rspace="0em">X</mo>
        <mn class="oof1">0</mn><mn class="oof2">1</mn><mn class="nobox">2</mn>
      </msub>
      <mn class="oof1">0</mn><mn class="oof2">1</mn><mn class="nobox">2</mn>
      <mn>X</mn>
      <mn class="oof1">0</mn><mn class="oof2">1</mn><mn class="nobox">2</mn>
    </math>
  </p>
  <p>
    <math>
      <mn class="oof1">0</mn><mn class="oof2">1</mn><mn class="nobox">2</mn>
      <mn>X</mn>
      <mn class="oof1">0</mn><mn class="oof2">1</mn><mn class="nobox">2</mn>
      <msup class="testedElement">
        <mn class="oof1">0</mn><mn class="oof2">1</mn><mn class="nobox">2</mn>
        <mn>X</mn>
        <mn class="oof1">0</mn><mn class="oof2">1</mn><mn class="nobox">2</mn>
        <mo lspace="2em" rspace="0em">X</mo>
        <mn class="oof1">0</mn><mn class="oof2">1</mn><mn class="nobox">2</mn>
      </msup>
      <mn class="oof1">0</mn><mn class="oof2">1</mn><mn class="nobox">2</mn>
      <mn>X</mn>
      <mn class="oof1">0</mn><mn class="oof2">1</mn><mn class="nobox">2</mn>
    </math>
  </p>
  <p>
    <math>
      <mn class="oof1">0</mn><mn class="oof2">1</mn><mn class="nobox">2</mn>
      <mn>X</mn>
      <mn class="oof1">0</mn><mn class="oof2">1</mn><mn class="nobox">2</mn>
      <msubsup class="testedElement">
        <mn class="oof1">0</mn><mn class="oof2">1</mn><mn class="nobox">2</mn>
        <mn>X</mn>
        <mn class="oof1">0</mn><mn class="oof2">1</mn><mn class="nobox">2</mn>
        <mo lspace="2em" rspace="0em">X</mo>
        <mn class="oof1">0</mn><mn class="oof2">1</mn><mn class="nobox">2</mn>
        <mn>X</mn>
        <mn class="oof1">0</mn><mn class="oof2">1</mn><mn class="nobox">2</mn>
      </msubsup>
      <mn class="oof1">0</mn><mn class="oof2">1</mn><mn class="nobox">2</mn>
      <mn>X</mn>
      <mn class="oof1">0</mn><mn class="oof2">1</mn><mn class="nobox">2</mn>
    </math>
  </p>
  <p>
    <math>
      <mn class="oof1">0</mn><mn class="oof2">1</mn><mn class="nobox">2</mn>
      <mn>X</mn>
      <mn class="oof1">0</mn><mn class="oof2">1</mn><mn class="nobox">2</mn>
      <munder class="testedElement">
        <mn class="oof1">0</mn><mn class="oof2">1</mn><mn class="nobox">2</mn>
        <mn>X</mn>
        <mn class="oof1">0</mn><mn class="oof2">1</mn><mn class="nobox">2</mn>
        <mo lspace="2em" rspace="0em">X</mo>
        <mn class="oof1">0</mn><mn class="oof2">1</mn><mn class="nobox">2</mn>
      </munder>
      <mn class="oof1">0</mn><mn class="oof2">1</mn><mn class="nobox">2</mn>
      <mn>X</mn>
      <mn class="oof1">0</mn><mn class="oof2">1</mn><mn class="nobox">2</mn>
    </math>
  </p>
  <p>
    <math>
      <mn class="oof1">0</mn><mn class="oof2">1</mn><mn class="nobox">2</mn>
      <mn>X</mn>
      <mn class="oof1">0</mn><mn class="oof2">1</mn><mn class="nobox">2</mn>
      <mover class="testedElement">
        <mn class="oof1">0</mn><mn class="oof2">1</mn><mn class="nobox">2</mn>
        <mn>X</mn>
        <mn class="oof1">0</mn><mn class="oof2">1</mn><mn class="nobox">2</mn>
        <mo lspace="2em" rspace="0em">X</mo>
        <mn class="oof1">0</mn><mn class="oof2">1</mn><mn class="nobox">2</mn>
      </mover>
      <mn class="oof1">0</mn><mn class="oof2">1</mn><mn class="nobox">2</mn>
      <mn>X</mn>
      <mn class="oof1">0</mn><mn class="oof2">1</mn><mn class="nobox">2</mn>
    </math>
  </p>
  <p>
    <math>
      <mn class="oof1">0</mn><mn class="oof2">1</mn><mn class="nobox">2</mn>
      <mn>X</mn>
      <mn class="oof1">0</mn><mn class="oof2">1</mn><mn class="nobox">2</mn>
      <munderover class="testedElement">
        <mn class="oof1">0</mn><mn class="oof2">1</mn><mn class="nobox">2</mn>
        <mn>X</mn>
        <mn class="oof1">0</mn><mn class="oof2">1</mn><mn class="nobox">2</mn>
        <mo lspace="2em" rspace="0em">X</mo>
        <mn class="oof1">0</mn><mn class="oof2">1</mn><mn class="nobox">2</mn>
      </munderover>
      <mn class="oof1">0</mn><mn class="oof2">1</mn><mn class="nobox">2</mn>
      <mn>X</mn>
      <mn class="oof1">0</mn><mn class="oof2">1</mn><mn class="nobox">2</mn>
    </math>
  </p>
  <p>
    <math>
      <mn class="oof1">0</mn><mn class="oof2">1</mn><mn class="nobox">2</mn>
      <mn>X</mn>
      <mn class="oof1">0</mn><mn class="oof2">1</mn><mn class="nobox">2</mn>
      <mmultiscripts class="testedElement">
        <mn class="oof1">0</mn><mn class="oof2">1</mn><mn class="nobox">2</mn>
        <mn>X</mn>
        <mn class="oof1">0</mn><mn class="oof2">1</mn><mn class="nobox">2</mn>
        <mo lspace="2em" rspace="0em">X</mo>
        <mn class="oof1">0</mn><mn class="oof2">1</mn><mn class="nobox">2</mn>
        <mn>X</mn>
        <mn class="oof1">0</mn><mn class="oof2">1</mn><mn class="nobox">2</mn>
        <mn>X</mn>
        <mn class="oof1">0</mn><mn class="oof2">1</mn><mn class="nobox">2</mn>
        <mn>X</mn>
        <mn class="oof1">0</mn><mn class="oof2">1</mn><mn class="nobox">2</mn>
      </mmultiscripts>
      <mn class="oof1">0</mn><mn class="oof2">1</mn><mn class="nobox">2</mn>
      <mn>X</mn>
      <mn class="oof1">0</mn><mn class="oof2">1</mn><mn class="nobox">2</mn>
    </math>
  </p>
  <p>
    <math>
      <mn class="oof1">0</mn><mn class="oof2">1</mn><mn class="nobox">2</mn>
      <mn>X</mn>
      <mn class="oof1">0</mn><mn class="oof2">1</mn><mn class="nobox">2</mn>
      <mfrac class="testedElement">
        <mn class="oof1">0</mn><mn class="oof2">1</mn><mn class="nobox">2</mn>
        <mn>X</mn>
        <mn class="oof1">0</mn><mn class="oof2">1</mn><mn class="nobox">2</mn>
        <mo lspace="2em" rspace="0em">X</mo>
        <mn class="oof1">0</mn><mn class="oof2">1</mn><mn class="nobox">2</mn>
      </mfrac>
      <mn class="oof1">0</mn><mn class="oof2">1</mn><mn class="nobox">2</mn>
      <mn>X</mn>
      <mn class="oof1">0</mn><mn class="oof2">1</mn><mn class="nobox">2</mn>
    </math>
  </p>

</body>
</html>
