4 <title>nsIAccessible::name calculation
</title>
5 <link rel=
"stylesheet" type=
"text/css" href=
"chrome://mochikit/content/tests/SimpleTest/test.css" />
7 <script type=
"application/javascript"
8 src=
"chrome://mochikit/content/MochiKit/packed.js"></script>
9 <script type=
"application/javascript"
10 src=
"chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
11 <script type=
"application/javascript"
12 src=
"chrome://mochikit/content/a11y/accessible/common.js"></script>
13 <script type=
"application/javascript"
14 src=
"chrome://mochikit/content/a11y/accessible/nsIAccessible_name.js"></script>
16 <script type=
"application/javascript">
21 // Simple label provided via ARIA
22 testName(
"btn_simple_aria_label",
"I am a button");
24 // aria-label and aria-labelledby, expect aria-label
25 testName(
"btn_both_aria_labels",
"I am a button, two");
27 //////////////////////////////////////////////////////////////////////////
30 // Single relation. The value of 'aria-labelledby' contains the ID of
31 // an element. Gets the name from text node of that element.
32 testName(
"btn_labelledby_text",
"text");
34 // Multiple relations. The value of 'aria-labelledby' contains the IDs
35 // of elements. Gets the name from text nodes of those elements.
36 testName(
"btn_labelledby_texts",
"text1 text2");
39 //////////////////////////////////////////////////////////////////////////
40 // Name from subtree (single relation labelled_by).
42 // Gets the name from text nodes contained by nested elements
43 testName(
"btn_labelledby_mixed",
"nomore text");
45 // Gets the name from text nodes contained by nested elements, ignores
46 // hidden elements (bug
443081).
47 testName(
"btn_labelledby_mixed_hidden_child",
"nomore text2");
49 // Gets the name from hidden text nodes contained by nested elements,
50 // (label element is hidden entirely), (bug
443081).
51 testName(
"btn_labelledby_mixed_hidden",
"lala more hidden text");
53 // Gets the name from text nodes contained by nested elements having block
54 // representation (every text node value in the name should be devided by
56 testName(
"btn_labelledby_mixed_block",
"text more text");
58 // Gets the name from text nodes contained by html:td (every text node
59 // value in the name should be devided by spaces).
60 // XXX: this case is rather a feature than strong wanted behaviour.
61 testName(
"btn_labelledby_mixed_table",
"text space text");
63 // Gets the name from image accessible.
64 testName(
"btn_labelledby_mixed_img",
"text image");
66 // Gets the name from input accessibles
67 // Note: if input have label elements then the name isn't calculated
69 testName(
"btn_labelledby_mixed_input",
70 "input button Submit Query Reset input image");
72 // Gets the name from the title of object element.
73 testName(
"btn_labelledby_mixed_object",
"object");
75 // Gets the name from text nodes. Element br adds space between them.
76 testName(
"btn_labelledby_mixed_br",
"text text");
79 //////////////////////////////////////////////////////////////////////////
82 // The label element contains the button. The name is calculated from
84 // Note: the name contains the content of the button.
85 testName(
"btn_label_inside",
"text10text");
87 // The label element and the button are placed in the same form. Gets
88 // the name from the label subtree.
89 testName(
"btn_label_inform",
"in form");
91 // The label element is placed outside of form where the button is.
92 // Do not take into account the label.
93 testName(
"btn_label_outform",
"12");
95 // The label element and the button are in the same document. Gets the
96 // name from the label subtree.
97 testName(
"btn_label_indocument",
"in document");
100 //////////////////////////////////////////////////////////////////////////
101 // name from children
103 // ARIA role button is presented allowing the name calculation from
105 testName(
"btn_children",
"14");
107 // ARIA role option is presented allowing the name calculation from
108 // visible children (bug
443081).
109 testName(
"lb_opt1_children_hidden",
"i am visible");
112 //////////////////////////////////////////////////////////////////////////
115 // If nothing is left. Let's try title attribute.
116 testName(
"btn_title",
"title");
118 //////////////////////////////////////////////////////////////////////////
121 // textarea's name should have the value, which initially is specified by
123 testName(
"textareawithchild",
"Story: Foo");
125 // new textarea name should reflect the value change.
126 var elem = document.getElementById(
"textareawithchild");
129 testName(
"textareawithchild",
"Story: Bar");
131 /////////////////////////////////////////////////////////////////////////
132 // label with nested combobox
134 testName(
"comboinmiddle",
"Subscribe to ATOM feed.");
139 SimpleTest.waitForExplicitFinish();
140 addLoadEvent(doTest);
148 href=
"https://bugzilla.mozilla.org/show_bug.cgi?id=444279"
149 title=
"mochitest for accessible name calculating">
153 <div id=
"content" style=
"display: none"></div>
157 <!-- aria-label, simple label -->
158 <span id=
"btn_simple_aria_label" role=
"button" aria-label=
"I am a button"/>
160 <!-- aria-label plus aria-labelledby -->
161 <span id=
"btn_both_aria_labels" role=
"button" aria-label=
"I am a button, two"
162 aria-labelledby=
"labelledby_text"/>
165 <!-- aria-labelledby, single relation -->
166 <span id=
"labelledby_text">text
</span>
167 <button id=
"btn_labelledby_text"
168 aria-labelledby=
"labelledby_text">1</button>
171 <!-- aria-labelledby, multiple relations -->
172 <span id=
"labelledby_text1">text1
</span>
173 <span id=
"labelledby_text2">text2
</span>
174 <button id=
"btn_labelledby_texts"
175 aria-labelledby=
"labelledby_text1 labelledby_text2">2</button>
178 <!-- the name from subtree, mixed content -->
179 <span id=
"labelledby_mixed">no
<span>more text
</span></span>
180 <button id=
"btn_labelledby_mixed"
181 aria-labelledby=
"labelledby_mixed">3</button>
184 <!-- the name from subtree, mixed/hidden content -->
185 <span id=
"labelledby_mixed_hidden_child">
187 <span style=
"display: none;">hidden
</span>
189 <span style=
"visibility: hidden">hidden2
</span>
192 <button id=
"btn_labelledby_mixed_hidden_child"
193 aria-labelledby=
"labelledby_mixed_hidden_child">3.1</button>
196 <!-- the name from subtree, mixed/completely hidden content -->
197 <span id=
"labelledby_mixed_hidden"
198 style=
"display: none;">lala
<span>more hidden
</span>text
</span></span>
199 <button id=
"btn_labelledby_mixed_hidden"
200 aria-labelledby=
"labelledby_mixed_hidden">3.2</button>
203 <!-- the name from subtree, mixed content, block structure -->
204 <div id=
"labelledby_mixed_block"><div>text
</div>more text
</div></div>
205 <button id=
"btn_labelledby_mixed_block"
206 aria-labelledby=
"labelledby_mixed_block">4</button>
209 <!-- the name from subtree, mixed content, table structure -->
211 <td id=
"labelledby_mixed_table">text
<span>space
</span>text
</td>
213 <button id=
"btn_labelledby_mixed_table"
214 aria-labelledby=
"labelledby_mixed_table">5</button>
217 <!-- the name from subtree, child img -->
218 <span id=
"labelledby_mixed_img">text
<img alt=
"image"/></span>
219 <button id=
"btn_labelledby_mixed_img"
220 aria-labelledby=
"labelledby_mixed_img">6</button>
223 <!-- the name from subtree, child inputs -->
224 <span id=
"labelledby_mixed_input">
225 <input type=
"button" id=
"input_button" title=
"input button"/>
226 <input type=
"submit" id=
"input_submit"/>
227 <input type=
"reset" id=
"input_reset"/>
228 <input type=
"image" id=
"input_image" title=
"input image"/>
230 <button id=
"btn_labelledby_mixed_input"
231 aria-labelledby=
"labelledby_mixed_input">7</button>
234 <!-- the name from subtree, child object -->
235 <span id=
"labelledby_mixed_object">
236 <object data=
"about:blank" title=
"object"></object>
238 <button id=
"btn_labelledby_mixed_object"
239 aria-labelledby=
"labelledby_mixed_object">8</button>
242 <!-- the name from subtree, child br -->
243 <span id=
"labelledby_mixed_br">text
<br/>text
</span>
244 <button id=
"btn_labelledby_mixed_br"
245 aria-labelledby=
"labelledby_mixed_br">9</button>
248 <!-- label element, label contains the button -->
249 <label>text
<button id=
"btn_label_inside">10</button>text
</label>
252 <!-- label element, label and the button are in the same form -->
254 <label for=
"btn_label_inform">in form
</label>
255 <button id=
"btn_label_inform">11</button>
258 <!-- label element, label is outside of the form of the button -->
259 <label for=
"btn_label_outform">out form
</label>
261 <button id=
"btn_label_outform">12</button>
264 <!-- label element, label and the button are in the same document -->
265 <label for=
"btn_label_indocument">in document
</label>
266 <button id=
"btn_label_indocument">13</button>
268 <!-- name from children -->
269 <span id=
"btn_children" role=
"button">14</span>
271 <!-- name from children, hidden children -->
272 <div role=
"listbox" tabindex=
"0">
273 <div id=
"lb_opt1_children_hidden" role=
"option" tabindex=
"0">
274 <span>i am visible
</span>
275 <span style=
"display:none">i am hidden
</span>
279 <!-- name from title attribute -->
280 <span id=
"btn_title" role=
"group" title=
"title">15</span>
282 <!-- A textarea nested in a label with a text child (bug #453371). -->
285 <textarea id=
"textareawithchild" name=
"name">Foo
</textarea>
289 <!-- A label with a nested control in the middle -->
291 <label id=
"comboinmiddle">
293 <select id=
"combo3" name=
"occupation">
294 <option>ATOM
</option>