summaryrefslogtreecommitdiffstats
path: root/accessible/tests/mochitest/name/markuprules.xml
blob: 7f64ada3452daee815ebdcad77c7d06cea942157 (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
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
<?xml version="1.0"?>

<!--
  This XML file is used to create sequence of accessible name tests. It consist
  of two sections. The first section 'ruledfn' declares name computation rules.
  The second section 'rulesample' defines markup samples we need to check name
  computation rules for.

  <ruledfn>
    <ruleset>
      <rule>

  Section 'ruledfn' contains 'ruleset' elements. Every 'ruleset' element is
  presented by 'rule' elements so that sequence of 'rule' elements gives the
  sequence of name computations rules. Every 'rule' element can be one of four
  types.

   * <rule attr='' type='string'/> used when name is equal to the value of
     attribute presented on the element.

     Example, 'aria-label' attribute. In this case 'rule' element has 'attr'
     attribute pointing to attribute name and 'type' attribute with 'string'
     value. For example, <rule attr="aria-label" type="string"/>.

   * <rule attr='' type='ref'/> used when name is calculated from elements that
     are pointed to by attribute value on the element.

     Example is 'aria-labelledby'. In this case 'rule' element has 'attr'
     attribute holding the sequence of IDs of elements used to compute the name,
     in addition the 'rule' element has 'type' attribute with 'ref' value.
     For example, <rule attr="aria-labelledby" type="ref"/>.

   * <rule elm='' elmattr=''/> used when name is calculated from another
     element. These attributes are used to find an element by tagname and
     attribute with value equaled to ID of the element. If 'elmattr' is missed
     then element from subtree with the given tagname is used.

     Example, html:label@for element, <rule elm="label" elmattr="for"/>.
     Example, html:caption element, <rule elm="caption"/>

   * <rule fromsubtree='true'/> used when name is computed from subtree.

     Example, html:button. In this case 'rule' element has 'fromsubtree'
     attribute with 'true' value.

  <rulesample>
    <markup ruleset=''>

  Section 'rulesample' provides set of markup samples ('markup' elements). Every
  'markup' element contains an element that accessible name will be computed for
  (let's call it test element). In addition the 'markup' element contains some
  other elements from native markup used in name calculation process for test
  element. Test element is pointed to by 'ref' attribute on 'markup' element.
  Also 'markup' element has 'ruleset' attribute to indicate ruleset for the test
  element.

  How does it work? Let's consider simple example:
  <ruledfn>
    <ruleset id="aria">
      <rule attr="aria-label" type="string"/>
      <rule attr="aria-labelledby" type="ref"/>
    </ruleset>
  </ruledfn>
  <rulesample>
    <markup ref="html:div" ruleset="aria">
      <html:span id="label" textequiv="test2">test2</html:span>
      <html:div aria-label="test1"
                aria-labelledby="label">it's a div</html:div>
    </markup>
  </rulesample>

  Initially 'markup' element holds markup for all rules specified by 'ruleset'
  attribute. This allows us to check if the sequence of name computation rules
  is correct. Here 'ruleset' element defines two rules. We get the first rule
  which means accesible name is computed from value of 'aria-label' attribute.
  Then we check accessible name for the test element and remove 'aria-label'
  attribute. After we get the second rule which means we should get IDs from
  'aria-labelledby' attribute and compose accessible name from values of
  'textequiv' attributes (that are supposed to give the desired name for each
  element that is being pointed to by aria-labelledby). Check accessible name
  and finish test.
-->

<rules xmlns:html="http://www.w3.org/1999/xhtml"
       xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">

  <ruledfn>

    <!-- bricks -->
    <ruleset id="ARIA">
      <rule attr="aria-labelledby" type="ref"/>
      <rule attr="aria-label" type="string"/>
    </ruleset>

    <ruleset id="HTMLControl:Head">
      <ruleset ref="ARIA"/>
      <rule elm="label" elmattr="for"/>
    </ruleset>

    <!-- general -->
    <ruleset id="HTMLControl">
      <ruleset ref="HTMLControl:Head"/>
      <rule fromsubtree="true"/>
      <rule attr="title" type="string"/>
    </ruleset>

    <ruleset id="HTMLElm">
      <ruleset ref="ARIA"/>
      <rule attr="title" type="string"/>
    </ruleset>

    <!-- specific -->
    <ruleset id="HTMLARIAGridCell">
      <ruleset ref="ARIA"/>
      <rule fromsubtree="true"/>
      <rule attr="title" type="string"/>
    </ruleset>

    <ruleset id="HTMLInputButton">
      <ruleset ref="HTMLControl:Head"/>
      <rule attr="value" type="string" explict-name="false" reordered="true"/>
      <rule attr="title" type="string"/>
    </ruleset>

    <ruleset id="HTMLInputSubmit" defaultName="Submit Query">
      <ruleset ref="HTMLControl:Head"/>
      <rule attr="value" type="string" explict-name="false" textchanged="true"/>
    </ruleset>

    <ruleset id="HTMLInputReset" defaultName="Reset">
      <ruleset ref="HTMLControl:Head"/>
      <rule attr="value" type="string" explict-name="false" textchanged="true"/>
    </ruleset>

    <ruleset id="HTMLInputImage">
      <ruleset ref="HTMLControl:Head"/>
      <rule attr="alt" type="string" recreated="true"/>
      <rule attr="value" type="string" recreated="true"/>
      <rule attr="title" type="string"/>
    </ruleset>

    <ruleset id="HTMLInputImageNoValidSrc" defaultName="Submit Query">
      <ruleset ref="HTMLControl:Head"/>
      <rule attr="alt" type="string" explict-name="false" recreated="true"/>
      <rule attr="value" type="string" explict-name="false" recreated="true"/>
    </ruleset>

    <ruleset id="HTMLOption">
      <ruleset ref="ARIA"/>
      <rule attr="label" type="string"/>
      <rule fromsubtree="true"/>
      <rule attr="title" type="string"/>
    </ruleset>

    <ruleset id="HTMLImg">
      <ruleset ref="ARIA"/>
      <rule attr="alt" type="string"/>
      <rule attr="title" type="string"/>
    </ruleset>

    <ruleset id="HTMLImgEmptyAlt">
      <ruleset ref="ARIA"/>
      <rule attr="title" type="string"/>
      <rule attr="alt" type="string"/>
    </ruleset>

    <ruleset id="HTMLTable">
      <ruleset ref="ARIA"/>
      <rule elm="caption"/>
      <rule attr="summary" type="string"/>
      <rule attr="title" type="string"/>
    </ruleset>
  </ruledfn>

  <rulesample>

    <markup id="HTMLButtonTest"
            ref="html:button" ruleset="HTMLControl">
      <html:span id="l1" textequiv="test2">test2</html:span>
      <html:span id="l2" textequiv="test3">test3</html:span>
      <html:label for="btn" textequiv="test4">test4</html:label>
      <html:button id="btn"
                   aria-label="test1"
                   aria-labelledby="l1 l2"
                   title="test5"
                   textequiv="press me">press me</html:button>
    </markup>

    <markup id="HTMLInputButtonTest"
            ref="html:input" ruleset="HTMLInputButton">
      <html:span id="l1" textequiv="test2">test2</html:span>
      <html:span id="l2" textequiv="test3">test3</html:span>
      <html:label for="btn" textequiv="test4">test4</html:label>
      <html:input id="btn"
                  type="button"
                  aria-label="test1"
                  aria-labelledby="l1 l2"
                  value="name from value"
                  alt="no name from al"
                  src="no name from src"
                  data="no name from data"
                  title="name from title"/>
    </markup>

    <markup id="HTMLInputSubmitTest"
            ref="html:input" ruleset="HTMLInputSubmit">
      <html:span id="l1" textequiv="test2">test2</html:span>
      <html:span id="l2" textequiv="test3">test3</html:span>
      <html:label for="btn-submit" textequiv="test4">test4</html:label>
      <html:input id="btn-submit"
                  type="submit"
                  aria-label="test1"
                  aria-labelledby="l1 l2"
                  value="name from value"
                  alt="no name from atl"
                  src="no name from src"
                  data="no name from data"
                  title="no name from title"/>
    </markup>

    <markup id="HTMLInputResetTest"
            ref="html:input" ruleset="HTMLInputReset">
      <html:span id="l1" textequiv="test2">test2</html:span>
      <html:span id="l2" textequiv="test3">test3</html:span>
      <html:label for="btn-reset" textequiv="test4">test4</html:label>
      <html:input id="btn-reset"
                  type="reset"
                  aria-label="test1"
                  aria-labelledby="l1 l2"
                  value="name from value"
                  alt="no name from alt"
                  src="no name from src"
                  data="no name from data"
                  title="no name from title"/>
    </markup>

    <markup id="HTMLInputImageTest"
            ref="html:input" ruleset="HTMLInputImage">
      <html:span id="l1" textequiv="test2">test2</html:span>
      <html:span id="l2" textequiv="test3">test3</html:span>
      <html:label for="btn-image" textequiv="test4">test4</html:label>
      <html:input id="btn-image"
                  type="image"
                  aria-label="test1"
                  aria-labelledby="l1 l2"
                  alt="name from alt"
                  value="name from value"
                  src="../moz.png"
                  data="no name from data"
                  title="name from title"/>
    </markup>

    <markup id="HTMLInputImageNoValidSrcTest"
            ref="html:input" ruleset="HTMLInputImageNoValidSrc">
      <html:span id="l1" textequiv="test2">test2</html:span>
      <html:span id="l2" textequiv="test3">test3</html:span>
      <html:label for="btn-image" textequiv="test4">test4</html:label>
      <html:input id="btn-image"
                  type="image"
                  aria-label="test1"
                  aria-labelledby="l1 l2"
                  alt="name from alt"
                  value="name from value"
                  data="no name from data"
                  title="no name from title"/>
    </markup>

    <markup id="HTMLOptionTest"
            ref="html:select/html:option[1]" ruleset="HTMLOption">
      <html:span id="l1" textequiv="test2">test2</html:span>
      <html:span id="l2" textequiv="test3">test3</html:span>
      <html:select>
        <html:option id="opt"
                     aria-label="test1"
                     aria-labelledby="l1 l2"
                     label="test4"
                     title="test5"
                     textequiv="option1">option1</html:option>
        <html:option>option2</html:option>
      </html:select>
    </markup>

    <markup id="HTMLImageTest"
            ref="html:img" ruleset="HTMLImg">
      <html:span id="l1" textequiv="test2">test2</html:span>
      <html:span id="l2" textequiv="test3">test3</html:span>
      <html:img id="img"
                aria-label="Logo of Mozilla"
                aria-labelledby="l1 l2"
                alt="Mozilla logo"
                title="This is a logo"
                src="../moz.png"/>
    </markup>

    <markup id="HTMLImageEmptyAltTest"
            ref="html:img" ruleset="HTMLImgEmptyAlt">
      <html:span id="l1" textequiv="test2">test2</html:span>
      <html:span id="l2" textequiv="test3">test3</html:span>
      <html:img id="imgemptyalt"
                 aria-label="Logo of Mozilla"
                 aria-labelledby="l1 l2"
                 title="This is a logo"
                 alt=""
                 src="../moz.png"/>
    </markup>

    <markup id="HTMLTdTest"
            ref="html:table/html:tr/html:td" ruleset="HTMLElm">
      <html:span id="l1" textequiv="test2">test2</html:span>
      <html:span id="l2" textequiv="test3">test3</html:span>
      <html:label for="tc" textequiv="test4">test4</html:label>
      <html:table>
        <html:tr>
          <html:td id="tc"
                   aria-label="test1"
                   aria-labelledby="l1 l2"
                   title="test5">
            <html:p>This is a paragraph</html:p>
            <html:a href="#">This is a link</html:a>
            <html:ul>
              <html:li>This is a list</html:li>
            </html:ul>
          </html:td>
        </html:tr>
      </html:table>
    </markup>

    <markup id="HTMLTdARIAGridCellTest"
            ref="html:table/html:tr/html:td" ruleset="HTMLARIAGridCell">
      <html:span id="l1" textequiv="test2">test2</html:span>
      <html:span id="l2" textequiv="test3">test3</html:span>
      <html:label for="gc" textequiv="test4">test4</html:label>
      <html:table>
        <html:tr>
          <html:td id="gc"
                   role="gridcell"
                   aria-label="test1"
                   aria-labelledby="l1 l2"
                   textequiv="This is a paragraph This is a link • Listitem1 • Listitem2"
                   title="This is a paragraph This is a link This is a list">
            <html:p>This is a paragraph</html:p>
            <html:a href="#">This is a link</html:a>
            <html:ul>
              <html:li>Listitem1</html:li>
              <html:li>Listitem2</html:li>
            </html:ul>
          </html:td>
        </html:tr>
      </html:table>
    </markup>

    <markup id="HTMLTableTest"
            ref="html:table" ruleset="HTMLTable">
      <html:span id="l1" textequiv="lby_tst6_1">lby_tst6_1</html:span>
      <html:span id="l2" textequiv="lby_tst6_2">lby_tst6_2</html:span>
      <html:label for="t" textequiv="label_tst6">label_tst6</html:label>
      <!-- layout frame are recreated due to varous reasons, here's text frame
          placed after caption frame triggres table frame recreation when
          caption element is removed from DOM; get rid text node after caption
          node to make the test working -->
      <html:table id="t" aria-label="arialabel_tst6"
                  aria-labelledby="l1 l2"
                  summary="summary_tst6"
                  title="title_tst6">
        <html:caption textequiv="caption_tst6">caption_tst6</html:caption><html:tr>
          <html:td>cell1</html:td>
          <html:td>cell2</html:td>
        </html:tr>
      </html:table>
    </markup>

  </rulesample>
</rules>