blob: 38215a0fe3b4060688b5d32db7570bc8228637f5 [file] [log] [blame]
n_wang@apple.com7e33a432016-04-30 18:06:47 +00001<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
2<html>
3<head>
jdiggs@igalia.comda78ad82018-03-16 21:01:25 +00004<script src="../resources/js-test-pre.js"></script>
n_wang@apple.com7e33a432016-04-30 18:06:47 +00005</head>
6<body id="body">
7
jdiggs@igalia.comda78ad82018-03-16 21:01:25 +00008<label id="label1" for="input" aria-label="aria label">Some text</label>
n_wang@apple.com7e33a432016-04-30 18:06:47 +00009<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.comfbdeb372016-05-02 06:14:36 +000014<label id="label3" for="input3" hidden aria-label="hidden aria label">hidden text</label>
15<input id="input3" type="text">
16
n_wang@apple.comd4ad0242016-09-29 15:13:00 +000017<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.com7e33a432016-04-30 18:06:47 +000022<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.comda78ad82018-03-16 21:01:25 +000032 // For ATK, it should return both, with the title ui element being the label element.
n_wang@apple.com7e33a432016-04-30 18:06:47 +000033 var input1 = accessibilityController.accessibleElementById("input");
34 var titleUIElement1 = input1.titleUIElement();
jdiggs@igalia.comda78ad82018-03-16 21:01:25 +000035 if (accessibilityController.platformName != "atk")
36 shouldBeTrue("!titleUIElement1");
37 else
38 shouldBeTrue("titleUIElement1.isEqual(accessibilityController.accessibleElementById('label1'))");
39
n_wang@apple.com7e33a432016-04-30 18:06:47 +000040 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.comfbdeb372016-05-02 06:14:36 +000046
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.comd4ad0242016-09-29 15:13:00 +000050
51 // aria-labelledby also works.
52 var input4 = accessibilityController.accessibleElementById("input4");
53 shouldBe("input4.title", "'AXTitle: aria labelledby'");
n_wang@apple.com7e33a432016-04-30 18:06:47 +000054 }
55
56</script>
57
jdiggs@igalia.comda78ad82018-03-16 21:01:25 +000058<script src="../resources/js-test-post.js"></script>
n_wang@apple.com7e33a432016-04-30 18:06:47 +000059</body>
60</html>