n_wang@apple.com | 7e33a43 | 2016-04-30 18:06:47 +0000 | [diff] [blame] | 1 | <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN"> |
| 2 | <html> |
| 3 | <head> |
jdiggs@igalia.com | da78ad8 | 2018-03-16 21:01:25 +0000 | [diff] [blame] | 4 | <script src="../resources/js-test-pre.js"></script> |
n_wang@apple.com | 7e33a43 | 2016-04-30 18:06:47 +0000 | [diff] [blame] | 5 | </head> |
| 6 | <body id="body"> |
| 7 | |
jdiggs@igalia.com | da78ad8 | 2018-03-16 21:01:25 +0000 | [diff] [blame] | 8 | <label id="label1" for="input" aria-label="aria label">Some text</label> |
n_wang@apple.com | 7e33a43 | 2016-04-30 18:06:47 +0000 | [diff] [blame] | 9 | <input id="input" type="text" size=20> |
| 10 | |
| 11 | <label id="label2" for="input2">Some other text</label> |
| 12 | <input id="input2" type="text" size=20> |
| 13 | |
n_wang@apple.com | fbdeb37 | 2016-05-02 06:14:36 +0000 | [diff] [blame] | 14 | <label id="label3" for="input3" hidden aria-label="hidden aria label">hidden text</label> |
| 15 | <input id="input3" type="text"> |
| 16 | |
n_wang@apple.com | d4ad024 | 2016-09-29 15:13:00 +0000 | [diff] [blame] | 17 | <p id="p1">aria</p> |
| 18 | <p id="p2">labelledby</p> |
| 19 | <label for="input4" aria-labelledby="p1 p2">Some text</label> |
| 20 | <input id="input4" type="text" size=20> |
| 21 | |
n_wang@apple.com | 7e33a43 | 2016-04-30 18:06:47 +0000 | [diff] [blame] | 22 | <p id="description"></p> |
| 23 | <div id="console"></div> |
| 24 | |
| 25 | <script> |
| 26 | |
| 27 | description("This tests that the aria-label attribute works on <label> element."); |
| 28 | |
| 29 | if (window.accessibilityController) { |
| 30 | |
| 31 | // aria-label on the <label> element return a title for the input, instead of a title ui element. |
jdiggs@igalia.com | da78ad8 | 2018-03-16 21:01:25 +0000 | [diff] [blame] | 32 | // For ATK, it should return both, with the title ui element being the label element. |
n_wang@apple.com | 7e33a43 | 2016-04-30 18:06:47 +0000 | [diff] [blame] | 33 | var input1 = accessibilityController.accessibleElementById("input"); |
| 34 | var titleUIElement1 = input1.titleUIElement(); |
jdiggs@igalia.com | da78ad8 | 2018-03-16 21:01:25 +0000 | [diff] [blame] | 35 | if (accessibilityController.platformName != "atk") |
| 36 | shouldBeTrue("!titleUIElement1"); |
| 37 | else |
| 38 | shouldBeTrue("titleUIElement1.isEqual(accessibilityController.accessibleElementById('label1'))"); |
| 39 | |
n_wang@apple.com | 7e33a43 | 2016-04-30 18:06:47 +0000 | [diff] [blame] | 40 | shouldBe("input1.title", "'AXTitle: aria label'"); |
| 41 | |
| 42 | // Normal case. |
| 43 | var input2 = accessibilityController.accessibleElementById("input2"); |
| 44 | var titleUIElement2 = input2.titleUIElement(); |
| 45 | shouldBeTrue("titleUIElement2.isEqual(accessibilityController.accessibleElementById('label2'))"); |
n_wang@apple.com | fbdeb37 | 2016-05-02 06:14:36 +0000 | [diff] [blame] | 46 | |
| 47 | // Make sure when the input element has no rendered label, it won't cause crash. |
| 48 | var input3 = accessibilityController.accessibleElementById("input3"); |
| 49 | shouldBe("input3.title", "'AXTitle: hidden aria label'"); |
n_wang@apple.com | d4ad024 | 2016-09-29 15:13:00 +0000 | [diff] [blame] | 50 | |
| 51 | // aria-labelledby also works. |
| 52 | var input4 = accessibilityController.accessibleElementById("input4"); |
| 53 | shouldBe("input4.title", "'AXTitle: aria labelledby'"); |
n_wang@apple.com | 7e33a43 | 2016-04-30 18:06:47 +0000 | [diff] [blame] | 54 | } |
| 55 | |
| 56 | </script> |
| 57 | |
jdiggs@igalia.com | da78ad8 | 2018-03-16 21:01:25 +0000 | [diff] [blame] | 58 | <script src="../resources/js-test-post.js"></script> |
n_wang@apple.com | 7e33a43 | 2016-04-30 18:06:47 +0000 | [diff] [blame] | 59 | </body> |
| 60 | </html> |