summaryrefslogtreecommitdiffstats
path: root/accessible/tests/browser/mac/browser_mathml.js
blob: d4cf49981058df5fd5d3d948f3031a05ea2470ff (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
/* 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">
      <mn>2</mn>
    </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", "AXMathNumber", "2");
  }
);

addAccessibleTask(
  `<math>
    <mroot id="root">
      <mi>sin</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", "sin");
    testMathAttr(root, "AXMathRootIndex", "AXMathNumber", "3");
  }
);

addAccessibleTask(
  `<math>
    <mfrac id="fraction">
      <mn>2</mn>
      <mn>3</mn>
     </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", "AXMathNumber", "2");
    testMathAttr(fraction, "AXMathFractionDenominator", "AXMathNumber", "3");
  }
);

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", "∫");
  }
);