browser_accessibility_text_label_audit.js (34896B)
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 /** 8 * Checks functionality around text label audit for the AccessibleActor. 9 */ 10 11 const { 12 accessibility: { 13 AUDIT_TYPE: { TEXT_LABEL }, 14 SCORES: { BEST_PRACTICES, FAIL, WARNING }, 15 ISSUE_TYPE: { 16 [TEXT_LABEL]: { 17 DIALOG_NO_NAME, 18 DOCUMENT_NO_TITLE, 19 EMBED_NO_NAME, 20 FIGURE_NO_NAME, 21 FORM_FIELDSET_NO_NAME, 22 FORM_FIELDSET_NO_NAME_FROM_LEGEND, 23 FORM_NO_NAME, 24 FORM_NO_VISIBLE_NAME, 25 FORM_OPTGROUP_NO_NAME_FROM_LABEL, 26 HEADING_NO_CONTENT, 27 HEADING_NO_NAME, 28 IFRAME_NO_NAME_FROM_TITLE, 29 IMAGE_NO_NAME, 30 INTERACTIVE_NO_NAME, 31 MATHML_GLYPH_NO_NAME, 32 TOOLBAR_NO_NAME, 33 }, 34 }, 35 }, 36 } = require("resource://devtools/shared/constants.js"); 37 38 add_task(async function () { 39 const { target, walker, a11yWalker, parentAccessibility } = 40 await initAccessibilityFrontsForUrl( 41 `${MAIN_DOMAIN}doc_accessibility_text_label_audit.html` 42 ); 43 44 const tests = [ 45 ["Button menu with inner content", "#buttonmenu-1", null], 46 ["Button menu nested inside a <label>", "#buttonmenu-2", null], 47 [ 48 "Button menu with no name", 49 "#buttonmenu-3", 50 { score: FAIL, issue: INTERACTIVE_NO_NAME }, 51 ], 52 ["Button menu with aria-label", "#buttonmenu-4", null], 53 ["Button menu with <label>", "#buttonmenu-5", null], 54 ["Button menu with aria-labelledby", "#buttonmenu-6", null], 55 ["Paragraph with inner content", "#p1", null], 56 ["Empty paragraph", "#p2", null], 57 [ 58 "<canvas> with no name", 59 "#canvas-1", 60 { score: FAIL, issue: IMAGE_NO_NAME }, 61 ], 62 ["<canvas> with aria-label", "#canvas-2", null], 63 ["<canvas> with aria-labelledby", "#canvas-3", null], 64 [ 65 "<canvas> with inner content", 66 "#canvas-4", 67 { score: FAIL, issue: IMAGE_NO_NAME }, 68 ], 69 [ 70 "Checkbox with no name", 71 "#checkbox-1", 72 { score: FAIL, issue: FORM_NO_NAME }, 73 ], 74 [ 75 "Checkbox with unrelated label", 76 "#checkbox-2", 77 { score: FAIL, issue: FORM_NO_NAME }, 78 ], 79 ["Checkbox nested inside a <label>", "#checkbox-3", null], 80 ["Checkbox with a label", "#checkbox-4", null], 81 [ 82 "Checkbox with aria-label", 83 "#checkbox-5", 84 { score: WARNING, issue: FORM_NO_VISIBLE_NAME }, 85 ], 86 ["Checkbox with aria-labelledby visible label", "#checkbox-6", null], 87 [ 88 "Empty aria checkbox", 89 "#checkbox-7", 90 { score: FAIL, issue: FORM_NO_NAME }, 91 ], 92 [ 93 "Aria checkbox with aria-label", 94 "#checkbox-8", 95 { score: WARNING, issue: FORM_NO_VISIBLE_NAME }, 96 ], 97 ["Aria checkbox with aria-labelledby visible label", "#checkbox-9", null], 98 ["Menuitem checkbox with inner content", "#menuitemcheckbox-1", null], 99 [ 100 "Menuitem checkbox with unlabelled inner content", 101 "#menuitemcheckbox-2", 102 { score: FAIL, issue: INTERACTIVE_NO_NAME }, 103 ], 104 [ 105 "Empty menuitem checkbox", 106 "#menuitemcheckbox-3", 107 { score: FAIL, issue: INTERACTIVE_NO_NAME }, 108 ], 109 [ 110 "Menuitem checkbox with no textual inner content", 111 "#menuitemcheckbox-4", 112 { score: FAIL, issue: INTERACTIVE_NO_NAME }, 113 ], 114 [ 115 "Menuitem checkbox with labelled inner content", 116 "#menuitemcheckbox-5", 117 null, 118 ], 119 [ 120 "Menuitem checkbox with white space inner content", 121 "#menuitemcheckbox-6", 122 { score: FAIL, issue: INTERACTIVE_NO_NAME }, 123 ], 124 ["Column header with inner content", "#columnheader-1", null], 125 [ 126 "Empty column header", 127 "#columnheader-2", 128 { score: FAIL, issue: INTERACTIVE_NO_NAME }, 129 ], 130 [ 131 "Column header with white space inner content", 132 "#columnheader-3", 133 { score: FAIL, issue: INTERACTIVE_NO_NAME }, 134 ], 135 ["Column header with aria-label", "#columnheader-4", null], 136 [ 137 "Column header with empty aria-label", 138 "#columnheader-5", 139 { score: FAIL, issue: INTERACTIVE_NO_NAME }, 140 ], 141 [ 142 "Column header with white space aria-label", 143 "#columnheader-6", 144 { score: FAIL, issue: INTERACTIVE_NO_NAME }, 145 ], 146 ["Column header with aria-labelledby", "#columnheader-7", null], 147 ["Aria column header with inner content", "#columnheader-8", null], 148 [ 149 "Empty aria column header", 150 "#columnheader-9", 151 { score: FAIL, issue: INTERACTIVE_NO_NAME }, 152 ], 153 [ 154 "Aria column header with white space inner content", 155 "#columnheader-10", 156 { score: FAIL, issue: INTERACTIVE_NO_NAME }, 157 ], 158 ["Aria column header with aria-label", "#columnheader-11", null], 159 [ 160 "Aria column header with empty aria-label", 161 "#columnheader-12", 162 { score: FAIL, issue: INTERACTIVE_NO_NAME }, 163 ], 164 [ 165 "Aria column header with white space aria-label", 166 "#columnheader-13", 167 { score: FAIL, issue: INTERACTIVE_NO_NAME }, 168 ], 169 ["Aria column header with aria-labelledby", "#columnheader-14", null], 170 ["Combobox with a <label>", "#combobox-1", null], 171 [ 172 "Combobox with no label", 173 "#combobox-2", 174 { score: FAIL, issue: FORM_NO_NAME }, 175 ], 176 [ 177 "Combobox with unrelated label", 178 "#combobox-3", 179 { score: FAIL, issue: FORM_NO_NAME }, 180 ], 181 ["Combobox nested inside a label", "#combobox-4", null], 182 [ 183 "Combobox with aria-label", 184 "#combobox-5", 185 { score: WARNING, issue: FORM_NO_VISIBLE_NAME }, 186 ], 187 ["Combobox with aria-labelledby a visible label", "#combobox-6", null], 188 ["Combobox option with inner content", "#combobox-option-1", null], 189 [ 190 "Combobox option with no inner content", 191 "#combobox-option-2", 192 { score: FAIL, issue: INTERACTIVE_NO_NAME }, 193 ], 194 [ 195 "Combobox option with white string inner content", 196 "#combobox-option-3", 197 { score: FAIL, issue: INTERACTIVE_NO_NAME }, 198 ], 199 ["Combobox option with label attribute", "#combobox-option-4", null], 200 [ 201 "Combobox option with empty label attribute", 202 "#combobox-option-5", 203 { score: FAIL, issue: INTERACTIVE_NO_NAME }, 204 ], 205 [ 206 "Combobox option with white string label attribute", 207 "#combobox-option-6", 208 { score: FAIL, issue: INTERACTIVE_NO_NAME }, 209 ], 210 [ 211 "Svg diagram with no name", 212 "#diagram-1", 213 { score: FAIL, issue: IMAGE_NO_NAME }, 214 ], 215 [ 216 "Svg diagram with empty aria-label", 217 "#diagram-2", 218 { score: FAIL, issue: IMAGE_NO_NAME }, 219 ], 220 ["Svg diagram with aria-label", "#diagram-3", null], 221 ["Svg diagram with aria-labelledby", "#diagram-4", null], 222 [ 223 "Svg diagram with aria-labelledby an element with empty content", 224 "#diagram-5", 225 { score: FAIL, issue: IMAGE_NO_NAME }, 226 ], 227 [ 228 "Dialog with no name", 229 "#dialog-1", 230 { score: BEST_PRACTICES, issue: DIALOG_NO_NAME }, 231 ], 232 [ 233 "Dialog with empty aria-label", 234 "#dialog-2", 235 { score: BEST_PRACTICES, issue: DIALOG_NO_NAME }, 236 ], 237 ["Dialog with aria-label", "#dialog-3", null], 238 ["Dialog with aria-labelledby", "#dialog-4", null], 239 [ 240 "Aria dialog with no name", 241 "#dialog-5", 242 { score: BEST_PRACTICES, issue: DIALOG_NO_NAME }, 243 ], 244 [ 245 "Aria dialog with empty aria-label", 246 "#dialog-6", 247 { score: BEST_PRACTICES, issue: DIALOG_NO_NAME }, 248 ], 249 ["Aria dialog with aria-label", "#dialog-7", null], 250 ["Aria dialog with aria-labelledby", "#dialog-8", null], 251 [ 252 "Dialog with aria-labelledby an element with empty content", 253 "#dialog-9", 254 { score: BEST_PRACTICES, issue: DIALOG_NO_NAME }, 255 ], 256 [ 257 "Aria dialog with aria-labelledby an element with empty content", 258 "#dialog-10", 259 { score: BEST_PRACTICES, issue: DIALOG_NO_NAME }, 260 ], 261 [ 262 "Edit combobox with no name", 263 "#editcombobox-1", 264 { score: FAIL, issue: FORM_NO_NAME }, 265 ], 266 [ 267 "Edit combobox with aria-label", 268 "#editcombobox-2", 269 { score: WARNING, issue: FORM_NO_VISIBLE_NAME }, 270 ], 271 [ 272 "Edit combobox with aria-labelled a visible label", 273 "#editcombobox-3", 274 null, 275 ], 276 ["Input nested inside a <label>", "#entry-1", null], 277 ["Input with no name", "#entry-2", { score: FAIL, issue: FORM_NO_NAME }], 278 [ 279 "Input with aria-label", 280 "#entry-3", 281 { score: WARNING, issue: FORM_NO_VISIBLE_NAME }, 282 ], 283 [ 284 "Input with unrelated <label>", 285 "#entry-4", 286 { score: FAIL, issue: FORM_NO_NAME }, 287 ], 288 ["Input with <label>", "#entry-5", null], 289 ["Input with aria-labelledby", "#entry-6", null], 290 [ 291 "Aria textbox with no name", 292 "#entry-7", 293 { score: FAIL, issue: FORM_NO_NAME }, 294 ], 295 [ 296 "Aria textbox with aria-label", 297 "#entry-8", 298 { score: WARNING, issue: FORM_NO_VISIBLE_NAME }, 299 ], 300 ["Aria textbox with aria-labelledby", "#entry-9", null], 301 ["Figure with <figcaption>", "#figure-1", null], 302 [ 303 "Figore with no <figcaption>", 304 "#figure-2", 305 { score: BEST_PRACTICES, issue: FIGURE_NO_NAME }, 306 ], 307 ["Aria figure with aria-labelledby", "#figure-3", null], 308 [ 309 "Aria figure with aria-labelledby an element with empty content", 310 "#figure-4", 311 { score: BEST_PRACTICES, issue: FIGURE_NO_NAME }, 312 ], 313 [ 314 "Aria figure with no name", 315 "#figure-5", 316 { score: BEST_PRACTICES, issue: FIGURE_NO_NAME }, 317 ], 318 ["Image with no alt text", "#img-1", { score: FAIL, issue: IMAGE_NO_NAME }], 319 ["Image with aria-label", "#img-2", null], 320 ["Image with aria-labelledby", "#img-3", null], 321 ["Image with alt text", "#img-4", null], 322 [ 323 "Image with aria-labelledby an element with empty content", 324 "#img-5", 325 { score: FAIL, issue: IMAGE_NO_NAME }, 326 ], 327 [ 328 "Aria image with no name", 329 "#img-6", 330 { score: FAIL, issue: IMAGE_NO_NAME }, 331 ], 332 ["Aria image with aria-label", "#img-7", null], 333 ["Aria image with aria-labelledby", "#img-8", null], 334 [ 335 "Aria image with empty aria-label", 336 "#img-9", 337 { score: FAIL, issue: IMAGE_NO_NAME }, 338 ], 339 [ 340 "Aria image with aria-labelledby an element with empty content", 341 "#img-10", 342 { score: FAIL, issue: IMAGE_NO_NAME }, 343 ], 344 ["<optgroup> with label", "#optgroup-1", null], 345 [ 346 "<optgroup> with empty label", 347 "#optgroup-2", 348 { score: FAIL, issue: FORM_OPTGROUP_NO_NAME_FROM_LABEL }, 349 ], 350 [ 351 "<optgroup> with no label", 352 "#optgroup-3", 353 { score: FAIL, issue: FORM_OPTGROUP_NO_NAME_FROM_LABEL }, 354 ], 355 [ 356 "<optgroup> with aria-label", 357 "#optgroup-4", 358 { score: FAIL, issue: FORM_OPTGROUP_NO_NAME_FROM_LABEL }, 359 ], 360 [ 361 "<optgroup> with aria-labelledby", 362 "#optgroup-5", 363 { score: FAIL, issue: FORM_OPTGROUP_NO_NAME_FROM_LABEL }, 364 ], 365 ["<fieldset> with <legend>", "#fieldset-1", null], 366 [ 367 "<fieldset> with empty <legend>", 368 "#fieldset-2", 369 { score: FAIL, issue: FORM_FIELDSET_NO_NAME }, 370 ], 371 [ 372 "<fieldset> with no <legend>", 373 "#fieldset-3", 374 { score: FAIL, issue: FORM_FIELDSET_NO_NAME }, 375 ], 376 [ 377 "<fieldset> with aria-label", 378 "#fieldset-4", 379 { score: WARNING, issue: FORM_FIELDSET_NO_NAME_FROM_LEGEND }, 380 ], 381 [ 382 "<fieldset> with aria-labelledby", 383 "#fieldset-5", 384 { score: WARNING, issue: FORM_FIELDSET_NO_NAME_FROM_LEGEND }, 385 ], 386 ["Empty <h1>", "#heading-1", { score: FAIL, issue: HEADING_NO_NAME }], 387 ["<h1> with inner content", "#heading-2", null], 388 [ 389 "<h1> with white space inner content", 390 "#heading-3", 391 { score: FAIL, issue: HEADING_NO_NAME }, 392 ], 393 [ 394 "<h1> with aria-label", 395 "#heading-4", 396 { score: WARNING, issue: HEADING_NO_CONTENT }, 397 ], 398 [ 399 "<h1> with aria-labelledby", 400 "#heading-5", 401 { score: WARNING, issue: HEADING_NO_CONTENT }, 402 ], 403 ["<h1> with inner content and aria-label", "#heading-6", null], 404 ["<h1> with inner content and aria-labelledby", "#heading-7", null], 405 [ 406 "Empty aria heading", 407 "#heading-8", 408 { score: FAIL, issue: HEADING_NO_NAME }, 409 ], 410 ["Aria heading with content", "#heading-9", null], 411 [ 412 "Aria heading with white space inner content", 413 "#heading-10", 414 { score: FAIL, issue: HEADING_NO_NAME }, 415 ], 416 [ 417 "Aria heading with aria-label", 418 "#heading-11", 419 { score: WARNING, issue: HEADING_NO_CONTENT }, 420 ], 421 [ 422 "Aria heading with aria-labelledby", 423 "#heading-12", 424 { score: WARNING, issue: HEADING_NO_CONTENT }, 425 ], 426 ["Aria heading with inner content and aria-label", "#heading-13", null], 427 [ 428 "Aria heading with inner content and aria-labelledby", 429 "#heading-14", 430 null, 431 ], 432 [ 433 "Image map with no name", 434 "#imagemap-1", 435 { score: FAIL, issue: IMAGE_NO_NAME }, 436 ], 437 ["Image map with aria-label", "#imagemap-2", null], 438 ["Image map with aria-labelledby", "#imagemap-3", null], 439 ["Image map with alt attribute", "#imagemap-4", null], 440 [ 441 "Image map with aria-labelledby an element with empty content", 442 "#imagemap-5", 443 { score: FAIL, issue: IMAGE_NO_NAME }, 444 ], 445 ["<iframe> with title", "#iframe-1", null], 446 [ 447 "<iframe> with empty title", 448 "#iframe-2", 449 { score: FAIL, issue: IFRAME_NO_NAME_FROM_TITLE }, 450 ], 451 [ 452 "<iframe> with no title", 453 "#iframe-3", 454 { score: FAIL, issue: IFRAME_NO_NAME_FROM_TITLE }, 455 ], 456 [ 457 "<iframe> with aria-label", 458 "#iframe-4", 459 { score: FAIL, issue: IFRAME_NO_NAME_FROM_TITLE }, 460 ], 461 [ 462 "<iframe> with aria-label and title", 463 "#iframe-5", 464 { score: FAIL, issue: IFRAME_NO_NAME_FROM_TITLE }, 465 ], 466 [ 467 "<object> with image data type and no name", 468 "#object-1", 469 { score: FAIL, issue: IMAGE_NO_NAME }, 470 ], 471 ["<object> with image data type and aria-label", "#object-2", null], 472 ["<object> with image data type and aria-labelledby", "#object-3", null], 473 ["<object> with non-image data type", "#object-4", null], 474 [ 475 "<embed> with image data type and no name", 476 "#embed-1", 477 { score: FAIL, issue: IMAGE_NO_NAME }, 478 ], 479 [ 480 "<embed> with video data type and no name", 481 "#embed-2", 482 { score: FAIL, issue: EMBED_NO_NAME }, 483 ], 484 ["<embed> with video data type and aria-label", "#embed-3", null], 485 ["<embed> with video data type and aria-labelledby", "#embed-4", null], 486 ["Link with no inner content", "#link-1", null], 487 ["Link with inner content", "#link-2", null], 488 [ 489 "Link with href and no inner content", 490 "#link-3", 491 { score: FAIL, issue: INTERACTIVE_NO_NAME }, 492 ], 493 ["Link with href and inner content", "#link-4", null], 494 [ 495 "Link with empty href and no inner content", 496 "#link-5", 497 { score: FAIL, issue: INTERACTIVE_NO_NAME }, 498 ], 499 ["Link with empty href and inner content", "#link-6", null], 500 [ 501 "Link with # href and no inner content", 502 "#link-7", 503 { score: FAIL, issue: INTERACTIVE_NO_NAME }, 504 ], 505 ["Link with # href and inner content", "#link-8", null], 506 [ 507 "Link with non empty href and no inner content", 508 "#link-9", 509 { score: FAIL, issue: INTERACTIVE_NO_NAME }, 510 ], 511 ["Link with non empty href and inner content", "#link-10", null], 512 ["Link with aria-label", "#link-11", null], 513 ["Link with aria-labelledby", "#link-12", null], 514 [ 515 "Aria link with no inner content", 516 "#link-13", 517 { score: FAIL, issue: INTERACTIVE_NO_NAME }, 518 ], 519 ["Aria link with inner content", "#link-14", null], 520 ["Aria link with aria-label", "#link-15", null], 521 ["Aria link with aria-labelledby", "#link-16", null], 522 ["<select> with a visible <label>", "#listbox-1", null], 523 [ 524 "<select> with no name", 525 "#listbox-2", 526 { score: FAIL, issue: FORM_NO_NAME }, 527 ], 528 [ 529 "<select> with unrelated <label>", 530 "#listbox-3", 531 { score: FAIL, issue: FORM_NO_NAME }, 532 ], 533 ["<select> nested inside a <label>", "#listbox-4", null], 534 [ 535 "<select> with aria-label", 536 "#listbox-5", 537 { score: WARNING, issue: FORM_NO_VISIBLE_NAME }, 538 ], 539 ["<select> with aria-labelledby a visible element", "#listbox-6", null], 540 [ 541 "MathML glyph with no name", 542 "#mglyph-1", 543 { score: FAIL, issue: MATHML_GLYPH_NO_NAME }, 544 ], 545 ["MathML glyph with aria-label", "#mglyph-2", null], 546 ["MathML glyph with aria-labelledby", "#mglyph-3", null], 547 ["MathML glyph with alt text", "#mglyph-4", null], 548 [ 549 "MathML glyph with empty alt text", 550 "#mglyph-5", 551 { score: FAIL, issue: MATHML_GLYPH_NO_NAME }, 552 ], 553 [ 554 "MathML glyph with aria-labelledby an element with no inner content", 555 "#mglyph-6", 556 { score: FAIL, issue: MATHML_GLYPH_NO_NAME }, 557 ], 558 [ 559 "Aria menu item with no name", 560 "#menuitem-1", 561 { score: FAIL, issue: INTERACTIVE_NO_NAME }, 562 ], 563 [ 564 "Aria menu item with empty aria-label", 565 "#menuitem-2", 566 { score: FAIL, issue: INTERACTIVE_NO_NAME }, 567 ], 568 ["Aria menu item with aria-label", "#menuitem-3", null], 569 ["Aria menu item with aria-labelledby", "#menuitem-4", null], 570 [ 571 "Aria menu item with aria-labelledby element with empty inner content", 572 "#menuitem-5", 573 { score: FAIL, issue: INTERACTIVE_NO_NAME }, 574 ], 575 ["Aria menu item with inner content", "#menuitem-6", null], 576 ["Option with inner content", "#option-1", null], 577 [ 578 "Option with no inner content", 579 "#option-2", 580 { score: FAIL, issue: INTERACTIVE_NO_NAME }, 581 ], 582 [ 583 "Option with white space inner ", 584 "#option-3", 585 { score: FAIL, issue: INTERACTIVE_NO_NAME }, 586 ], 587 ["Option with a label", "#option-4", null], 588 [ 589 "Option with an empty label", 590 "#option-5", 591 { score: FAIL, issue: INTERACTIVE_NO_NAME }, 592 ], 593 [ 594 "Option with a white space label", 595 "#option-6", 596 { score: FAIL, issue: INTERACTIVE_NO_NAME }, 597 ], 598 ["Aria option with inner content", "#option-7", null], 599 [ 600 "Aria option with no inner content", 601 "#option-8", 602 { score: FAIL, issue: INTERACTIVE_NO_NAME }, 603 ], 604 [ 605 "Aria option with white space inner content", 606 "#option-9", 607 { score: FAIL, issue: INTERACTIVE_NO_NAME }, 608 ], 609 ["Aria option with aria-label", "#option-10", null], 610 [ 611 "Aria option with empty aria-label", 612 "#option-11", 613 { score: FAIL, issue: INTERACTIVE_NO_NAME }, 614 ], 615 [ 616 "Aria option with white space aria-label", 617 "#option-12", 618 { score: FAIL, issue: INTERACTIVE_NO_NAME }, 619 ], 620 ["Aria option with aria-labelledby", "#option-13", null], 621 [ 622 "Aria option with aria-labelledby an element with empty content", 623 "#option-14", 624 { score: FAIL, issue: INTERACTIVE_NO_NAME }, 625 ], 626 [ 627 "Aria option with aria-labelledby an element with white space content", 628 "#option-15", 629 { score: FAIL, issue: INTERACTIVE_NO_NAME }, 630 ], 631 [ 632 "Empty aria treeitem", 633 "#treeitem-1", 634 { score: FAIL, issue: INTERACTIVE_NO_NAME }, 635 ], 636 [ 637 "Aria treeitem with empty aria-label", 638 "#treeitem-2", 639 { score: FAIL, issue: INTERACTIVE_NO_NAME }, 640 ], 641 ["Aria treeitem with aria-label", "#treeitem-3", null], 642 ["Aria treeitem with aria-labelledby", "#treeitem-4", null], 643 [ 644 "Aria treeitem with aria-labelledby an element with empty content", 645 "#treeitem-5", 646 { score: FAIL, issue: INTERACTIVE_NO_NAME }, 647 ], 648 ["Aria treeitem with inner content", "#treeitem-6", null], 649 [ 650 "Aria tab with no content", 651 "#tab-1", 652 { score: FAIL, issue: INTERACTIVE_NO_NAME }, 653 ], 654 [ 655 "Aria tab with empty aria-label", 656 "#tab-2", 657 { score: FAIL, issue: INTERACTIVE_NO_NAME }, 658 ], 659 ["Aria tab with aria-label", "#tab-3", null], 660 ["Aria tab with aria-labelledby", "#tab-4", null], 661 [ 662 "Aria tab with aria-labelledby an element with empty content", 663 "#tab-5", 664 { score: FAIL, issue: INTERACTIVE_NO_NAME }, 665 ], 666 ["Aria tab with inner content", "#tab-6", null], 667 ["Password nested inside a <label>", "#password-1", null], 668 ["Password no name", "#password-2", { score: FAIL, issue: FORM_NO_NAME }], 669 [ 670 "Password with aria-label", 671 "#password-3", 672 { score: WARNING, issue: FORM_NO_VISIBLE_NAME }, 673 ], 674 [ 675 "Password with unrelated label", 676 "#password-4", 677 { score: FAIL, issue: FORM_NO_NAME }, 678 ], 679 ["Password with <label>", "#password-5", null], 680 ["Password with aria-labelledby a visible element", "#password-6", null], 681 ["<progress> nested inside a label", "#progress-1", null], 682 [ 683 "<progress> with no name", 684 "#progress-2", 685 { score: FAIL, issue: FORM_NO_NAME }, 686 ], 687 [ 688 "<progress> with aria-label", 689 "#progress-3", 690 { score: WARNING, issue: FORM_NO_VISIBLE_NAME }, 691 ], 692 [ 693 "<progress> with unrelated <label>", 694 "#progress-4", 695 { score: FAIL, issue: FORM_NO_NAME }, 696 ], 697 ["<progress> with <label>", "#progress-5", null], 698 ["<progress> with aria-labelledby a visible element", "#progress-6", null], 699 [ 700 "Aria progressbar nested inside a <label>", 701 "#progress-7", 702 { score: FAIL, issue: FORM_NO_NAME }, 703 ], 704 [ 705 "Aria progressbar with aria-labelledby a visible element", 706 "#progress-8", 707 null, 708 ], 709 [ 710 "Aria progressbar no name", 711 "#progress-9", 712 { score: FAIL, issue: FORM_NO_NAME }, 713 ], 714 [ 715 "Aria progressbar with aria-label", 716 "#progress-10", 717 { score: WARNING, issue: FORM_NO_VISIBLE_NAME }, 718 ], 719 [ 720 "Aria progressbar with unrelated <label>", 721 "#progress-11", 722 { score: FAIL, issue: FORM_NO_NAME }, 723 ], 724 [ 725 "Aria progressbar with <label>", 726 "#progress-12", 727 { score: FAIL, issue: FORM_NO_NAME }, 728 ], 729 [ 730 "Aria progressbar with aria-labelledby a visible <label>", 731 "#progress-13", 732 null, 733 ], 734 ["Button with inner content", "#button-1", null], 735 [ 736 "Image button with no name", 737 "#button-2", 738 { score: FAIL, issue: INTERACTIVE_NO_NAME }, 739 ], 740 [ 741 "Button with no name", 742 "#button-3", 743 { score: FAIL, issue: INTERACTIVE_NO_NAME }, 744 ], 745 [ 746 "Image button with empty alt text", 747 "#button-4", 748 { score: FAIL, issue: INTERACTIVE_NO_NAME }, 749 ], 750 ["Image button with alt text", "#button-5", null], 751 [ 752 "Button with white space inner content", 753 "#button-6", 754 { score: FAIL, issue: INTERACTIVE_NO_NAME }, 755 ], 756 ["Button inside a <label>", "#button-7", null], 757 ["Button with aria-label", "#button-8", null], 758 [ 759 "Button with unrelated <label>", 760 "#button-9", 761 { score: FAIL, issue: INTERACTIVE_NO_NAME }, 762 ], 763 ["Button with <label>", "#button-10", null], 764 ["Button with aria-labelledby a visile <label>", "#button-11", null], 765 [ 766 "Aria button inside a label", 767 "#button-12", 768 { score: FAIL, issue: INTERACTIVE_NO_NAME }, 769 ], 770 ["Aria button with aria-labelled by a <label>", "#button-13", null], 771 [ 772 "Aria button with no content", 773 "#button-14", 774 { score: FAIL, issue: INTERACTIVE_NO_NAME }, 775 ], 776 ["Aria button with aria-label", "#button-15", null], 777 [ 778 "Aria button with unrelated <label>", 779 "#button-16", 780 { score: FAIL, issue: INTERACTIVE_NO_NAME }, 781 ], 782 [ 783 "Aria button with <label>", 784 "#button-17", 785 { score: FAIL, issue: INTERACTIVE_NO_NAME }, 786 ], 787 ["Aria button with aria-labelledby a visible <label>", "#button-18", null], 788 ["Radio nested inside a label", "#radiobutton-1", null], 789 [ 790 "Radio with no name", 791 "#radiobutton-2", 792 { score: FAIL, issue: FORM_NO_NAME }, 793 ], 794 [ 795 "Radio with aria-label", 796 "#radiobutton-3", 797 { score: WARNING, issue: FORM_NO_VISIBLE_NAME }, 798 ], 799 [ 800 "Radio with unrelated <label>", 801 "#radiobutton-4", 802 { score: FAIL, issue: FORM_NO_NAME }, 803 ], 804 ["Radio with visible label>", "#radiobutton-5", null], 805 ["Radio with aria-labelledby a visible <label>", "#radiobutton-6", null], 806 [ 807 "Aria radio with no name", 808 "#radiobutton-7", 809 { score: FAIL, issue: FORM_NO_NAME }, 810 ], 811 [ 812 "Aria radio with aria-label", 813 "#radiobutton-8", 814 { score: WARNING, issue: FORM_NO_VISIBLE_NAME }, 815 ], 816 [ 817 "Aria radio with aria-labelledby a visible element", 818 "#radiobutton-9", 819 null, 820 ], 821 ["Aria menuitemradio with inner content", "#menuitemradio-1", null], 822 [ 823 "Aria menuitemradio with no inner content", 824 "#menuitemradio-2", 825 { score: FAIL, issue: INTERACTIVE_NO_NAME }, 826 ], 827 [ 828 "Aria menuitemradio with white space inner content", 829 "#menuitemradio-3", 830 { score: FAIL, issue: INTERACTIVE_NO_NAME }, 831 ], 832 ["Rowheader with inner content", "#rowheader-1", null], 833 [ 834 "Rowheader with no inner content", 835 "#rowheader-2", 836 { score: FAIL, issue: INTERACTIVE_NO_NAME }, 837 ], 838 [ 839 "Rowheader with white space inner content", 840 "#rowheader-3", 841 { score: FAIL, issue: INTERACTIVE_NO_NAME }, 842 ], 843 ["Rowheader with aria-label", "#rowheader-4", null], 844 [ 845 "Rowheader with empty aria-label", 846 "#rowheader-5", 847 { score: FAIL, issue: INTERACTIVE_NO_NAME }, 848 ], 849 [ 850 "Rowheader with white space aria-label", 851 "#rowheader-6", 852 { score: FAIL, issue: INTERACTIVE_NO_NAME }, 853 ], 854 ["Rowheader with aria-labelledby", "#rowheader-7", null], 855 ["Aria rowheader with inner content", "#rowheader-8", null], 856 [ 857 "Aria rowheader with no inner content", 858 "#rowheader-9", 859 { score: FAIL, issue: INTERACTIVE_NO_NAME }, 860 ], 861 [ 862 "Aria rowheader with white space inner content", 863 "#rowheader-10", 864 { score: FAIL, issue: INTERACTIVE_NO_NAME }, 865 ], 866 ["Aria rowheader with aria-label", "#rowheader-11", null], 867 [ 868 "Aria rowheader with empty aria-label", 869 "#rowheader-12", 870 { score: FAIL, issue: INTERACTIVE_NO_NAME }, 871 ], 872 [ 873 "Aria rowheader with white space aria-label", 874 "#rowheader-13", 875 { score: FAIL, issue: INTERACTIVE_NO_NAME }, 876 ], 877 ["Aria rowheader with aria-labelledby", "#rowheader-14", null], 878 ["Slider nested inside a <label>", "#slider-1", null], 879 ["Slider with no name", "#slider-2", { score: FAIL, issue: FORM_NO_NAME }], 880 [ 881 "Slider with aria-label", 882 "#slider-3", 883 { score: WARNING, issue: FORM_NO_VISIBLE_NAME }, 884 ], 885 [ 886 "Slider with unrelated <label>", 887 "#slider-4", 888 { score: FAIL, issue: FORM_NO_NAME }, 889 ], 890 ["Slider with a visible <label>", "#slider-5", null], 891 ["Slider with aria-labelled by a visible <label>", "#slider-6", null], 892 [ 893 "Aria slider with no name", 894 "#slider-7", 895 { score: FAIL, issue: FORM_NO_NAME }, 896 ], 897 [ 898 "Aria slider with aria-label", 899 "#slider-8", 900 { score: WARNING, issue: FORM_NO_VISIBLE_NAME }, 901 ], 902 ["Aria slider with aria-labelledby a visible element", "#slider-9", null], 903 ["Number input inside a label", "#spinbutton-1", null], 904 [ 905 "Number input with no label", 906 "#spinbutton-2", 907 { score: FAIL, issue: FORM_NO_NAME }, 908 ], 909 [ 910 "Number input with aria-label", 911 "#spinbutton-3", 912 { score: WARNING, issue: FORM_NO_VISIBLE_NAME }, 913 ], 914 [ 915 "Number input with unrelated <label>", 916 "#spinbutton-4", 917 { score: FAIL, issue: FORM_NO_NAME }, 918 ], 919 ["Number input with visible <label>", "#spinbutton-5", null], 920 [ 921 "Number input with aria-labelled by a visible <label>", 922 "#spinbutton-6", 923 null, 924 ], 925 [ 926 "Aria spinbutton with no name", 927 "#spinbutton-7", 928 { score: FAIL, issue: FORM_NO_NAME }, 929 ], 930 [ 931 "Aria spinbutton with aria-label", 932 "#spinbutton-8", 933 { score: WARNING, issue: FORM_NO_VISIBLE_NAME }, 934 ], 935 [ 936 "Aria spinbutton with aria-labelledby a visible element", 937 "#spinbutton-9", 938 null, 939 ], 940 [ 941 "Aria switch with no name", 942 "#switch-1", 943 { score: FAIL, issue: FORM_NO_NAME }, 944 ], 945 [ 946 "Aria switch wtih aria-label", 947 "#switch-2", 948 { score: WARNING, issue: FORM_NO_VISIBLE_NAME }, 949 ], 950 ["Aria switch with aria-labelledby a visible element", "#switch-3", null], 951 [ 952 "Aria switch with unrelated <label>", 953 "#switch-4", 954 { score: FAIL, issue: FORM_NO_NAME }, 955 ], 956 [ 957 "Aria switch nested inside a <label>", 958 "#switch-5", 959 { score: FAIL, issue: FORM_NO_NAME }, 960 ], 961 // See bug: https://bugzilla.mozilla.org/show_bug.cgi?id=559770 962 // ["Meter inside a label", "#meter-1", null], 963 // See bug: https://bugzilla.mozilla.org/show_bug.cgi?id=559770 964 // ["Meter with no name", "#meter-2", { score: FAIL, issue: FORM_NO_NAME }], 965 // See bug: https://bugzilla.mozilla.org/show_bug.cgi?id=559770 966 // ["Meter with aria-label", "#meter-3", 967 // { score: WARNING, issue: FORM_NO_VISIBLE_NAME}], 968 // See bug: https://bugzilla.mozilla.org/show_bug.cgi?id=559770 969 // ["Meter with unrelated <label>", "#meter-4", { score: FAIL, issue: FORM_NO_NAME }], 970 ["Meter with visible <label>", "#meter-5", null], 971 ["Meter with aria-labelledby a visible <label>", "#meter-6", null], 972 // See bug: https://bugzilla.mozilla.org/show_bug.cgi?id=559770 973 // ["Aria meter with no name", "#meter-7", { score: FAIL, issue: FORM_NO_NAME }], 974 // See bug: https://bugzilla.mozilla.org/show_bug.cgi?id=559770 975 // ["Aria meter with aria-label", "#meter-8", 976 // { score: WARNING, issue: FORM_NO_VISIBLE_NAME}], 977 ["Aria meter with aria-labelledby a visible element", "#meter-9", null], 978 ["Toggle button with inner content", "#togglebutton-1", null], 979 [ 980 "Image toggle button with no name", 981 "#togglebutton-2", 982 { score: FAIL, issue: INTERACTIVE_NO_NAME }, 983 ], 984 [ 985 "Empty toggle button", 986 "#togglebutton-3", 987 { score: FAIL, issue: INTERACTIVE_NO_NAME }, 988 ], 989 [ 990 "Image toggle button with empty alt text", 991 "#togglebutton-4", 992 { score: FAIL, issue: INTERACTIVE_NO_NAME }, 993 ], 994 ["Image toggle button with alt text", "#togglebutton-5", null], 995 [ 996 "Toggle button with white space inner content", 997 "#togglebutton-6", 998 { score: FAIL, issue: INTERACTIVE_NO_NAME }, 999 ], 1000 ["Toggle button nested inside a label", "#togglebutton-7", null], 1001 ["Toggle button with aria-label", "#togglebutton-8", null], 1002 [ 1003 "Toggle button with unrelated <label>", 1004 "#togglebutton-9", 1005 { score: FAIL, issue: INTERACTIVE_NO_NAME }, 1006 ], 1007 ["Toggle button with <label>", "#togglebutton-10", null], 1008 [ 1009 "Toggle button with aria-labelled by a visible <label>", 1010 "#togglebutton-11", 1011 null, 1012 ], 1013 [ 1014 "Aria toggle button nested inside a label", 1015 "#togglebutton-12", 1016 { score: FAIL, issue: INTERACTIVE_NO_NAME }, 1017 ], 1018 [ 1019 "Aria toggle button with aria-labelled by and nested inside a label", 1020 "#togglebutton-13", 1021 null, 1022 ], 1023 [ 1024 "Aria toggle button with no name", 1025 "#togglebutton-14", 1026 { score: FAIL, issue: INTERACTIVE_NO_NAME }, 1027 ], 1028 ["Aria toggle button with aria-label", "#togglebutton-15", null], 1029 [ 1030 "Aria toggle button with unrelated <label>", 1031 "#togglebutton-16", 1032 { score: FAIL, issue: INTERACTIVE_NO_NAME }, 1033 ], 1034 [ 1035 "Aria toggle button with <label>", 1036 "#togglebutton-17", 1037 { score: FAIL, issue: INTERACTIVE_NO_NAME }, 1038 ], 1039 [ 1040 "Aria toggle button with aria-labelledby a visible <label>", 1041 "#togglebutton-18", 1042 null, 1043 ], 1044 ["Non-unique aria toolbar with aria-label", "#toolbar-1", null], 1045 [ 1046 "Non-unique aria toolbar with no name (", 1047 "#toolbar-2", 1048 { score: FAIL, issue: TOOLBAR_NO_NAME }, 1049 ], 1050 [ 1051 "Non-unique aAria toolbar with aria-labelledby an element with empty content", 1052 "#toolbar-3", 1053 { score: FAIL, issue: TOOLBAR_NO_NAME }, 1054 ], 1055 ["Non-unique aria toolbar with aria-labelledby", "#toolbar-4", null], 1056 ["SVGElement with role=img that has a title", "#svg-1", null], 1057 ["SVGElement without role=img that has a title", "#svg-2", null], 1058 [ 1059 "SVGElement with role=img and no name", 1060 "#svg-3", 1061 { score: FAIL, issue: IMAGE_NO_NAME }, 1062 ], 1063 [ 1064 "SVGElement with no name", 1065 "#svg-4", 1066 { score: FAIL, issue: IMAGE_NO_NAME }, 1067 ], 1068 ["SVGElement with a name", "#svg-5", null], 1069 [ 1070 "SVGElement with a name and with ownerSVGElement with a name", 1071 "#svg-6", 1072 null, 1073 ], 1074 ["SVGElement with a title", "#svg-7", null], 1075 [ 1076 "SVGElement with a name and with ownerSVGElement with a title", 1077 "#svg-8", 1078 null, 1079 ], 1080 ["SVGElement with role=img that has a title", "#svg-9", null], 1081 [ 1082 "SVGElement with a name and with ownerSVGElement with role=img that has a title", 1083 "#svg-10", 1084 null, 1085 ], 1086 [ 1087 "SVGElement with role=img and no title", 1088 "#svg-11", 1089 { score: FAIL, issue: IMAGE_NO_NAME }, 1090 ], 1091 [ 1092 "SVGElement with a name and with ownerSVGElement with role=img and no title", 1093 "#svg-12", 1094 null, 1095 ], 1096 ]; 1097 1098 for (const [description, selector, expected] of tests) { 1099 info(description); 1100 const node = await walker.querySelector(walker.rootNode, selector); 1101 const front = await a11yWalker.getAccessibleFor(node); 1102 const audit = await front.audit({ types: [TEXT_LABEL] }); 1103 Assert.deepEqual( 1104 audit[TEXT_LABEL], 1105 expected, 1106 `Audit result for ${selector} is correct.` 1107 ); 1108 } 1109 1110 info("Test document rule:"); 1111 const front = await a11yWalker.getAccessibleFor(walker.rootNode); 1112 let audit = await front.audit({ types: [TEXT_LABEL] }); 1113 info("Document with no title"); 1114 Assert.deepEqual( 1115 audit[TEXT_LABEL], 1116 { score: FAIL, issue: DOCUMENT_NO_TITLE }, 1117 "Audit result for document is correct." 1118 ); 1119 1120 await SpecialPowers.spawn(gBrowser.selectedBrowser, [], () => { 1121 content.document.title = "Hello world"; 1122 }); 1123 audit = await front.audit({ types: [TEXT_LABEL] }); 1124 info("Document with title"); 1125 Assert.deepEqual( 1126 audit[TEXT_LABEL], 1127 null, 1128 "Audit result for document is correct." 1129 ); 1130 1131 await waitForA11yShutdown(parentAccessibility); 1132 await target.destroy(); 1133 gBrowser.removeCurrentTab(); 1134 });