1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/accessible/tests/mochitest/name/test_general.xul Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,367 @@ 1.4 +<?xml version="1.0"?> 1.5 +<?xml-stylesheet href="chrome://global/skin" type="text/css"?> 1.6 +<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" 1.7 + type="text/css"?> 1.8 +<?xml-stylesheet href="general.css" 1.9 + type="text/css"?> 1.10 + 1.11 + 1.12 +<window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" 1.13 + title="Accessibility Name Calculating Test."> 1.14 + 1.15 + <script type="application/javascript" 1.16 + src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js" /> 1.17 + 1.18 + <script type="application/javascript" 1.19 + src="../common.js"></script> 1.20 + <script type="application/javascript" 1.21 + src="../role.js"></script> 1.22 + <script type="application/javascript" 1.23 + src="../name.js"></script> 1.24 + 1.25 + <script type="application/javascript"> 1.26 + <![CDATA[ 1.27 + function doTest() 1.28 + { 1.29 + // aria-label 1.30 + 1.31 + // Simple label provided via ARIA 1.32 + testName("btn_simple_aria_label", "I am a button"); 1.33 + 1.34 + // aria-label and aria-labelledby, expect aria-labelledby 1.35 + testName("btn_both_aria_labels", "text I am a button, two"); 1.36 + 1.37 + ////////////////////////////////////////////////////////////////////////// 1.38 + // aria-labelledby 1.39 + 1.40 + // Single relation. The value of 'aria-labelledby' contains the ID of 1.41 + // an element. Gets the name from text node of that element. 1.42 + testName("btn_labelledby_text", "text"); 1.43 + 1.44 + // Multiple relations. The value of 'aria-labelledby' contains the IDs 1.45 + // of elements. Gets the name from text nodes of those elements. 1.46 + testName("btn_labelledby_texts", "text1 text2"); 1.47 + 1.48 + // Trick cases. Self and recursive referencing. 1.49 + testName("rememberHistoryDays", "Remember 3 days"); 1.50 + testName("historyDays", "Remember 3 days"); 1.51 + testName("rememberAfter", null); // XUL labels doesn't allow name from subtree 1.52 + 1.53 + // Anonymous content (see name.xbl#third) 1.54 + var anonBtn = getAccessible("labelledby_box_anon").lastChild; 1.55 + testName(anonBtn, "It's a cool button"); 1.56 + 1.57 + ////////////////////////////////////////////////////////////////////////// 1.58 + // Name from subtree (single relation labelled_by). 1.59 + 1.60 + // Gets the name from text nodes contained by nested elements. 1.61 + testName("btn_labelledby_mixed", "nomore text"); 1.62 + 1.63 + // Gets the name from text nodes and selected item of menulist 1.64 + // (other items are ignored). 1.65 + testName("btn_labelledby_mixed_menulist", 1.66 + "nomore text selected item more text"); 1.67 + 1.68 + // Gets the name from text nodes contained by nested elements, ignores 1.69 + // hidden elements (bug 443081). 1.70 + testName("btn_labelledby_mixed_hidden_child", "nomore text2"); 1.71 + 1.72 + // Gets the name from hidden text nodes contained by nested elements, 1.73 + // (label element is hidden entirely), (bug 443081) 1.74 + testName("btn_labelledby_mixed_hidden", "lala more hidden text"); 1.75 + 1.76 + 1.77 + ////////////////////////////////////////////////////////////////////////// 1.78 + // Name for nsIDOMXULLabeledControlElement. 1.79 + 1.80 + // Gets the name from @label attribute. 1.81 + testName("btn_nsIDOMXULLabeledControlElement", "labeled element"); 1.82 + 1.83 + 1.84 + ////////////////////////////////////////////////////////////////////////// 1.85 + // Name for nsIDOMXULSelectControlItemElement. 1.86 + 1.87 + // Gets the name from @label attribute. 1.88 + testName("li_nsIDOMXULSelectControlItemElement", "select control item"); 1.89 + 1.90 + 1.91 + ////////////////////////////////////////////////////////////////////////// 1.92 + // Name if the XUL element doesn't implement nsIDOMXULSelectControlElement 1.93 + // and has @label attribute. 1.94 + 1.95 + testName("box_not_nsIDOMXULSelectControlElement", "box"); 1.96 + 1.97 + 1.98 + ////////////////////////////////////////////////////////////////////////// 1.99 + // Name from the label element. 1.100 + 1.101 + // The label and button are placed on 2nd level relative common parent. 1.102 + testName("btn_label_1", "label1"); 1.103 + 1.104 + // The label is on 1st, the button is on 5th level relative common parent. 1.105 + testName("btn_label_2", "label2"); 1.106 + 1.107 + // The label and button are siblings. 1.108 + testName("btn_label_3", "label3"); 1.109 + 1.110 + // Multiple labels for single button: XUL button takes the last one. 1.111 + testName("btn_label_4", "label5"); 1.112 + 1.113 + 1.114 + ////////////////////////////////////////////////////////////////////////// 1.115 + // Name from the label element in anonymous content (see bug 362365). 1.116 + 1.117 + // Get the name from anonymous label element for anonymous textbox 1.118 + // (@anonid is used). 1.119 + var ID = "box_label_anon1"; 1.120 + var box1Acc = testName(ID, null); 1.121 + if (box1Acc) { 1.122 + var textboxAcc = box1Acc.firstChild; 1.123 + is(textboxAcc.name, "Label", 1.124 + "Wrong label for anonymous textbox of " + ID); 1.125 + } 1.126 + 1.127 + // Get the name from anonymous label element for anonymous textbox 1.128 + // (@anonid is used). Nested bindings. 1.129 + ID = "box_label_anon2"; 1.130 + var box2Acc = testName(ID, null); 1.131 + if (box2Acc) { 1.132 + var textboxAcc = box2Acc.firstChild; 1.133 + is(textboxAcc.name, "Label", 1.134 + "Wrong label for anonymous textbox of " + ID); 1.135 + 1.136 + var topTextboxAcc = box2Acc.lastChild; 1.137 + is(topTextboxAcc.name, "Top textbox", 1.138 + "Wrong label for anonymous textbox of " + ID); 1.139 + } 1.140 + 1.141 + 1.142 + ////////////////////////////////////////////////////////////////////////// 1.143 + // tooltiptext (if nothing above isn't presented then tooltiptext is used) 1.144 + testName("box_tooltiptext", "tooltiptext label"); 1.145 + 1.146 + 1.147 + ////////////////////////////////////////////////////////////////////////// 1.148 + // Name from the @title attribute of <toolbaritem/> (original bug 237249). 1.149 + 1.150 + // Direct child of toolbaritem. 1.151 + var textboxAcc = testName("toolbaritem_textbox", "ooospspss"); 1.152 + 1.153 + // Element from anonymous content of direct child of toolbaritem. 1.154 + var entryAcc = textboxAcc.firstChild; 1.155 + testRole(entryAcc, ROLE_ENTRY); 1.156 + is(entryAcc.name, "ooospspss", 1.157 + "Wrong name for text entry of autocomplete textbox 'toolbaritem_textbox'."); 1.158 + 1.159 + // Child from subtree of toolbaritem. 1.160 + testName("toolbaritem_hboxbutton", "ooospspss"); 1.161 + 1.162 + 1.163 + ////////////////////////////////////////////////////////////////////////// 1.164 + // Name from children 1.165 + 1.166 + // ARIA role button is presented allowing the name calculation from 1.167 + // children. 1.168 + testName("box_children", "14"); 1.169 + 1.170 + // ARIA role option is presented allowing the name calculation from 1.171 + // the visible children (bug 443081) 1.172 + testName("lb_opt1_children_hidden", "i am visible"); 1.173 + 1.174 + 1.175 + ////////////////////////////////////////////////////////////////////////// 1.176 + // Name from aria-labelledby: menuitem label+ listitem label 1.177 + testName("li_labelledby", "Show an Alert The moment the event starts"); 1.178 + 1.179 + SimpleTest.finish(); 1.180 + } 1.181 + 1.182 + SimpleTest.waitForExplicitFinish(); 1.183 + addA11yLoadEvent(doTest); 1.184 + ]]> 1.185 + </script> 1.186 + 1.187 + <hbox flex="1" style="overflow: auto;"> 1.188 + 1.189 + <body xmlns="http://www.w3.org/1999/xhtml"> 1.190 + <a target="_blank" 1.191 + href="https://bugzilla.mozilla.org/show_bug.cgi?id=444279" 1.192 + title="mochitest for accessible name calculating"> 1.193 + Mozilla Bug 444279 1.194 + </a> 1.195 + <a target="_blank" 1.196 + href="https://bugzilla.mozilla.org/show_bug.cgi?id=441991" 1.197 + title="nsXULListitemAccessible::GetName prefers label \ 1.198 + attribute over aria-labelledby and doesn't allow recursion"> 1.199 + Mozilla Bug 441991 1.200 + </a> 1.201 + <p id="display"></p> 1.202 + <div id="content" style="display: none"> 1.203 + </div> 1.204 + <pre id="test"> 1.205 + </pre> 1.206 + </body> 1.207 + 1.208 + <vbox flex="1"> 1.209 + 1.210 + <!-- aria-label, simple label --> 1.211 + <button id="btn_simple_aria_label" aria-label="I am a button"/> 1.212 + 1.213 + <!-- aria-label plus aria-labelledby --> 1.214 + <button id="btn_both_aria_labels" aria-label="I am a button, two" 1.215 + aria-labelledby="labelledby_text btn_both_aria_labels"/> 1.216 + 1.217 + <!-- aria-labelledby, single relation --> 1.218 + <description id="labelledby_text">text</description> 1.219 + <button id="btn_labelledby_text" 1.220 + aria-labelledby="labelledby_text"/> 1.221 + 1.222 + <!-- aria-labelledby, multiple relations --> 1.223 + <description id="labelledby_text1">text1</description> 1.224 + <description id="labelledby_text2">text2</description> 1.225 + <button id="btn_labelledby_texts" 1.226 + aria-labelledby="labelledby_text1 labelledby_text2"/> 1.227 + 1.228 + <!-- aria-labelledby, multiple relations --> 1.229 + <box class="third" id="labelledby_box_anon" role="group" /> 1.230 + 1.231 + <!-- trick aria-labelledby --> 1.232 + <checkbox id="rememberHistoryDays" 1.233 + label="Remember " 1.234 + aria-labelledby="rememberHistoryDays historyDays rememberAfter"/> 1.235 + <textbox id="historyDays" type="number" size="3" value="3" 1.236 + aria-labelledby="rememberHistoryDays historyDays rememberAfter"/> 1.237 + <label id="rememberAfter">days</label> 1.238 + 1.239 + <!-- the name from subtree, mixed content --> 1.240 + <description id="labelledby_mixed"> 1.241 + no<description>more text</description> 1.242 + </description> 1.243 + <button id="btn_labelledby_mixed" 1.244 + aria-labelledby="labelledby_mixed"/> 1.245 + 1.246 + <!-- the name from subtree, mixed/hidden content --> 1.247 + <description id="labelledby_mixed_hidden_child">no<description>more <description hidden="true">hidden</description>text2</description></description> 1.248 + <button id="btn_labelledby_mixed_hidden_child" 1.249 + aria-labelledby="labelledby_mixed_hidden_child"/> 1.250 + 1.251 + <!-- the name from subtree, mixed/completely hidden content --> 1.252 + <description id="labelledby_mixed_hidden" 1.253 + hidden="true">lala <description>more hidden </description>text</description> 1.254 + <button id="btn_labelledby_mixed_hidden" 1.255 + aria-labelledby="labelledby_mixed_hidden"/> 1.256 + <br/> 1.257 + 1.258 + <!-- the name from subtree, mixed content, ignore items of menulist --> 1.259 + <description id="labelledby_mixed_menulist"> 1.260 + no<description>more text</description> 1.261 + <menulist> 1.262 + <menupopup> 1.263 + <menuitem label="selected item"/> 1.264 + <menuitem label="item"/> 1.265 + </menupopup> 1.266 + </menulist> 1.267 + more text 1.268 + </description> 1.269 + <button id="btn_labelledby_mixed_menulist" 1.270 + aria-labelledby="labelledby_mixed_menulist"/> 1.271 + 1.272 + <!-- nsIDOMXULLabeledControlElement --> 1.273 + <button id="btn_nsIDOMXULLabeledControlElement" 1.274 + label="labeled element"/> 1.275 + 1.276 + <!-- nsIDOMXULSelectControlItemElement --> 1.277 + <listbox> 1.278 + <listitem id="li_nsIDOMXULSelectControlItemElement" 1.279 + label="select control item"/> 1.280 + </listbox> 1.281 + 1.282 + <!-- not nsIDOMXULSelectControlElement --> 1.283 + <box id="box_not_nsIDOMXULSelectControlElement" role="group" label="box"/> 1.284 + 1.285 + <!-- label element --> 1.286 + <hbox> 1.287 + <box> 1.288 + <label control="btn_label_1">label1</label> 1.289 + </box> 1.290 + <label control="btn_label_2">label2</label> 1.291 + <box> 1.292 + <button id="btn_label_1"/> 1.293 + <box> 1.294 + <box> 1.295 + <box> 1.296 + <button id="btn_label_2"/> 1.297 + </box> 1.298 + </box> 1.299 + </box> 1.300 + </box> 1.301 + <label control="btn_label_3">label3</label> 1.302 + <button id="btn_label_3"/> 1.303 + 1.304 + <label control="btn_label_4">label4</label> 1.305 + <label control="btn_label_4">label5</label> 1.306 + <button id="btn_label_4"/> 1.307 + </hbox> 1.308 + 1.309 + <!-- label element, anonymous content --> 1.310 + <box id="box_label_anon1" 1.311 + class="first" 1.312 + role="group"/> 1.313 + 1.314 + <box id="box_label_anon2" 1.315 + class="second" 1.316 + role="group"/> 1.317 + 1.318 + <!-- tooltiptext --> 1.319 + <box id="box_tooltiptext" 1.320 + role="group" 1.321 + tooltiptext="tooltiptext label"/> 1.322 + 1.323 + <!-- the name from @title of toolbaritem --> 1.324 + <toolbar> 1.325 + <toolbaritem title="ooospspss"> 1.326 + <textbox id="toolbaritem_textbox" 1.327 + flex="1" 1.328 + type="autocomplete" 1.329 + enablehistory="true"> 1.330 + <hbox role="button" id="toolbaritem_hboxbutton"> 1.331 + <description value="button"/> 1.332 + </hbox> 1.333 + </textbox> 1.334 + </toolbaritem> 1.335 + </toolbar> 1.336 + 1.337 + <!-- name from children --> 1.338 + <box id="box_children" role="button">14</box> 1.339 + 1.340 + <!-- name from children, hidden children --> 1.341 + <vbox role="listbox" tabindex="0"> 1.342 + <hbox id="lb_opt1_children_hidden" role="option" tabindex="0"> 1.343 + <description>i am visible</description> 1.344 + <description style="display:none">i am hidden</description> 1.345 + </hbox> 1.346 + </vbox> 1.347 + 1.348 + <!-- bug 441991; create name from other menuitem label listitem's own label --> 1.349 + <hbox> 1.350 + <listbox> 1.351 + <listitem id="li_labelledby" 1.352 + label="The moment the event starts" 1.353 + aria-labelledby="menuitem-DISPLAY li_labelledby"/> 1.354 + </listbox> 1.355 + <menulist> 1.356 + <menupopup> 1.357 + <menuitem id="menuitem-DISPLAY" 1.358 + value="DISPLAY" 1.359 + label="Show an Alert"/> 1.360 + <menuitem id="menuitem-EMAIL" 1.361 + value="EMAIL" 1.362 + label="Send an E-mail"/> 1.363 + </menupopup> 1.364 + </menulist> 1.365 + </hbox> 1.366 + 1.367 + </vbox> <!-- close tests area --> 1.368 + </hbox> <!-- close main area --> 1.369 +</window> 1.370 +