Rewrite the tests of scripts-subsup.html
authorfred.wang@free.fr <fred.wang@free.fr@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 7 Jul 2016 14:20:20 +0000 (14:20 +0000)
committerfred.wang@free.fr <fred.wang@free.fr@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 7 Jul 2016 14:20:20 +0000 (14:20 +0000)
https://bugs.webkit.org/show_bug.cgi?id=159202

The tests for script metrics in scripts-subsup.html are very unreliable and difficult to
debug. They currently fail on all platforms. We remove them and import a test from the
MathML in HTML5 test suite that verifies equivalent features in a more reliable and
understandable way. The equivalence test for msubsup and empty script is not preserved as
the current code does not actually try to achieve this equivalence.

Patch by Frederic Wang <fwang@igalia.com> on 2016-07-07
Reviewed by Martin Robinson.

* imported/mathml-in-html5/mathml/presentation-markup/scripts/subsup-1-expected.txt: Added.
* imported/mathml-in-html5/mathml/presentation-markup/scripts/subsup-1.html: Added.
* mathml/presentation/scripts-subsup-expected.html: Remove the tests for metrics.
* mathml/presentation/scripts-subsup.html: Ditto.
* platform/gtk/TestExpectations: Remove failure for scripts-subsup.html.
* platform/ios-simulator-wk1/TestExpectations: Ditto.
* platform/ios-simulator/TestExpectations: Ditto.
* platform/mac/TestExpectations: Ditto.
* platform/win/TestExpectations: Ditto.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@202904 268f45cc-cd09-0410-ab3c-d52691b4dbfc

LayoutTests/ChangeLog
LayoutTests/imported/mathml-in-html5/mathml/presentation-markup/scripts/subsup-1-expected.txt [new file with mode: 0644]
LayoutTests/imported/mathml-in-html5/mathml/presentation-markup/scripts/subsup-1.html [new file with mode: 0644]
LayoutTests/mathml/presentation/scripts-subsup-expected.html
LayoutTests/mathml/presentation/scripts-subsup.html
LayoutTests/platform/gtk/TestExpectations
LayoutTests/platform/ios-simulator-wk1/TestExpectations
LayoutTests/platform/ios-simulator/TestExpectations
LayoutTests/platform/mac/TestExpectations
LayoutTests/platform/win/TestExpectations

index c0c49e4..3258fba 100644 (file)
@@ -1,5 +1,28 @@
 2016-07-07  Frederic Wang  <fwang@igalia.com>
 
+        Rewrite the tests of scripts-subsup.html
+        https://bugs.webkit.org/show_bug.cgi?id=159202
+
+        The tests for script metrics in scripts-subsup.html are very unreliable and difficult to
+        debug. They currently fail on all platforms. We remove them and import a test from the
+        MathML in HTML5 test suite that verifies equivalent features in a more reliable and
+        understandable way. The equivalence test for msubsup and empty script is not preserved as
+        the current code does not actually try to achieve this equivalence.
+
+        Reviewed by Martin Robinson.
+
+        * imported/mathml-in-html5/mathml/presentation-markup/scripts/subsup-1-expected.txt: Added.
+        * imported/mathml-in-html5/mathml/presentation-markup/scripts/subsup-1.html: Added.
+        * mathml/presentation/scripts-subsup-expected.html: Remove the tests for metrics.
+        * mathml/presentation/scripts-subsup.html: Ditto.
+        * platform/gtk/TestExpectations: Remove failure for scripts-subsup.html.
+        * platform/ios-simulator-wk1/TestExpectations: Ditto.
+        * platform/ios-simulator/TestExpectations: Ditto.
+        * platform/mac/TestExpectations: Ditto.
+        * platform/win/TestExpectations: Ditto.
+
+2016-07-07  Frederic Wang  <fwang@igalia.com>
+
         Improve test mathml/presentation/tokenElements-background-color.html
         https://bugs.webkit.org/show_bug.cgi?id=130693
 
diff --git a/LayoutTests/imported/mathml-in-html5/mathml/presentation-markup/scripts/subsup-1-expected.txt b/LayoutTests/imported/mathml-in-html5/mathml/presentation-markup/scripts/subsup-1-expected.txt
new file mode 100644 (file)
index 0000000..bed8e56
--- /dev/null
@@ -0,0 +1,7 @@
+
+PASS Respective horizontal positions 
+PASS Alignment of the base on the baseline 
+PASS Vertical position of scripts 
+PASS Width of scripted elements 
+PASS Height of scripted elements 
+
diff --git a/LayoutTests/imported/mathml-in-html5/mathml/presentation-markup/scripts/subsup-1.html b/LayoutTests/imported/mathml-in-html5/mathml/presentation-markup/scripts/subsup-1.html
new file mode 100644 (file)
index 0000000..ebb3df5
--- /dev/null
@@ -0,0 +1,104 @@
+<!DOCTYPE html>
+<html>
+<head>
+<meta charset="utf-8">
+<title>Subscripts and Superscripts metrics</title>
+<link rel="help" href="http://www.mathml-association.org/MathMLinHTML5/S3.html#SS4">
+<meta name="assert" content="Basic metrics for elements msub, msup and msubsup.">
+<script src="../../../../../resources/testharness.js"></script>
+<script src="../../../../../resources/testharnessreport.js"></script>
+<style>
+  math, mspace {
+    font-size: 10px;
+  }
+</style>
+<script>
+  /* This test does not use any specific fonts and so the exact rules are not
+  specified precisely. We assume reasonable values for script shifts and
+  spacing. */
+
+  function getBox(aId) {
+    var box = document.getElementById(aId).getBoundingClientRect();
+    box.middle = (box.bottom + box.top) / 2;
+    return box;
+  }
+
+  setup({ explicit_done: true });
+  window.addEventListener("load", runTests);
+
+  function runTests() {
+    test(function() {
+      var e = 1;
+      assert_less_than_equal(getBox("msubBase").right, getBox("msubSub").left, e, "msub: subscript is after base");
+      assert_less_than_equal(getBox("msupBase").right, getBox("msupSup").left, e, "msup: superscript is after base");
+      assert_less_than_equal(getBox("msubsupBase").right, getBox("msubsupSub").left, e, "msubsup: subscript is after base");
+      assert_less_than_equal(getBox("msubsupBase").right, getBox("msubsupSup").left, e, "msubsup: superscript is after base");
+
+      e = 3;
+      assert_approx_equals(getBox("msubBase").right, getBox("msubSub").left, e, "msub: space between base and subscript is small");
+      assert_approx_equals(getBox("msubBase").right, getBox("msubSub").left, e, "msub: subscript is after base");
+      assert_approx_equals(getBox("msupBase").right, getBox("msupSup").left, e, "msup: superscript is after base");
+      assert_approx_equals(getBox("msubsupBase").right, getBox("msubsupSub").left, e, "msubsup: subscript is after base");
+      assert_approx_equals(getBox("msubsupBase").right, getBox("msubsupSup").left, e, "msubsup: superscript is after base");
+    }, "Respective horizontal positions");
+
+    test(function() {
+      var e = 1;
+      assert_approx_equals(getBox("msubBase").middle, getBox("baseline").bottom, e, "msub: base is placed on the baseline");
+      assert_approx_equals(getBox("msupBase").middle, getBox("baseline").bottom, e, "msup: base is placed on the baseline");
+      assert_approx_equals(getBox("msubsupBase").middle, getBox("baseline").bottom, e, "msubsup: base is placed on the baseline");
+    }, "Alignment of the base on the baseline");
+
+    test(function() {
+      var e = 3;
+      assert_approx_equals(getBox("msubSub").middle, getBox("msubBase").bottom, e, "msub: script is placed at the bottom of the base");
+      assert_approx_equals(getBox("msupSup").middle, getBox("msupBase").top, e, "msup: script is placed at the top of the base");
+      assert_approx_equals(getBox("msubsupSub").middle, getBox("msubsupBase").bottom, e, "msubsup: script is placed at the bottom of the base");
+      assert_approx_equals(getBox("msubsupSup").middle, getBox("msubsupBase").top, e, "msubsup: script is placed at the top of the base");
+    }, "Vertical position of scripts");
+
+    test(function() {
+      var e = 3;
+      assert_approx_equals(getBox("msub").width, getBox("msubSub").right - getBox("msubBase").left, e, "msub: width is determined by the left/right sides of base/script (+ some space after script)");
+      assert_approx_equals(getBox("msup").width, getBox("msupSup").right - getBox("msupBase").left, e, "msup: width is determined by the left/right sides of base/script (+ some space after script)");
+      assert_approx_equals(getBox("msubsup").width, Math.max(getBox("msubsupSub").right, getBox("msubsupSup").right) - getBox("msubsupBase").left, e, "msubsup: width is determined by the left/right sides of base/scripts (+ some space after script)");
+    }, "Width of scripted elements");
+
+    test(function() {
+      var e = 1;
+      assert_greater_than_equal(getBox("msub").height, getBox("msubBase").height, e, "msub: height is at least the one of the base");
+      assert_greater_than_equal(getBox("msup").height, getBox("msupBase").height, e, "msup: height is at least the one of the base");
+      assert_greater_than_equal(getBox("msubsup").height, getBox("msubsupBase").height, e, "msubsup: height is at least the one of the base");
+
+      e = 3;
+      assert_approx_equals(getBox("msub").height, Math.max(getBox("msubSub").bottom, getBox("msubBase").bottom) - getBox("msubBase").top, e, "msub: height is determined by the top/bottom sides of base/scripts");
+      assert_approx_equals(getBox("msup").height, getBox("msupBase").bottom - Math.min(getBox("msupSup").top, getBox("msupBase").top), e, "msup: height is determined by the top/bottom sides of base/scripts");
+      assert_approx_equals(getBox("msubsup").height, Math.max(getBox("msubSub").bottom, getBox("msubBase").bottom) - Math.min(getBox("msupSup").top, getBox("msupBase").top), e, "msubsup: height is determined by the top/bottom sides of base/scripts");
+    }, "Height of scripted elements");
+
+    done();
+  }
+</script>
+</head>
+<body>
+  <p>
+    <math>
+      <mspace id="baseline" width="30px" height="2px" depth="0px" mathbackground="blue"/>
+      <msub id="msub" mathbackground="green">
+        <mspace id="msubBase" width="30px" height="15px" depth="15px" mathbackground="black"/>
+        <mspace id="msubSub" width="10px" height="5px" depth="5px" mathbackground="black"/>
+      </msub>
+      <msup id="msup" mathbackground="blue">
+        <mspace id="msupBase" width="30px" height="15px" depth="15px" mathbackground="black"/>
+        <mspace id="msupSup" width="10px" height="5px" depth="5px" mathbackground="black"/>
+      </msup>
+      <msubsup id="msubsup" mathbackground="green">
+        <mspace id="msubsupBase" width="30px" height="15px" depth="15px" mathbackground="black"/>
+        <mspace id="msubsupSub" width="10px" height="5px" depth="5px" mathbackground="black"/>
+        <mspace id="msubsupSup" width="10px" height="5px" depth="5px" mathbackground="black"/>
+      </msubsup>
+    </math>
+  </p>
+  <hr/>
+</body>
+</html>
index 8165b87..6dc641d 100644 (file)
       padding: 0;
       border: 0;
       }
-      td {
-      border: 1px solid black;
-      text-align: center; width: 100px; height: 100px;
-      vertical-align: middle;
-      }
-      span {
-      display: inline-block;
-      background: black;
-      border: 0;
-      margin: 0;
-      }
     </style>
   </head>
   <body>
-
-    <!-- The sub/sup scripts should be hidden by the black rectangles -->
-    <table style="position: absolute; top: 10px; left: 10px; font-family: Ahem;">
-      <tr>
-        <td style="text-align: left; vertical-align: top;">
-          <math style="font-family: Ahem;">
-            <msub>
-              <mtext>X</mtext>
-              <mtext style="visibility: hidden;">X</mtext>
-            </msub>
-          </math>
-        </td>
-        <td style="text-align: left;">
-          <math style="font-family: Ahem;">
-            <msubsup>
-              <mtext>X</mtext>
-              <mtext style="visibility: hidden;">X</mtext>
-              <mtext style="visibility: hidden;">X</mtext>
-            </msubsup>
-          </math>
-        </td>
-        <td style="text-align: left; vertical-align: bottom;">
-          <math style="font-family: Ahem;">
-            <msup>
-              <mtext>X</mtext>
-              <mtext style="visibility: hidden;">X</mtext>
-            </msup>
-          </math>
-        </td>
-      </tr>
-    </table>
-
-    <table style="position: absolute; top: 10px; left: 10px; font-family: Ahem;">
-      <tr>
-        <td style="text-align: left; vertical-align: top;">
-          <span style="visibility: hidden;">X</span><span style="vertical-align: -25%;">X</span>
-        </td>
-        <td style="text-align: left;">
-          <span style="visibility: hidden;">X</span><span>X<br/>X</span>
-        </td>
-        <td style="text-align: left; vertical-align: bottom;">
-          <span style="visibility: hidden;">X</span><span style="vertical-align: +50%;">X</span>
-        </td>
-      </tr>
-    </table>
-
-    <!-- The bases should be hidden by the black rectangles -->
-    <table style="position: absolute; top: 120px; left: 10px;">
-      <tr>
-        <td style="text-align: left; vertical-align: top;">
-          <math>
-            <msub>
-              <mtext style="visibility: hidden;">X</mtext>
-              <mtext>X</mtext>
-            </msub>
-          </math>
-        </td>
-        <td style="text-align: left;">
-          <math>
-            <msubsup>
-              <mtext style="visibility: hidden;">X</mtext>
-              <mtext>X</mtext>
-              <mtext>X</mtext>
-            </msubsup>
-          </math>
-        </td>
-        <td style="text-align: left; vertical-align: bottom;">
-          <math>
-            <msup>
-              <mtext style="visibility: hidden;">X</mtext>
-              <mtext>X</mtext>
-            </msup>
-          </math>
-        </td>
-      </tr>
-    </table>
-
-    <table style="position: absolute; top: 120px; left: 10px;">
-      <tr>
-        <td style="text-align: left; vertical-align: top;">
-          <span>X</span>
-        </td>
-        <td style="text-align: left;">
-          <span>X</span>
-        </td>
-        <td style="text-align: left; vertical-align: bottom;">
-          <span>X</span>
-        </td>
-      </tr>
-    </table>
-
-    <div style="position: absolute; top: 250px; left: 10px;">
+    <div>
       <math>
         <msub>
           <mi>A</mi>
           <mi>C</mi>
         </msubsup>
       </math>
-      <math>
-        <msub>
-          <mi>A</mi>
-          <mi>B</mi>
-        </msub>
-        <msup>
-          <mi>A</mi>
-          <mi>B</mi>
-        </msup>
-      </math>
     </div>
 
   </body>
index 7e34b80..5a5b70f 100644 (file)
       padding: 0;
       border: 0;
       }
-      td {
-      border: 1px solid black;
-      text-align: center; width: 100px; height: 100px;
-      vertical-align: middle;
-      }
-      span {
-      display: inline-block;
-      background: black;
-      border: 0;
-      margin: 0;
-      }
     </style>
   </head>
   <body>
-
-    <!-- The sub/sup scripts should be hidden by the black rectangles -->
-    <table style="position: absolute; top: 10px; left: 10px; font-family: Ahem;">
-      <tr>
-        <td style="text-align: left; vertical-align: top;">
-          <math style="font-family: Ahem;">
-            <msub>
-              <mtext>X</mtext>
-              <mtext>X</mtext>
-            </msub>
-          </math>
-        </td>
-        <td style="text-align: left;">
-          <math style="font-family: Ahem;">
-            <msubsup>
-              <mtext>X</mtext>
-              <mtext>X</mtext>
-              <mtext>X</mtext>
-            </msubsup>
-          </math>
-        </td>
-        <td style="text-align: left; vertical-align: bottom;">
-          <math style="font-family: Ahem;">
-            <msup>
-              <mtext>X</mtext>
-              <mtext>X</mtext>
-            </msup>
-          </math>
-        </td>
-      </tr>
-    </table>
-
-    <table style="position: absolute; top: 10px; left: 10px; font-family: Ahem;">
-      <tr>
-        <td style="text-align: left; vertical-align: top;">
-          <span style="visibility: hidden;">X</span><span style="vertical-align: -25%;">X</span>
-        </td>
-        <td style="text-align: left;">
-          <span style="visibility: hidden;">X</span><span>X<br/>X</span>
-        </td>
-        <td style="text-align: left; vertical-align: bottom;">
-          <span style="visibility: hidden;">X</span><span style="vertical-align: +50%;">X</span>
-        </td>
-      </tr>
-    </table>
-
-    <!-- The bases should be hidden by the black rectangles -->
-    <table style="position: absolute; top: 120px; left: 10px;">
-      <tr>
-        <td style="text-align: left; vertical-align: top;">
-          <math>
-            <msub>
-              <mtext>X</mtext>
-              <mtext>X</mtext>
-            </msub>
-          </math>
-        </td>
-        <td style="text-align: left;">
-          <math>
-            <msubsup>
-              <mtext>X</mtext>
-              <mtext>X</mtext>
-              <mtext>X</mtext>
-            </msubsup>
-          </math>
-        </td>
-        <td style="text-align: left; vertical-align: bottom;">
-          <math>
-            <msup>
-              <mtext>X</mtext>
-              <mtext>X</mtext>
-            </msup>
-          </math>
-        </td>
-      </tr>
-    </table>
-
-    <table style="position: absolute; top: 120px; left: 10px;">
-      <tr>
-        <td style="text-align: left; vertical-align: top;">
-          <span>X</span>
-        </td>
-        <td style="text-align: left;">
-          <span>X</span>
-        </td>
-        <td style="text-align: left; vertical-align: bottom;">
-          <span>X</span>
-        </td>
-      </tr>
-    </table>
-
-    <div style="position: absolute; top: 250px; left: 10px;">
+    <div>
       <!-- This verifies that the scripts are drawn smaller. Note: WebKit does
            not currently implement scriptlevel and only sets the size to
            0.75em. See bug 118738. -->
           <mi style="font-size: 0.75em !important">C</mi>
         </msubsup>
       </math>
-
-      <!-- This verifies that <msubsup> with an empty script is
-           equivalent to the corresponding constructions with only one script.
-        -->
-      <math>
-        <msubsup>
-          <mi>A</mi>
-          <mi>B</mi>
-          <mspace/>
-        </msubsup>
-        <msubsup>
-          <mi>A</mi>
-          <mspace/>
-          <mi>B</mi>
-        </msubsup>
-      </math>
     </div>
 
   </body>
index 958fda7..5fb4b3d 100644 (file)
@@ -545,7 +545,6 @@ webkit.org/b/142269 fast/attachment/attachment-dom.html [ Failure ]
 webkit.org/b/142270 fast/canvas/canvas-ellipse-zero-lineto.html [ Failure ]
 
 webkit.org/b/142283 fast/regions/overflow/overflow-first-and-last-regions.html [ ImageOnlyFailure ]
-webkit.org/b/142289 mathml/presentation/scripts-subsup.html [ ImageOnlyFailure ]
 
 webkit.org/b/142819 fast/text/baseline-inline-block.html [ ImageOnlyFailure ]
 
index 8795785..a46fafb 100644 (file)
@@ -735,7 +735,6 @@ mathml/presentation/mo-invisible.html
 
 # MathML tests that fail:
 mathml/presentation/mo-stretch-update.html [ ImageOnlyFailure ]
-mathml/presentation/scripts-subsup.html [ ImageOnlyFailure ]
 
 # SVG tests that fail:
 imported/mozilla/svg/smil/motion/animateMotion-values-linear-1.svg [ ImageOnlyFailure ]
index edf3912..8287ac7 100644 (file)
@@ -678,7 +678,6 @@ mathml/presentation/tokenElements-mathvariant.html [ Skip ]
 # MathML tests that fail:
 mathml/presentation/scripts-height.html [ ImageOnlyFailure ]
 mathml/presentation/multiscripts-positions.html [ Pass ImageOnlyFailure ]
-mathml/presentation/scripts-subsup.html [ Pass ImageOnlyFailure ]
 
 # <rdar://problem/19215305> ASSERT(m_cgFont.get()) fails in FontPlatformData::ctFont()
 svg/text/svg-fallback-font-crash.html
index 8a80aff..ba8e477 100644 (file)
@@ -807,7 +807,6 @@ mathml/opentype/large-operators-italic-correction.html [ Skip ]
 
 # MathML tests that fail:
 mathml/presentation/multiscripts-positions.html [ Pass ImageOnlyFailure ]
-mathml/presentation/scripts-subsup.html [ Pass ImageOnlyFailure ]
 
 webkit.org/b/128255 compositing/columns/composited-lr-paginated-repaint.html [ Pass Failure ]
 webkit.org/b/128255 compositing/columns/composited-rl-paginated-repaint.html [ Pass Failure ]
index 1785d08..7b4f60b 100644 (file)
@@ -1943,7 +1943,6 @@ mathml/presentation/mo-stacked-glyphs.html [ ImageOnlyFailure ]
 mathml/presentation/style-changed.html [ Crash Pass ]
 mathml/opentype/large-operators-munderover.html [ Failure ]
 mathml/presentation/attributes-mathvariant.html [ ImageOnlyFailure ]
-webkit.org/b/159202 mathml/presentation/scripts-subsup.html [ ImageOnlyFailure ]
 mathml/presentation/tokenElements-mathvariant.html [ ImageOnlyFailure ]
 
 # These tests require the Latin Modern Math font.