Bug 1638147 - Introduce tests for MathML accessibility support on mac. r=morgan
authorEitan Isaacson <eitan@monotonous.org>
Wed, 20 May 2020 23:53:46 +0000
changeset 531355 1afd7205a9f3d9c61ba847dd7769543ad8befeaa
parent 531354 17c8b0e564637546efa3291f173253841c184f1b
child 531356 7b87e7b47c38348c3c6bf99c19e77e95b00a680c
push id37438
push userabutkovits@mozilla.com
push dateThu, 21 May 2020 09:36:57 +0000
treeherdermozilla-central@2d00a1a6495c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmorgan
bugs1638147
milestone78.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1638147 - Introduce tests for MathML accessibility support on mac. r=morgan Differential Revision: https://phabricator.services.mozilla.com/D75425
accessible/tests/browser/mac/browser.ini
accessible/tests/browser/mac/browser_mathml.js
--- a/accessible/tests/browser/mac/browser.ini
+++ b/accessible/tests/browser/mac/browser.ini
@@ -17,8 +17,9 @@ support-files =
 [browser_roles_elements.js]
 [browser_table.js]
 [browser_selectables.js]
 [browser_toggle_radio_check.js]
 [browser_link.js]
 [browser_aria_haspopup.js]
 [browser_required.js]
 [browser_popupbutton.js]
+[browser_mathml.js]
new file mode 100644
--- /dev/null
+++ b/accessible/tests/browser/mac/browser_mathml.js
@@ -0,0 +1,151 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+"use strict";
+
+function testMathAttr(iface, attr, subrole, textLeafValue) {
+  ok(iface.attributeNames.includes(attr), `Object has ${attr} attribute`);
+  let value = iface.getAttributeValue(attr);
+  is(
+    value.getAttributeValue("AXSubrole"),
+    subrole,
+    `${attr} value has correct subrole`
+  );
+
+  if (textLeafValue) {
+    let children = value.getAttributeValue("AXChildren");
+    is(children.length, 1, `${attr} value has one child`);
+
+    is(
+      children[0].getAttributeValue("AXRole"),
+      "AXStaticText",
+      `${attr} value's child is static text`
+    );
+    is(
+      children[0].getAttributeValue("AXValue"),
+      textLeafValue,
+      `${attr} value has correct text`
+    );
+  }
+}
+
+addAccessibleTask(
+  `<math id="math">
+     <msqrt id="sqrt">
+      <mi>-1</mi>
+    </msqrt>
+    </math>`,
+  async (browser, accDoc) => {
+    let math = getNativeInterface(accDoc, "math");
+    is(
+      math.getAttributeValue("AXSubrole"),
+      "AXDocumentMath",
+      "Math element has correct subrole"
+    );
+
+    let sqrt = getNativeInterface(accDoc, "sqrt");
+    is(
+      sqrt.getAttributeValue("AXSubrole"),
+      "AXMathSquareRoot",
+      "msqrt has correct subrole"
+    );
+
+    testMathAttr(sqrt, "AXMathRootRadicand", "AXMathIdentifier", "-1");
+  }
+);
+
+addAccessibleTask(
+  `<math>
+    <mroot id="root">
+      <mi>x</mi>
+      <mn>3</mn>
+    </mroot>
+  </math>`,
+  async (browser, accDoc) => {
+    let root = getNativeInterface(accDoc, "root");
+    is(
+      root.getAttributeValue("AXSubrole"),
+      "AXMathRoot",
+      "mroot has correct subrole"
+    );
+
+    testMathAttr(root, "AXMathRootRadicand", "AXMathIdentifier", "x");
+    testMathAttr(root, "AXMathRootIndex", "AXMathNumber", "3");
+  }
+);
+
+addAccessibleTask(
+  `<math>
+    <mfrac id="fraction">
+      <mi>a</mi>
+      <mi>b</mi>
+     </mfrac>
+  </math>`,
+  async (browser, accDoc) => {
+    let fraction = getNativeInterface(accDoc, "fraction");
+    is(
+      fraction.getAttributeValue("AXSubrole"),
+      "AXMathFraction",
+      "mfrac has correct subrole"
+    );
+    ok(fraction.attributeNames.includes("AXMathFractionNumerator"));
+    ok(fraction.attributeNames.includes("AXMathFractionDenominator"));
+    ok(fraction.attributeNames.includes("AXMathLineThickness"));
+
+    // Bug 1639745
+    todo_is(fraction.getAttributeValue("AXMathLineThickness"), 1);
+
+    testMathAttr(fraction, "AXMathFractionNumerator", "AXMathIdentifier", "a");
+    testMathAttr(
+      fraction,
+      "AXMathFractionDenominator",
+      "AXMathIdentifier",
+      "b"
+    );
+  }
+);
+
+addAccessibleTask(
+  `<math>
+  <msubsup id="subsup">
+    <mo>∫</mo>
+    <mn>0</mn>
+    <mn>1</mn>
+  </msubsup>
+  </math>`,
+  async (browser, accDoc) => {
+    let subsup = getNativeInterface(accDoc, "subsup");
+    is(
+      subsup.getAttributeValue("AXSubrole"),
+      "AXMathSubscriptSuperscript",
+      "msubsup has correct subrole"
+    );
+
+    testMathAttr(subsup, "AXMathSubscript", "AXMathNumber", "0");
+    testMathAttr(subsup, "AXMathSuperscript", "AXMathNumber", "1");
+    testMathAttr(subsup, "AXMathBase", "AXMathOperator", "∫");
+  }
+);
+
+addAccessibleTask(
+  `<math>
+  <munderover id="underover">
+    <mo>∫</mo>
+    <mn>0</mn>
+    <mi>∞</mi>
+  </munderover>
+  </math>`,
+  async (browser, accDoc) => {
+    let underover = getNativeInterface(accDoc, "underover");
+    is(
+      underover.getAttributeValue("AXSubrole"),
+      "AXMathUnderOver",
+      "munderover has correct subrole"
+    );
+
+    testMathAttr(underover, "AXMathUnder", "AXMathNumber", "0");
+    testMathAttr(underover, "AXMathOver", "AXMathIdentifier", "∞");
+    testMathAttr(underover, "AXMathBase", "AXMathOperator", "∫");
+  }
+);