Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
michael@0 | 1 | <?xml version="1.0"?> |
michael@0 | 2 | <?xml-stylesheet href="chrome://global/skin" type="text/css"?> |
michael@0 | 3 | <?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" |
michael@0 | 4 | type="text/css"?> |
michael@0 | 5 | <?xml-stylesheet href="general.css" |
michael@0 | 6 | type="text/css"?> |
michael@0 | 7 | |
michael@0 | 8 | |
michael@0 | 9 | <window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" |
michael@0 | 10 | title="Accessibility Name Calculating Test."> |
michael@0 | 11 | |
michael@0 | 12 | <script type="application/javascript" |
michael@0 | 13 | src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js" /> |
michael@0 | 14 | |
michael@0 | 15 | <script type="application/javascript" |
michael@0 | 16 | src="../common.js"></script> |
michael@0 | 17 | <script type="application/javascript" |
michael@0 | 18 | src="../role.js"></script> |
michael@0 | 19 | <script type="application/javascript" |
michael@0 | 20 | src="../name.js"></script> |
michael@0 | 21 | |
michael@0 | 22 | <script type="application/javascript"> |
michael@0 | 23 | <![CDATA[ |
michael@0 | 24 | function doTest() |
michael@0 | 25 | { |
michael@0 | 26 | // aria-label |
michael@0 | 27 | |
michael@0 | 28 | // Simple label provided via ARIA |
michael@0 | 29 | testName("btn_simple_aria_label", "I am a button"); |
michael@0 | 30 | |
michael@0 | 31 | // aria-label and aria-labelledby, expect aria-labelledby |
michael@0 | 32 | testName("btn_both_aria_labels", "text I am a button, two"); |
michael@0 | 33 | |
michael@0 | 34 | ////////////////////////////////////////////////////////////////////////// |
michael@0 | 35 | // aria-labelledby |
michael@0 | 36 | |
michael@0 | 37 | // Single relation. The value of 'aria-labelledby' contains the ID of |
michael@0 | 38 | // an element. Gets the name from text node of that element. |
michael@0 | 39 | testName("btn_labelledby_text", "text"); |
michael@0 | 40 | |
michael@0 | 41 | // Multiple relations. The value of 'aria-labelledby' contains the IDs |
michael@0 | 42 | // of elements. Gets the name from text nodes of those elements. |
michael@0 | 43 | testName("btn_labelledby_texts", "text1 text2"); |
michael@0 | 44 | |
michael@0 | 45 | // Trick cases. Self and recursive referencing. |
michael@0 | 46 | testName("rememberHistoryDays", "Remember 3 days"); |
michael@0 | 47 | testName("historyDays", "Remember 3 days"); |
michael@0 | 48 | testName("rememberAfter", null); // XUL labels doesn't allow name from subtree |
michael@0 | 49 | |
michael@0 | 50 | // Anonymous content (see name.xbl#third) |
michael@0 | 51 | var anonBtn = getAccessible("labelledby_box_anon").lastChild; |
michael@0 | 52 | testName(anonBtn, "It's a cool button"); |
michael@0 | 53 | |
michael@0 | 54 | ////////////////////////////////////////////////////////////////////////// |
michael@0 | 55 | // Name from subtree (single relation labelled_by). |
michael@0 | 56 | |
michael@0 | 57 | // Gets the name from text nodes contained by nested elements. |
michael@0 | 58 | testName("btn_labelledby_mixed", "nomore text"); |
michael@0 | 59 | |
michael@0 | 60 | // Gets the name from text nodes and selected item of menulist |
michael@0 | 61 | // (other items are ignored). |
michael@0 | 62 | testName("btn_labelledby_mixed_menulist", |
michael@0 | 63 | "nomore text selected item more text"); |
michael@0 | 64 | |
michael@0 | 65 | // Gets the name from text nodes contained by nested elements, ignores |
michael@0 | 66 | // hidden elements (bug 443081). |
michael@0 | 67 | testName("btn_labelledby_mixed_hidden_child", "nomore text2"); |
michael@0 | 68 | |
michael@0 | 69 | // Gets the name from hidden text nodes contained by nested elements, |
michael@0 | 70 | // (label element is hidden entirely), (bug 443081) |
michael@0 | 71 | testName("btn_labelledby_mixed_hidden", "lala more hidden text"); |
michael@0 | 72 | |
michael@0 | 73 | |
michael@0 | 74 | ////////////////////////////////////////////////////////////////////////// |
michael@0 | 75 | // Name for nsIDOMXULLabeledControlElement. |
michael@0 | 76 | |
michael@0 | 77 | // Gets the name from @label attribute. |
michael@0 | 78 | testName("btn_nsIDOMXULLabeledControlElement", "labeled element"); |
michael@0 | 79 | |
michael@0 | 80 | |
michael@0 | 81 | ////////////////////////////////////////////////////////////////////////// |
michael@0 | 82 | // Name for nsIDOMXULSelectControlItemElement. |
michael@0 | 83 | |
michael@0 | 84 | // Gets the name from @label attribute. |
michael@0 | 85 | testName("li_nsIDOMXULSelectControlItemElement", "select control item"); |
michael@0 | 86 | |
michael@0 | 87 | |
michael@0 | 88 | ////////////////////////////////////////////////////////////////////////// |
michael@0 | 89 | // Name if the XUL element doesn't implement nsIDOMXULSelectControlElement |
michael@0 | 90 | // and has @label attribute. |
michael@0 | 91 | |
michael@0 | 92 | testName("box_not_nsIDOMXULSelectControlElement", "box"); |
michael@0 | 93 | |
michael@0 | 94 | |
michael@0 | 95 | ////////////////////////////////////////////////////////////////////////// |
michael@0 | 96 | // Name from the label element. |
michael@0 | 97 | |
michael@0 | 98 | // The label and button are placed on 2nd level relative common parent. |
michael@0 | 99 | testName("btn_label_1", "label1"); |
michael@0 | 100 | |
michael@0 | 101 | // The label is on 1st, the button is on 5th level relative common parent. |
michael@0 | 102 | testName("btn_label_2", "label2"); |
michael@0 | 103 | |
michael@0 | 104 | // The label and button are siblings. |
michael@0 | 105 | testName("btn_label_3", "label3"); |
michael@0 | 106 | |
michael@0 | 107 | // Multiple labels for single button: XUL button takes the last one. |
michael@0 | 108 | testName("btn_label_4", "label5"); |
michael@0 | 109 | |
michael@0 | 110 | |
michael@0 | 111 | ////////////////////////////////////////////////////////////////////////// |
michael@0 | 112 | // Name from the label element in anonymous content (see bug 362365). |
michael@0 | 113 | |
michael@0 | 114 | // Get the name from anonymous label element for anonymous textbox |
michael@0 | 115 | // (@anonid is used). |
michael@0 | 116 | var ID = "box_label_anon1"; |
michael@0 | 117 | var box1Acc = testName(ID, null); |
michael@0 | 118 | if (box1Acc) { |
michael@0 | 119 | var textboxAcc = box1Acc.firstChild; |
michael@0 | 120 | is(textboxAcc.name, "Label", |
michael@0 | 121 | "Wrong label for anonymous textbox of " + ID); |
michael@0 | 122 | } |
michael@0 | 123 | |
michael@0 | 124 | // Get the name from anonymous label element for anonymous textbox |
michael@0 | 125 | // (@anonid is used). Nested bindings. |
michael@0 | 126 | ID = "box_label_anon2"; |
michael@0 | 127 | var box2Acc = testName(ID, null); |
michael@0 | 128 | if (box2Acc) { |
michael@0 | 129 | var textboxAcc = box2Acc.firstChild; |
michael@0 | 130 | is(textboxAcc.name, "Label", |
michael@0 | 131 | "Wrong label for anonymous textbox of " + ID); |
michael@0 | 132 | |
michael@0 | 133 | var topTextboxAcc = box2Acc.lastChild; |
michael@0 | 134 | is(topTextboxAcc.name, "Top textbox", |
michael@0 | 135 | "Wrong label for anonymous textbox of " + ID); |
michael@0 | 136 | } |
michael@0 | 137 | |
michael@0 | 138 | |
michael@0 | 139 | ////////////////////////////////////////////////////////////////////////// |
michael@0 | 140 | // tooltiptext (if nothing above isn't presented then tooltiptext is used) |
michael@0 | 141 | testName("box_tooltiptext", "tooltiptext label"); |
michael@0 | 142 | |
michael@0 | 143 | |
michael@0 | 144 | ////////////////////////////////////////////////////////////////////////// |
michael@0 | 145 | // Name from the @title attribute of <toolbaritem/> (original bug 237249). |
michael@0 | 146 | |
michael@0 | 147 | // Direct child of toolbaritem. |
michael@0 | 148 | var textboxAcc = testName("toolbaritem_textbox", "ooospspss"); |
michael@0 | 149 | |
michael@0 | 150 | // Element from anonymous content of direct child of toolbaritem. |
michael@0 | 151 | var entryAcc = textboxAcc.firstChild; |
michael@0 | 152 | testRole(entryAcc, ROLE_ENTRY); |
michael@0 | 153 | is(entryAcc.name, "ooospspss", |
michael@0 | 154 | "Wrong name for text entry of autocomplete textbox 'toolbaritem_textbox'."); |
michael@0 | 155 | |
michael@0 | 156 | // Child from subtree of toolbaritem. |
michael@0 | 157 | testName("toolbaritem_hboxbutton", "ooospspss"); |
michael@0 | 158 | |
michael@0 | 159 | |
michael@0 | 160 | ////////////////////////////////////////////////////////////////////////// |
michael@0 | 161 | // Name from children |
michael@0 | 162 | |
michael@0 | 163 | // ARIA role button is presented allowing the name calculation from |
michael@0 | 164 | // children. |
michael@0 | 165 | testName("box_children", "14"); |
michael@0 | 166 | |
michael@0 | 167 | // ARIA role option is presented allowing the name calculation from |
michael@0 | 168 | // the visible children (bug 443081) |
michael@0 | 169 | testName("lb_opt1_children_hidden", "i am visible"); |
michael@0 | 170 | |
michael@0 | 171 | |
michael@0 | 172 | ////////////////////////////////////////////////////////////////////////// |
michael@0 | 173 | // Name from aria-labelledby: menuitem label+ listitem label |
michael@0 | 174 | testName("li_labelledby", "Show an Alert The moment the event starts"); |
michael@0 | 175 | |
michael@0 | 176 | SimpleTest.finish(); |
michael@0 | 177 | } |
michael@0 | 178 | |
michael@0 | 179 | SimpleTest.waitForExplicitFinish(); |
michael@0 | 180 | addA11yLoadEvent(doTest); |
michael@0 | 181 | ]]> |
michael@0 | 182 | </script> |
michael@0 | 183 | |
michael@0 | 184 | <hbox flex="1" style="overflow: auto;"> |
michael@0 | 185 | |
michael@0 | 186 | <body xmlns="http://www.w3.org/1999/xhtml"> |
michael@0 | 187 | <a target="_blank" |
michael@0 | 188 | href="https://bugzilla.mozilla.org/show_bug.cgi?id=444279" |
michael@0 | 189 | title="mochitest for accessible name calculating"> |
michael@0 | 190 | Mozilla Bug 444279 |
michael@0 | 191 | </a> |
michael@0 | 192 | <a target="_blank" |
michael@0 | 193 | href="https://bugzilla.mozilla.org/show_bug.cgi?id=441991" |
michael@0 | 194 | title="nsXULListitemAccessible::GetName prefers label \ |
michael@0 | 195 | attribute over aria-labelledby and doesn't allow recursion"> |
michael@0 | 196 | Mozilla Bug 441991 |
michael@0 | 197 | </a> |
michael@0 | 198 | <p id="display"></p> |
michael@0 | 199 | <div id="content" style="display: none"> |
michael@0 | 200 | </div> |
michael@0 | 201 | <pre id="test"> |
michael@0 | 202 | </pre> |
michael@0 | 203 | </body> |
michael@0 | 204 | |
michael@0 | 205 | <vbox flex="1"> |
michael@0 | 206 | |
michael@0 | 207 | <!-- aria-label, simple label --> |
michael@0 | 208 | <button id="btn_simple_aria_label" aria-label="I am a button"/> |
michael@0 | 209 | |
michael@0 | 210 | <!-- aria-label plus aria-labelledby --> |
michael@0 | 211 | <button id="btn_both_aria_labels" aria-label="I am a button, two" |
michael@0 | 212 | aria-labelledby="labelledby_text btn_both_aria_labels"/> |
michael@0 | 213 | |
michael@0 | 214 | <!-- aria-labelledby, single relation --> |
michael@0 | 215 | <description id="labelledby_text">text</description> |
michael@0 | 216 | <button id="btn_labelledby_text" |
michael@0 | 217 | aria-labelledby="labelledby_text"/> |
michael@0 | 218 | |
michael@0 | 219 | <!-- aria-labelledby, multiple relations --> |
michael@0 | 220 | <description id="labelledby_text1">text1</description> |
michael@0 | 221 | <description id="labelledby_text2">text2</description> |
michael@0 | 222 | <button id="btn_labelledby_texts" |
michael@0 | 223 | aria-labelledby="labelledby_text1 labelledby_text2"/> |
michael@0 | 224 | |
michael@0 | 225 | <!-- aria-labelledby, multiple relations --> |
michael@0 | 226 | <box class="third" id="labelledby_box_anon" role="group" /> |
michael@0 | 227 | |
michael@0 | 228 | <!-- trick aria-labelledby --> |
michael@0 | 229 | <checkbox id="rememberHistoryDays" |
michael@0 | 230 | label="Remember " |
michael@0 | 231 | aria-labelledby="rememberHistoryDays historyDays rememberAfter"/> |
michael@0 | 232 | <textbox id="historyDays" type="number" size="3" value="3" |
michael@0 | 233 | aria-labelledby="rememberHistoryDays historyDays rememberAfter"/> |
michael@0 | 234 | <label id="rememberAfter">days</label> |
michael@0 | 235 | |
michael@0 | 236 | <!-- the name from subtree, mixed content --> |
michael@0 | 237 | <description id="labelledby_mixed"> |
michael@0 | 238 | no<description>more text</description> |
michael@0 | 239 | </description> |
michael@0 | 240 | <button id="btn_labelledby_mixed" |
michael@0 | 241 | aria-labelledby="labelledby_mixed"/> |
michael@0 | 242 | |
michael@0 | 243 | <!-- the name from subtree, mixed/hidden content --> |
michael@0 | 244 | <description id="labelledby_mixed_hidden_child">no<description>more <description hidden="true">hidden</description>text2</description></description> |
michael@0 | 245 | <button id="btn_labelledby_mixed_hidden_child" |
michael@0 | 246 | aria-labelledby="labelledby_mixed_hidden_child"/> |
michael@0 | 247 | |
michael@0 | 248 | <!-- the name from subtree, mixed/completely hidden content --> |
michael@0 | 249 | <description id="labelledby_mixed_hidden" |
michael@0 | 250 | hidden="true">lala <description>more hidden </description>text</description> |
michael@0 | 251 | <button id="btn_labelledby_mixed_hidden" |
michael@0 | 252 | aria-labelledby="labelledby_mixed_hidden"/> |
michael@0 | 253 | <br/> |
michael@0 | 254 | |
michael@0 | 255 | <!-- the name from subtree, mixed content, ignore items of menulist --> |
michael@0 | 256 | <description id="labelledby_mixed_menulist"> |
michael@0 | 257 | no<description>more text</description> |
michael@0 | 258 | <menulist> |
michael@0 | 259 | <menupopup> |
michael@0 | 260 | <menuitem label="selected item"/> |
michael@0 | 261 | <menuitem label="item"/> |
michael@0 | 262 | </menupopup> |
michael@0 | 263 | </menulist> |
michael@0 | 264 | more text |
michael@0 | 265 | </description> |
michael@0 | 266 | <button id="btn_labelledby_mixed_menulist" |
michael@0 | 267 | aria-labelledby="labelledby_mixed_menulist"/> |
michael@0 | 268 | |
michael@0 | 269 | <!-- nsIDOMXULLabeledControlElement --> |
michael@0 | 270 | <button id="btn_nsIDOMXULLabeledControlElement" |
michael@0 | 271 | label="labeled element"/> |
michael@0 | 272 | |
michael@0 | 273 | <!-- nsIDOMXULSelectControlItemElement --> |
michael@0 | 274 | <listbox> |
michael@0 | 275 | <listitem id="li_nsIDOMXULSelectControlItemElement" |
michael@0 | 276 | label="select control item"/> |
michael@0 | 277 | </listbox> |
michael@0 | 278 | |
michael@0 | 279 | <!-- not nsIDOMXULSelectControlElement --> |
michael@0 | 280 | <box id="box_not_nsIDOMXULSelectControlElement" role="group" label="box"/> |
michael@0 | 281 | |
michael@0 | 282 | <!-- label element --> |
michael@0 | 283 | <hbox> |
michael@0 | 284 | <box> |
michael@0 | 285 | <label control="btn_label_1">label1</label> |
michael@0 | 286 | </box> |
michael@0 | 287 | <label control="btn_label_2">label2</label> |
michael@0 | 288 | <box> |
michael@0 | 289 | <button id="btn_label_1"/> |
michael@0 | 290 | <box> |
michael@0 | 291 | <box> |
michael@0 | 292 | <box> |
michael@0 | 293 | <button id="btn_label_2"/> |
michael@0 | 294 | </box> |
michael@0 | 295 | </box> |
michael@0 | 296 | </box> |
michael@0 | 297 | </box> |
michael@0 | 298 | <label control="btn_label_3">label3</label> |
michael@0 | 299 | <button id="btn_label_3"/> |
michael@0 | 300 | |
michael@0 | 301 | <label control="btn_label_4">label4</label> |
michael@0 | 302 | <label control="btn_label_4">label5</label> |
michael@0 | 303 | <button id="btn_label_4"/> |
michael@0 | 304 | </hbox> |
michael@0 | 305 | |
michael@0 | 306 | <!-- label element, anonymous content --> |
michael@0 | 307 | <box id="box_label_anon1" |
michael@0 | 308 | class="first" |
michael@0 | 309 | role="group"/> |
michael@0 | 310 | |
michael@0 | 311 | <box id="box_label_anon2" |
michael@0 | 312 | class="second" |
michael@0 | 313 | role="group"/> |
michael@0 | 314 | |
michael@0 | 315 | <!-- tooltiptext --> |
michael@0 | 316 | <box id="box_tooltiptext" |
michael@0 | 317 | role="group" |
michael@0 | 318 | tooltiptext="tooltiptext label"/> |
michael@0 | 319 | |
michael@0 | 320 | <!-- the name from @title of toolbaritem --> |
michael@0 | 321 | <toolbar> |
michael@0 | 322 | <toolbaritem title="ooospspss"> |
michael@0 | 323 | <textbox id="toolbaritem_textbox" |
michael@0 | 324 | flex="1" |
michael@0 | 325 | type="autocomplete" |
michael@0 | 326 | enablehistory="true"> |
michael@0 | 327 | <hbox role="button" id="toolbaritem_hboxbutton"> |
michael@0 | 328 | <description value="button"/> |
michael@0 | 329 | </hbox> |
michael@0 | 330 | </textbox> |
michael@0 | 331 | </toolbaritem> |
michael@0 | 332 | </toolbar> |
michael@0 | 333 | |
michael@0 | 334 | <!-- name from children --> |
michael@0 | 335 | <box id="box_children" role="button">14</box> |
michael@0 | 336 | |
michael@0 | 337 | <!-- name from children, hidden children --> |
michael@0 | 338 | <vbox role="listbox" tabindex="0"> |
michael@0 | 339 | <hbox id="lb_opt1_children_hidden" role="option" tabindex="0"> |
michael@0 | 340 | <description>i am visible</description> |
michael@0 | 341 | <description style="display:none">i am hidden</description> |
michael@0 | 342 | </hbox> |
michael@0 | 343 | </vbox> |
michael@0 | 344 | |
michael@0 | 345 | <!-- bug 441991; create name from other menuitem label listitem's own label --> |
michael@0 | 346 | <hbox> |
michael@0 | 347 | <listbox> |
michael@0 | 348 | <listitem id="li_labelledby" |
michael@0 | 349 | label="The moment the event starts" |
michael@0 | 350 | aria-labelledby="menuitem-DISPLAY li_labelledby"/> |
michael@0 | 351 | </listbox> |
michael@0 | 352 | <menulist> |
michael@0 | 353 | <menupopup> |
michael@0 | 354 | <menuitem id="menuitem-DISPLAY" |
michael@0 | 355 | value="DISPLAY" |
michael@0 | 356 | label="Show an Alert"/> |
michael@0 | 357 | <menuitem id="menuitem-EMAIL" |
michael@0 | 358 | value="EMAIL" |
michael@0 | 359 | label="Send an E-mail"/> |
michael@0 | 360 | </menupopup> |
michael@0 | 361 | </menulist> |
michael@0 | 362 | </hbox> |
michael@0 | 363 | |
michael@0 | 364 | </vbox> <!-- close tests area --> |
michael@0 | 365 | </hbox> <!-- close main area --> |
michael@0 | 366 | </window> |
michael@0 | 367 |