browser_roles_generic.js (32848B)
1 /* This Source Code Form is subject to the terms of the Mozilla Public 2 * License, v. 2.0. If a copy of the MPL was not distributed with this 3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 4 5 "use strict"; 6 7 /* import-globals-from ../../mochitest/role.js */ 8 loadScripts({ name: "role.js", dir: MOCHITESTS_DIR }); 9 10 /** 11 * Test ARIA role map 12 */ 13 addAccessibleTask( 14 `<span id="aria_alert" role="alert"></span> 15 <span id="aria_alert_mixed" role="aLERt"></span> 16 <span id="aria_alertdialog" role="alertdialog"></span> 17 <span id="aria_alertdialog_mixed" role="aLERTDIALOg"></span> 18 <span id="aria_application" role="application"></span> 19 <span id="aria_application_mixed" role="aPPLICATIOn"></span> 20 <span id="aria_article" role="article"></span> 21 <span id="aria_article_mixed" role="aRTICLe"></span> 22 <span id="aria_blockquote" role="blockquote"></span> 23 <span id="aria_blockquote_mixed" role="bLOCKQUOTe"></span> 24 <span id="aria_button" role="button"></span> 25 <span id="aria_button_mixed" role="bUTTOn"></span> 26 <span id="aria_caption" role="caption"></span> 27 <span id="aria_caption_mixed" role="cAPTIOn"></span> 28 <span id="aria_checkbox" role="checkbox"></span> 29 <span id="aria_checkbox_mixed" role="cHECKBOx"></span> 30 <span id="aria_code" role="code"></span> 31 <span id="aria_code_mixed" role="cODe"></span> 32 <span id="aria_combobox" role="combobox"></span> 33 <span id="aria_combobox_mixed" role="cOMBOBOx"></span> 34 <span id="aria_comment" role="comment"></span> 35 <span id="aria_comment_mixed" role="cOMMENt"></span> 36 <span id="aria_deletion" role="deletion"></span> 37 <span id="aria_deletion_mixed" role="dELETIOn"></span> 38 <span id="aria_dialog" role="dialog"></span> 39 <span id="aria_dialog_mixed" role="dIALOg"></span> 40 <span id="aria_directory" role="directory"></span> 41 <span id="aria_directory_mixed" role="dIRECTORy"></span> 42 <span id="aria_document" role="document"></span> 43 <span id="aria_document_mixed" role="dOCUMENt"></span> 44 <span id="aria_form" role="form"></span> 45 <span id="aria_form_mixed" role="fORm"></span> 46 <span id="aria_form_with_label" role="form" aria-label="Label"></span> 47 <span id="aria_form_with_label_mixed" role="fORm" aria-label="Label"></span> 48 <span id="aria_feed" role="feed"></span> 49 <span id="aria_feed_mixed" role="fEEd"></span> 50 <span id="aria_figure" role="figure"></span> 51 <span id="aria_figure_mixed" role="fIGURe"></span> 52 <span id="aria_grid" role="grid"></span> 53 <span id="aria_grid_mixed" role="gRId"></span> 54 <span id="aria_group" role="group"></span> 55 <span id="aria_group_mixed" role="gROUp"></span> 56 <span id="aria_heading" role="heading"></span> 57 <span id="aria_heading_mixed" role="hEADINg"></span> 58 <span id="aria_img" role="img"></span> 59 <span id="aria_img_mixed" role="iMg"></span> 60 <span id="aria_insertion" role="insertion"></span> 61 <span id="aria_insertion_mixed" role="iNSERTIOn"></span> 62 <span id="aria_link" role="link"></span> 63 <span id="aria_link_mixed" role="lINk"></span> 64 <span id="aria_list" role="list"></span> 65 <span id="aria_list_mixed" role="lISt"></span> 66 <span id="aria_listbox" role="listbox"></span> 67 <span id="aria_listbox_mixed" role="lISTBOx"></span> 68 <span id="aria_log" role="log"></span> 69 <span id="aria_log_mixed" role="lOg"></span> 70 <span id="aria_mark" role="mark"></span> 71 <span id="aria_mark_mixed" role="mARk"></span> 72 <span id="aria_marquee" role="marquee"></span> 73 <span id="aria_marquee_mixed" role="mARQUEe"></span> 74 <span id="aria_math" role="math"></span> 75 <span id="aria_math_mixed" role="mATh"></span> 76 <span id="aria_menu" role="menu"></span> 77 <span id="aria_menu_mixed" role="mENu"></span> 78 <span id="aria_menubar" role="menubar"></span> 79 <span id="aria_menubar_mixed" role="mENUBAr"></span> 80 <span id="aria_meter" role="meter"></span> 81 <span id="aria_meter_mixed" role="meTer"></span> 82 <span id="aria_note" role="note"></span> 83 <span id="aria_note_mixed" role="nOTe"></span> 84 <span id="aria_paragraph" role="paragraph"></span> 85 <span id="aria_paragraph_mixed" role="pARAGRAPh"></span> 86 <span id="aria_presentation" role="presentation" tabindex="0"></span> 87 <span id="aria_presentation_mixed" role="pRESENTATIOn" tabindex="0"></span> 88 <span id="aria_progressbar" role="progressbar"></span> 89 <span id="aria_progressbar_mixed" role="pROGRESSBAr"></span> 90 <span id="aria_radio" role="radio"></span> 91 <span id="aria_radio_mixed" role="rADIo"></span> 92 <span id="aria_radiogroup" role="radiogroup"></span> 93 <span id="aria_radiogroup_mixed" role="rADIOGROUp"></span> 94 <span id="aria_region_no_name" role="region"></span> 95 <span id="aria_region_no_name_mixed" role="rEGIOn"></span> 96 <span id="aria_region_has_label" role="region" aria-label="label"></span> 97 <span id="aria_region_has_label_mixed" role="rEGIOn" aria-label="label"></span> 98 <span id="aria_region_has_labelledby" role="region" aria-labelledby="label"><span id="label" aria-label="label"></span></span> 99 <span id="aria_region_has_labelledby_mixed" role="rEGIOn" aria-labelledby="label"><span id="label" aria-label="label"></span></span> 100 <span id="aria_region_has_title" role="region" title="title"></span> 101 <span id="aria_region_has_title_mixed" role="rEGIOn" title="title"></span> 102 <span id="aria_region_empty_name" role="region" aria-label="" title="" aria-labelledby="empty"></span><span id="empty"></span> 103 <span id="aria_region_empty_name_mixed" role="rEGIOn" aria-label="" title="" aria-labelledby="empty"></span><span id="empty"></span> 104 <table id="aria_region_as_table_with_caption" role="region"><caption>hello</caption></table> 105 <table id="aria_region_as_table_with_caption_mixed" role="rEGIOn"><caption>hello</caption></table> 106 <table id="aria_region_as_table_with_miscaption" role="region"><caption role="option">hello</caption></table> 107 <table id="aria_region_as_table_with_miscaption_mixed" role="rEGIOn"><caption role="option">hello</caption></table> 108 <span id="aria_scrollbar" role="scrollbar"></span> 109 <span id="aria_scrollbar_mixed" role="sCROLLBAr"></span> 110 <span id="aria_searchbox" role="searchbox"></span> 111 <span id="aria_searchbox_mixed" role="sEARCHBOx"></span> 112 <span id="aria_separator" role="separator"></span> 113 <span id="aria_separator_mixed" role="sEPARATOr"></span> 114 <span id="aria_slider" role="slider"></span> 115 <span id="aria_slider_mixed" role="sLIDEr"></span> 116 <span id="aria_spinbutton" role="spinbutton"></span> 117 <span id="aria_spinbutton_mixed" role="sPINBUTTOn"></span> 118 <span id="aria_status" role="status"></span> 119 <span id="aria_status_mixed" role="sTATUs"></span> 120 <span id="aria_subscript" role="subscript"></span> 121 <span id="aria_subscript_mixed" role="sUBSCRIPt"></span> 122 <span id="aria_suggestion" role="suggestion"></span> 123 <span id="aria_suggestion_mixed" role="sUGGESTIOn"></span> 124 <span id="aria_superscript" role="superscript"></span> 125 <span id="aria_superscript_mixed" role="sUPERSCRIPt"></span> 126 <span id="aria_switch" role="switch"></span> 127 <span id="aria_switch_mixed" role="sWITCh"></span> 128 <span id="aria_tablist" role="tablist"></span> 129 <span id="aria_tablist_mixed" role="tABLISt"></span> 130 <span id="aria_tabpanel" role="tabpanel"></span> 131 <span id="aria_tabpanel_mixed" role="tABPANEl"></span> 132 <span id="aria_term" role="term"></span> 133 <span id="aria_term_mixed" role="tERm"></span> 134 <span id="aria_textbox" role="textbox"></span> 135 <span id="aria_textbox_mixed" role="tEXTBOx"></span> 136 <span id="aria_timer" role="timer"></span> 137 <span id="aria_timer_mixed" role="tIMEr"></span> 138 <span id="aria_toolbar" role="toolbar"></span> 139 <span id="aria_toolbar_mixed" role="tOOLBAr"></span> 140 <span id="aria_tooltip" role="tooltip"></span> 141 <span id="aria_tooltip_mixed" role="tOOLTIp"></span> 142 <span id="aria_tree" role="tree"></span> 143 <span id="aria_tree_mixed" role="tREe"></span> 144 <span id="aria_treegrid" role="treegrid"></span> 145 <span id="aria_treegrid_mixed" role="tREEGRId"></span>`, 146 async function testARIARoleMap(browser, accDoc) { 147 let getAcc = id => findAccessibleChildByID(accDoc, id); 148 testRole(getAcc("aria_alert"), ROLE_ALERT); 149 testRole(getAcc("aria_alert_mixed"), ROLE_ALERT); 150 testRole(getAcc("aria_alertdialog"), ROLE_DIALOG); 151 testRole(getAcc("aria_alertdialog_mixed"), ROLE_DIALOG); 152 testRole(getAcc("aria_application"), ROLE_APPLICATION); 153 testRole(getAcc("aria_application_mixed"), ROLE_APPLICATION); 154 testRole(getAcc("aria_article"), ROLE_ARTICLE); 155 testRole(getAcc("aria_article_mixed"), ROLE_ARTICLE); 156 testRole(getAcc("aria_blockquote"), ROLE_BLOCKQUOTE); 157 testRole(getAcc("aria_blockquote_mixed"), ROLE_BLOCKQUOTE); 158 testRole(getAcc("aria_button"), ROLE_PUSHBUTTON); 159 testRole(getAcc("aria_button_mixed"), ROLE_PUSHBUTTON); 160 testRole(getAcc("aria_caption"), ROLE_CAPTION); 161 testRole(getAcc("aria_caption_mixed"), ROLE_CAPTION); 162 testRole(getAcc("aria_checkbox"), ROLE_CHECKBUTTON); 163 testRole(getAcc("aria_checkbox_mixed"), ROLE_CHECKBUTTON); 164 testRole(getAcc("aria_code"), ROLE_CODE); 165 testRole(getAcc("aria_code_mixed"), ROLE_CODE); 166 testRole(getAcc("aria_combobox"), ROLE_EDITCOMBOBOX); 167 testRole(getAcc("aria_combobox_mixed"), ROLE_EDITCOMBOBOX); 168 testRole(getAcc("aria_comment"), ROLE_COMMENT); 169 testRole(getAcc("aria_comment_mixed"), ROLE_COMMENT); 170 testRole(getAcc("aria_deletion"), ROLE_CONTENT_DELETION); 171 testRole(getAcc("aria_deletion_mixed"), ROLE_CONTENT_DELETION); 172 testRole(getAcc("aria_dialog"), ROLE_DIALOG); 173 testRole(getAcc("aria_dialog_mixed"), ROLE_DIALOG); 174 testRole(getAcc("aria_directory"), ROLE_LIST); 175 testRole(getAcc("aria_directory_mixed"), ROLE_LIST); 176 testRole(getAcc("aria_document"), ROLE_NON_NATIVE_DOCUMENT); 177 testRole(getAcc("aria_document_mixed"), ROLE_NON_NATIVE_DOCUMENT); 178 testRole(getAcc("aria_form"), ROLE_TEXT); 179 testRole(getAcc("aria_form_mixed"), ROLE_TEXT); 180 testRole(getAcc("aria_form_with_label"), ROLE_FORM); 181 testRole(getAcc("aria_form_with_label_mixed"), ROLE_FORM); 182 testRole(getAcc("aria_feed"), ROLE_GROUPING); 183 testRole(getAcc("aria_feed_mixed"), ROLE_GROUPING); 184 testRole(getAcc("aria_figure"), ROLE_FIGURE); 185 testRole(getAcc("aria_figure_mixed"), ROLE_FIGURE); 186 testRole(getAcc("aria_grid"), ROLE_GRID); 187 testRole(getAcc("aria_grid_mixed"), ROLE_GRID); 188 testRole(getAcc("aria_group"), ROLE_GROUPING); 189 testRole(getAcc("aria_group_mixed"), ROLE_GROUPING); 190 testRole(getAcc("aria_heading"), ROLE_HEADING); 191 testRole(getAcc("aria_heading_mixed"), ROLE_HEADING); 192 testRole(getAcc("aria_img"), ROLE_GRAPHIC); 193 testRole(getAcc("aria_img_mixed"), ROLE_GRAPHIC); 194 testRole(getAcc("aria_insertion"), ROLE_CONTENT_INSERTION); 195 testRole(getAcc("aria_insertion_mixed"), ROLE_CONTENT_INSERTION); 196 testRole(getAcc("aria_link"), ROLE_LINK); 197 testRole(getAcc("aria_link_mixed"), ROLE_LINK); 198 testRole(getAcc("aria_list"), ROLE_LIST); 199 testRole(getAcc("aria_list_mixed"), ROLE_LIST); 200 testRole(getAcc("aria_listbox"), ROLE_LISTBOX); 201 testRole(getAcc("aria_listbox_mixed"), ROLE_LISTBOX); 202 testRole(getAcc("aria_log"), ROLE_TEXT); // weak role 203 testRole(getAcc("aria_log_mixed"), ROLE_TEXT); // weak role 204 testRole(getAcc("aria_mark"), ROLE_MARK); 205 testRole(getAcc("aria_mark_mixed"), ROLE_MARK); 206 testRole(getAcc("aria_marquee"), ROLE_ANIMATION); 207 testRole(getAcc("aria_marquee_mixed"), ROLE_ANIMATION); 208 testRole(getAcc("aria_math"), ROLE_FLAT_EQUATION); 209 testRole(getAcc("aria_math_mixed"), ROLE_FLAT_EQUATION); 210 testRole(getAcc("aria_menu"), ROLE_MENUPOPUP); 211 testRole(getAcc("aria_menu_mixed"), ROLE_MENUPOPUP); 212 testRole(getAcc("aria_menubar"), ROLE_MENUBAR); 213 testRole(getAcc("aria_menubar_mixed"), ROLE_MENUBAR); 214 testRole(getAcc("aria_meter"), ROLE_METER); 215 testRole(getAcc("aria_meter_mixed"), ROLE_METER); 216 testRole(getAcc("aria_note"), ROLE_NOTE); 217 testRole(getAcc("aria_note_mixed"), ROLE_NOTE); 218 testRole(getAcc("aria_paragraph"), ROLE_PARAGRAPH); 219 testRole(getAcc("aria_paragraph_mixed"), ROLE_PARAGRAPH); 220 testRole(getAcc("aria_presentation"), ROLE_TEXT); // weak role 221 testRole(getAcc("aria_presentation_mixed"), ROLE_TEXT); // weak role 222 testRole(getAcc("aria_progressbar"), ROLE_PROGRESSBAR); 223 testRole(getAcc("aria_progressbar_mixed"), ROLE_PROGRESSBAR); 224 testRole(getAcc("aria_radio"), ROLE_RADIOBUTTON); 225 testRole(getAcc("aria_radio_mixed"), ROLE_RADIOBUTTON); 226 testRole(getAcc("aria_radiogroup"), ROLE_RADIO_GROUP); 227 testRole(getAcc("aria_radiogroup_mixed"), ROLE_RADIO_GROUP); 228 testRole(getAcc("aria_region_no_name"), ROLE_TEXT); 229 testRole(getAcc("aria_region_no_name_mixed"), ROLE_TEXT); 230 testRole(getAcc("aria_region_has_label"), ROLE_REGION); 231 testRole(getAcc("aria_region_has_label_mixed"), ROLE_REGION); 232 testRole(getAcc("aria_region_has_labelledby"), ROLE_REGION); 233 testRole(getAcc("aria_region_has_labelledby_mixed"), ROLE_REGION); 234 testRole(getAcc("aria_region_has_title"), ROLE_REGION); 235 testRole(getAcc("aria_region_has_title_mixed"), ROLE_REGION); 236 testRole(getAcc("aria_region_empty_name"), ROLE_TEXT); 237 testRole(getAcc("aria_region_empty_name_mixed"), ROLE_TEXT); 238 testRole(getAcc("aria_region_as_table_with_caption"), ROLE_REGION); 239 testRole(getAcc("aria_region_as_table_with_caption_mixed"), ROLE_REGION); 240 testRole(getAcc("aria_region_as_table_with_miscaption"), ROLE_REGION); 241 testRole(getAcc("aria_region_as_table_with_miscaption_mixed"), ROLE_REGION); 242 testRole(getAcc("aria_scrollbar"), ROLE_SCROLLBAR); 243 testRole(getAcc("aria_scrollbar_mixed"), ROLE_SCROLLBAR); 244 testRole(getAcc("aria_searchbox"), ROLE_SEARCHBOX); 245 testRole(getAcc("aria_searchbox_mixed"), ROLE_SEARCHBOX); 246 testRole(getAcc("aria_separator"), ROLE_SEPARATOR); 247 testRole(getAcc("aria_separator_mixed"), ROLE_SEPARATOR); 248 testRole(getAcc("aria_slider"), ROLE_SLIDER); 249 testRole(getAcc("aria_slider_mixed"), ROLE_SLIDER); 250 testRole(getAcc("aria_spinbutton"), ROLE_SPINBUTTON); 251 testRole(getAcc("aria_spinbutton_mixed"), ROLE_SPINBUTTON); 252 testRole(getAcc("aria_status"), ROLE_STATUSBAR); 253 testRole(getAcc("aria_status_mixed"), ROLE_STATUSBAR); 254 testRole(getAcc("aria_subscript"), ROLE_SUBSCRIPT); 255 testRole(getAcc("aria_subscript_mixed"), ROLE_SUBSCRIPT); 256 testRole(getAcc("aria_suggestion"), ROLE_SUGGESTION); 257 testRole(getAcc("aria_suggestion_mixed"), ROLE_SUGGESTION); 258 testRole(getAcc("aria_superscript"), ROLE_SUPERSCRIPT); 259 testRole(getAcc("aria_superscript_mixed"), ROLE_SUPERSCRIPT); 260 testRole(getAcc("aria_switch"), ROLE_SWITCH); 261 testRole(getAcc("aria_switch_mixed"), ROLE_SWITCH); 262 testRole(getAcc("aria_tablist"), ROLE_PAGETABLIST); 263 testRole(getAcc("aria_tablist_mixed"), ROLE_PAGETABLIST); 264 testRole(getAcc("aria_tabpanel"), ROLE_PROPERTYPAGE); 265 testRole(getAcc("aria_tabpanel_mixed"), ROLE_PROPERTYPAGE); 266 testRole(getAcc("aria_term"), ROLE_TERM); 267 testRole(getAcc("aria_term_mixed"), ROLE_TERM); 268 testRole(getAcc("aria_textbox"), ROLE_ENTRY); 269 testRole(getAcc("aria_textbox_mixed"), ROLE_ENTRY); 270 testRole(getAcc("aria_timer"), ROLE_TEXT); // weak role 271 testRole(getAcc("aria_timer_mixed"), ROLE_TEXT); // weak role 272 testRole(getAcc("aria_toolbar"), ROLE_TOOLBAR); 273 testRole(getAcc("aria_toolbar_mixed"), ROLE_TOOLBAR); 274 testRole(getAcc("aria_tooltip"), ROLE_TOOLTIP); 275 testRole(getAcc("aria_tooltip_mixed"), ROLE_TOOLTIP); 276 testRole(getAcc("aria_tree"), ROLE_OUTLINE); 277 testRole(getAcc("aria_tree_mixed"), ROLE_OUTLINE); 278 testRole(getAcc("aria_treegrid"), ROLE_TREE_TABLE); 279 testRole(getAcc("aria_treegrid_mixed"), ROLE_TREE_TABLE); 280 }, 281 { chrome: true, topLevel: true } 282 ); 283 284 /** 285 * Test ARIA landmarks 286 */ 287 addAccessibleTask( 288 ` <article id="articlemain" role="main">a main area</article> 289 <article id="articlemain_mixed" role="mAIn">a main area</article> 290 <article id="articleform" role="form">a form area</article> 291 <article id="articleform_mixed" role="fORm">a form area</article> 292 <article id="articleform_label" aria-label="form" role="form">a form area</article> 293 <article id="articleform_label_mixed" aria-label="form" role="fORm">a form area</article> 294 295 <div id="testArticle" role="article" title="Test article"> 296 <p>This is a paragraph inside the article.</p> 297 </div> 298 299 <div id="testArticle_mixed" role="aRTICLe" title="Test article"> 300 <p>This is a paragraph inside the article.</p> 301 </div> 302 303 <!-- "live" roles --> 304 <table role="log" id="log_table"> 305 <tr><td>Table based log</td></tr> 306 </table> 307 <table role="LOG" id="log_table_mixed"> 308 <tr><td>Table based log</td></tr> 309 </table> 310 <h1 role="marquee" id="marquee_h1">marquee</h1> 311 <h1 role="MARQUEE" id="marquee_h1_mixed">marquee</h1> 312 <div role="timer" id="timer_div">timer</div> 313 <div role="TIMER" id="timer_div_mixed">timer</div> 314 315 <!-- landmarks --> 316 <div role="application" id="application">application</div> 317 <div role="aPPLICATIOn" id="application_mixed">application</div> 318 <div role="form" id="form">form</div> 319 <div role="fORm" id="form_mixed">form</div> 320 <div role="form" id="form_label" aria-label="form">form</div> 321 <div role="fORm" id="form_label_mixed" aria-label="form">form</div> 322 323 <!-- weak landmarks --> 324 <div role="banner" id="banner">banner</div> 325 <div role="bANNEr" id="banner_mixed">banner</div> 326 <div role="complementary" id="complementary">complementary</div> 327 <div role="cOMPLEMENTARy" id="complementary_mixed">complementary</div> 328 <div role="contentinfo" id="contentinfo">contentinfo</div> 329 <div role="cONTENTINFo" id="contentinfo_mixed">contentinfo</div> 330 <div role="main" id="main">main</div> 331 <div role="mAIN" id="main_mixed">main</div> 332 <div role="navigation" id="navigation">navigation</div> 333 <div role="nAVIGATIOn" id="navigation_mixed">navigation</div> 334 <div role="search" id="search">search</div> 335 <div role="sEARCh" id="search_mixed">search</div> 336 337 <!-- landmarks are tables --> 338 <table role="application" id="application_table">application table 339 <tr><td>hi</td></tr></table> 340 <table role="aPPLICATIOn" id="application_table_mixed">application table 341 <tr><td>hi</td></tr></table> 342 <table role="banner" id="banner_table">banner table 343 <tr><td>hi</td></tr></table> 344 <table role="bANNEr" id="banner_table_mixed">banner table 345 <tr><td>hi</td></tr></table> 346 <table role="complementary" id="complementary_table">complementary table 347 <tr><td>hi</td></tr></table> 348 <table role="cOMPLEMENTARy" id="complementary_table_mixed">complementary table 349 <tr><td>hi</td></tr></table> 350 <table role="contentinfo" id="contentinfo_table">contentinfo table 351 <tr><td>hi</td></tr></table> 352 <table role="cONTENTINFo" id="contentinfo_table_mixed">contentinfo table 353 <tr><td>hi</td></tr></table> 354 <table role="main" id="main_table">main table 355 <tr><td>hi</td></tr></table> 356 <table role="mAIn" id="main_table_mixed">main table 357 <tr><td>hi</td></tr></table> 358 <table role="navigation" id="navigation_table">navigation table 359 <tr><td>hi</td></tr></table> 360 <table role="nAVIGATIOn" id="navigation_table_mixed">navigation table 361 <tr><td>hi</td></tr></table> 362 <table role="search" id="search_table">search table 363 <tr><td>hi</td></tr></table> 364 <table role="sEARCh" id="search_table_mixed">search table 365 <tr><td>hi</td></tr></table> 366 `, 367 async function testLandMarks(browser, accDoc) { 368 let getAcc = id => findAccessibleChildByID(accDoc, id); 369 // Note: 370 // The phrase "weak foo" here means that there is no good foo-to-gecko 371 // role mapping. Similarly "strong foo" means there is a good foo-to- 372 // gecko role mapping. 373 374 testRole(getAcc("articlemain"), ROLE_LANDMARK); 375 testRole(getAcc("articlemain_mixed"), ROLE_LANDMARK); 376 testRole(getAcc("articleform"), ROLE_ARTICLE); 377 testRole(getAcc("articleform_mixed"), ROLE_ARTICLE); 378 testRole(getAcc("articleform_label"), ROLE_FORM); 379 testRole(getAcc("articleform_label_mixed"), ROLE_FORM); 380 381 // Test article exposed as article 382 testRole(getAcc("testArticle"), ROLE_ARTICLE); 383 testRole(getAcc("testArticle_mixed"), ROLE_ARTICLE); 384 385 // weak roles that are forms of "live regions" 386 testRole(getAcc("log_table"), ROLE_TABLE); 387 testRole(getAcc("log_table_mixed"), ROLE_TABLE); 388 testRole(getAcc("timer_div"), ROLE_SECTION); 389 testRole(getAcc("timer_div_mixed"), ROLE_SECTION); 390 391 // other roles that are forms of "live regions" 392 testRole(getAcc("marquee_h1"), ROLE_ANIMATION); 393 testRole(getAcc("marquee_h1_mixed"), ROLE_ANIMATION); 394 395 // strong landmark 396 testRole(getAcc("application"), ROLE_APPLICATION); 397 testRole(getAcc("application_mixed"), ROLE_APPLICATION); 398 testRole(getAcc("form"), ROLE_SECTION); 399 testRole(getAcc("form_mixed"), ROLE_SECTION); 400 testRole(getAcc("form_label"), ROLE_FORM); 401 testRole(getAcc("form_label_mixed"), ROLE_FORM); 402 testRole(getAcc("application_table"), ROLE_APPLICATION); 403 testRole(getAcc("application_table_mixed"), ROLE_APPLICATION); 404 405 function testLandmark(landmarkId) { 406 testRole(getAcc(landmarkId), ROLE_LANDMARK); 407 testRole(getAcc(`${landmarkId}_mixed`), ROLE_LANDMARK); 408 409 let landmarkTable = getAcc(`${landmarkId}_table`); 410 testRole(landmarkTable, ROLE_LANDMARK); 411 ok( 412 !!landmarkTable.QueryInterface(nsIAccessibleTable), 413 "landmarked table should have nsIAccessibleTable" 414 ); 415 416 let landmarkTableMixed = getAcc(`${landmarkId}_table_mixed`); 417 testRole(landmarkTableMixed, ROLE_LANDMARK); 418 ok( 419 !!landmarkTableMixed.QueryInterface(nsIAccessibleTable), 420 "landmarked table should have nsIAccessibleTable" 421 ); 422 is(landmarkTableMixed.getCellAt(0, 0).firstChild.name, "hi", "no cell"); 423 } 424 425 testLandmark("banner"); 426 testLandmark("complementary"); 427 testLandmark("contentinfo"); 428 testLandmark("main"); 429 testLandmark("navigation"); 430 testLandmark("search"); 431 }, 432 { chrome: true, topLevel: true } 433 ); 434 435 /** 436 * Test abstract roles. 437 * User agents must not map abstract roles to anything but a generic "section" gecko role. 438 */ 439 addAccessibleTask( 440 `<!-- test abstract base type roles --> 441 <div role="composite" id="composite">composite</div> 442 <div role="cOMPOSITe" id="composite_mixed">composite</div> 443 <div role="landmark" id="landmark">landmark</div> 444 <div role="lANDMARk" id="landmark_mixed">landmark</div> 445 <div role="roletype" id="roletype">roletype</div> 446 <div role="rOLETYPe" id="roletype_mixed">roletype</div> 447 <div role="structure" id="structure">structure</div> 448 <div role="sTRUCTURe" id="structure_mixed">structure</div> 449 <div role="widget" id="widget">widget</div> 450 <div role="wIDGEt" id="widget_mixed">widget</div> 451 <div role="window" id="window">window</div> 452 <div role="wINDOw" id="window_mixed">window</div> 453 <!-- test abstract input roles --> 454 <div role="input" id="input">input</div> 455 <div role="iNPUt" id="input_mixed">input</div> 456 <div role="range" id="range">range</div> 457 <div role="rANGe" id="range_mixed">range</div> 458 <div role="select" id="select">select</div> 459 <div role="sELECt" id="select_mixed">select</div> 460 <!-- test abstract structure roles --> 461 <div role="section" id="section">section</div> 462 <div role="sECTIOn" id="section_mixed">section</div> 463 <div role="sectionhead" id="sectionhead">sectionhead</div> 464 <div role="sECTIONHEAd" id="sectionhead_mixed">sectionhead</div> 465 <div role="command" id="command">command</div> 466 <div role="cOmManD" id="command_mixed">command</div> 467 `, 468 async function testAbstract(browser, accDoc) { 469 let getAcc = id => findAccessibleChildByID(accDoc, id); 470 471 function testAbstractRole(id) { 472 testRole(getAcc(id), ROLE_SECTION); 473 testRole(getAcc(`${id}_mixed`), ROLE_SECTION); 474 } 475 476 testAbstractRole("composite"); 477 testAbstractRole("landmark"); 478 testAbstractRole("structure"); 479 testAbstractRole("widget"); 480 testAbstractRole("window"); 481 testAbstractRole("input"); 482 testAbstractRole("range"); 483 testAbstractRole("select"); 484 testAbstractRole("section"); 485 testAbstractRole("sectionhead"); 486 testAbstractRole("command"); 487 }, 488 { chrome: true, topLevel: true } 489 ); 490 491 /** 492 * Test child roles dependent on ancestor role presence 493 */ 494 addAccessibleTask( 495 `<table role="button"> 496 <tr id="buttontable_row"> 497 <td id="buttontable_cell">cell</td> 498 </tr> 499 </table> 500 <table role="bUTTOn"> 501 <tr id="buttontable_row_mixed"> 502 <td id="buttontable_cell_mixed">cell</td> 503 </tr> 504 </table> 505 506 <!-- roles transformed by ARIA roles of ancestors --> 507 <table role="grid"> 508 <tr> 509 <td id="implicit_gridcell">foo</td> 510 </tr> 511 </table> 512 <table role="gRId"> 513 <tr> 514 <td id="implicit_gridcell_mixed">foo</td> 515 </tr> 516 </table> 517 518 <!-- child roles dependent on ancestor role presence --> 519 <div role="grid"> 520 <div role="row"> 521 <span id="aria_columnheader" role="columnheader"></span> 522 <span id="aria_columnheader_mixed" role="cOLUMNHEADEr"></span> 523 <span id="aria_gridcell" role="gridcell"></span> 524 <span id="aria_gridcell_mixed" role="gRIDCELl"></span> 525 <span id="aria_rowheader" role="rowheader"></span> 526 <span id="aria_rowheader_mixed" role="rOWHEADEr"></span> 527 </div> 528 </div> 529 <div role="list"> 530 <span id="aria_listitem" role="listitem"></span> 531 <span id="aria_listitem_mixed" role="lISTITEm"></span> 532 </div> 533 <div role="menu"> 534 <span id="aria_menuitem" role="menuitem"></span> 535 <span id="aria_menuitem_mixed" role="mENUITEm"></span> 536 <span id="aria_menuitemcheckbox" role="menuitemcheckbox"></span> 537 <span id="aria_menuitemcheckbox_mixed" role="mENUITEMCHECKBOx"></span> 538 <span id="aria_menuitemradio" role="menuitemradio"></span> 539 <span id="aria_menuitemradio_mixed" role="mENUITEMRADIo"></span> 540 </div> 541 <div role="table"> 542 <span id="aria_row" role="row"></span> 543 <span id="aria_row_mixed" role="rOw"></span> 544 </div> 545 <div role="tablist"> 546 <span id="aria_tab" role="tab"></span> 547 <span id="aria_tab_mixed" role="tAb"></span> 548 </div> 549 <div role="tree"> 550 <span id="aria_treeitem" role="treeitem"></span> 551 <span id="aria_treeitem_mixed" role="tREEITEm"></span> 552 </div> 553 554 <!-- roles transformed by ARIA state attributes --> 555 <button aria-pressed="true" id="togglebutton"></button> 556 <button aria-pressed="tRUe" id="togglebutton_mixed"></button> 557 558 `, 559 async function testAncestorDependent(browser, accDoc) { 560 let getAcc = id => findAccessibleChildByID(accDoc, id); 561 562 testRole(getAcc("buttontable_row"), ROLE_TEXT_CONTAINER); 563 testRole(getAcc("buttontable_row_mixed"), ROLE_TEXT_CONTAINER); 564 testRole(getAcc("buttontable_cell"), ROLE_TEXT_CONTAINER); 565 testRole(getAcc("buttontable_cell_mixed"), ROLE_TEXT_CONTAINER); 566 567 testRole(getAcc("implicit_gridcell"), ROLE_GRID_CELL); 568 testRole(getAcc("implicit_gridcell_mixed"), ROLE_GRID_CELL); 569 570 testRole(getAcc("aria_columnheader"), ROLE_COLUMNHEADER); 571 testRole(getAcc("aria_columnheader_mixed"), ROLE_COLUMNHEADER); 572 testRole(getAcc("aria_gridcell"), ROLE_GRID_CELL); 573 testRole(getAcc("aria_gridcell_mixed"), ROLE_GRID_CELL); 574 testRole(getAcc("aria_rowheader"), ROLE_ROWHEADER); 575 testRole(getAcc("aria_rowheader_mixed"), ROLE_ROWHEADER); 576 testRole(getAcc("aria_listitem"), ROLE_LISTITEM); 577 testRole(getAcc("aria_listitem_mixed"), ROLE_LISTITEM); 578 testRole(getAcc("aria_menuitem"), ROLE_MENUITEM); 579 testRole(getAcc("aria_menuitem_mixed"), ROLE_MENUITEM); 580 testRole(getAcc("aria_menuitemcheckbox"), ROLE_CHECK_MENU_ITEM); 581 testRole(getAcc("aria_menuitemcheckbox_mixed"), ROLE_CHECK_MENU_ITEM); 582 testRole(getAcc("aria_menuitemradio"), ROLE_RADIO_MENU_ITEM); 583 testRole(getAcc("aria_menuitemradio_mixed"), ROLE_RADIO_MENU_ITEM); 584 testRole(getAcc("aria_row"), ROLE_ROW); 585 testRole(getAcc("aria_row_mixed"), ROLE_ROW); 586 testRole(getAcc("aria_tab"), ROLE_PAGETAB); 587 testRole(getAcc("aria_tab_mixed"), ROLE_PAGETAB); 588 testRole(getAcc("aria_treeitem"), ROLE_OUTLINEITEM); 589 testRole(getAcc("aria_treeitem_mixed"), ROLE_OUTLINEITEM); 590 591 // roles transformed by ARIA state attributes 592 testRole(getAcc("togglebutton"), ROLE_TOGGLE_BUTTON); 593 testRole(getAcc("togglebutton_mixed"), ROLE_TOGGLE_BUTTON); 594 }, 595 { chrome: true, topLevel: true } 596 ); 597 598 /** 599 * Test misc quirks 600 */ 601 addAccessibleTask( 602 `<!-- take the first known mappable role --> 603 <div role="wiggly:worm abc123 button" id="unknown_roles">worm button</div> 604 <div role="wiggly:worm abc123 bUTTOn" id="unknown_roles_mixed">worm button</div> 605 606 <!-- misc roles --> 607 <div role="note" id="note">note</div> 608 <div role="nOTe" id="note_mixed">note</div> 609 <div role="scrollbar" id="scrollbar">scrollbar</div> 610 <div role="sCROLLBAr" id="scrollbar_mixed">scrollbar</div> 611 612 <div id="dir" role="directory"> 613 <div role="listitem">A</div> 614 <div role="listitem">B</div> 615 <div role="listitem">C</div> 616 </div> 617 618 <div id="dir_mixed" role="dIRECTORy"> 619 <div role="listitem">A</div> 620 <div role="listitem">B</div> 621 <div role="listitem">C</div> 622 </div>`, 623 async function testRoleQuirks(browser, accDoc) { 624 let getAcc = id => findAccessibleChildByID(accDoc, id); 625 626 // //////////////////////////////////////////////////////////////////////// 627 // ignore unknown roles, take first known 628 testRole(getAcc("unknown_roles"), ROLE_PUSHBUTTON); 629 testRole(getAcc("unknown_roles_mixed"), ROLE_PUSHBUTTON); 630 631 // //////////////////////////////////////////////////////////////////////// 632 // misc roles 633 testRole(getAcc("note"), ROLE_NOTE); 634 testRole(getAcc("note_mixed"), ROLE_NOTE); 635 testRole(getAcc("scrollbar"), ROLE_SCROLLBAR); 636 testRole(getAcc("scrollbar_mixed"), ROLE_SCROLLBAR); 637 testRole(getAcc("dir"), ROLE_LIST); 638 testRole(getAcc("dir_mixed"), ROLE_LIST); 639 }, 640 { chrome: true, topLevel: true } 641 ); 642 643 /** 644 * Test equations 645 */ 646 addAccessibleTask( 647 `<p>Image: 648 <img id="img_eq" role="math" src="foo" alt="x^2 + y^2 + z^2"> 649 </p> 650 651 <p>Image: 652 <img id="img_eq_mixed" role="mATh" src="foo" alt="x^2 + y^2 + z^2"> 653 </p> 654 655 <p>Text: 656 <span id="txt_eq" role="math" title="x^2 + y^2 + z^2">x<sup>2</sup> + 657 y<sup>2</sup> + z<sup>2</sup></span> 658 </p> 659 <p>Text: 660 <span id="txt_eq_mixed" role="mATh" title="x^2 + y^2 + z^2">x<sup>2</sup> + 661 y<sup>2</sup> + z<sup>2</sup></span> 662 </p> 663 664 `, 665 async function testRoleQuirks(browser, accDoc) { 666 let getAcc = id => findAccessibleChildByID(accDoc, id); 667 // Test equation image 668 testRole(getAcc("img_eq"), ROLE_FLAT_EQUATION); 669 testRole(getAcc("img_eq_mixed"), ROLE_FLAT_EQUATION); 670 671 // Test textual equation 672 testRole(getAcc("txt_eq"), ROLE_FLAT_EQUATION); 673 testRole(getAcc("txt_eq_mixed"), ROLE_FLAT_EQUATION); 674 }, 675 { chrome: true, topLevel: true } 676 ); 677 678 /** 679 * Test doc role changes 680 */ 681 addAccessibleTask( 682 ``, 683 async function testRoleQuirks(browser, accDoc) { 684 await invokeSetAttribute(browser, "body", "role", "application"); 685 await untilCacheIs( 686 () => accDoc.role, 687 ROLE_APPLICATION, 688 "Doc role is 'application'" 689 ); 690 691 await invokeSetAttribute(browser, "body", "role", "dialog"); 692 await untilCacheIs(() => accDoc.role, ROLE_DIALOG, "Doc role is 'dialog'"); 693 694 // Other roles aren't valid on body elements. 695 696 await invokeSetAttribute(browser, "body", "role", "document"); 697 await untilCacheIs( 698 () => accDoc.role, 699 ROLE_DOCUMENT, 700 "Doc role is 'document'" 701 ); 702 703 await invokeSetAttribute(browser, "body", "role", "button"); 704 await untilCacheIs( 705 () => accDoc.role, 706 ROLE_DOCUMENT, 707 "Doc role is 'document'" 708 ); 709 710 // ... but mixed roles should still function like their regular variants 711 712 await invokeSetAttribute(browser, "body", "role", "ApPLiCaTiOn"); 713 await untilCacheIs( 714 () => accDoc.role, 715 ROLE_APPLICATION, 716 "Doc role is 'application'" 717 ); 718 719 await invokeSetAttribute(browser, "body", "role", "dIaLoG"); 720 await untilCacheIs(() => accDoc.role, ROLE_DIALOG, "Doc role is 'dialog'"); 721 }, 722 { chrome: true, topLevel: true } 723 ); 724 725 /** 726 * Test re-parented list item's role gets recomputed. 727 */ 728 addAccessibleTask( 729 `<div role="list" id="aria-list"> 730 </div> 731 <div role="listitem" id="aria-listitem">Bananas</div>`, 732 async function testListItemRelocation(browser, accDoc) { 733 is( 734 findAccessibleChildByID(accDoc, "aria-listitem").role, 735 ROLE_SECTION, 736 "List item in list should have section role" 737 ); 738 739 let evt = waitForEvent(EVENT_INNER_REORDER, "aria-list"); 740 await invokeSetAttribute( 741 browser, 742 "aria-list", 743 "aria-owns", 744 "aria-listitem" 745 ); 746 await evt; 747 748 is( 749 findAccessibleChildByID(accDoc, "aria-listitem").role, 750 ROLE_LISTITEM, 751 "List item in list should have listitem role" 752 ); 753 }, 754 { chrome: true, topLevel: true } 755 );