4 <script src=
"../resources/js-test.js"></script>
7 <label id=
"nothing1">Nothing
</label>
8 <label id=
"text_label1">
10 <input id=
"text1" type=
"text">
12 <label id=
"check_label1">
14 <input id=
"check1" type=
"checkbox">
16 <label id=
"radio_label1">
18 <input id=
"radio1" type=
"radio">
20 <label id=
"slider_label1">
22 <input id=
"slider1" type=
"range">
24 <label id=
"list_label1">
26 <select id=
"list1"><option>1</option></select>
28 <label id=
"label_for1" for=
"text_for1">Text with label for
</label>
29 <input id=
"text_for1" type=
"text">
32 <canvas id=
"myCanvas" width=
"300" height=
"300">
33 <label id=
"nothing2">Nothing
</label>
34 <label id=
"text_label2">
36 <input id=
"text2" type=
"text">
38 <label id=
"check_label2">
40 <input id=
"check2" type=
"checkbox">
42 <label id=
"radio_label2">
44 <input id=
"radio2" type=
"radio">
46 <label id=
"slider_label2">
48 <input id=
"slider2" type=
"range">
50 <label id=
"list_label2">
52 <select id=
"list2"><option>1</option></select>
54 <label id=
"label_for2" for=
"text_for2">Text with label for
</label>
55 <input id=
"text_for2" type=
"text">
58 <div id=
"console"></div>
60 description("This tests that labels and elements with labels in canvas fallback content have the same accessibility properties as those same elements outside of a canvas.");
62 if (window
.testRunner
&& window
.accessibilityController
) {
63 window
.testRunner
.dumpAsText();
65 window
.collapseWhitespace = function(str
) {
66 return str
.replace(/\s+/g, ' ').replace(/^\s+|\s+$/g, '');
69 // Given the ids of two elements, one inside canvas fallback content and one outside,
70 // make sure their accessibility properties are the same, checking primarily properties
71 // that affect label elements and controls with labels. It's also okay if an element is
72 // missing from the tree as long as it's missing from both (like when a label is ignored).
73 function check(id1
, id2
) {
74 debug("Checking accessibility properties for ids: " + id1
+ ", " + id2
);
75 window
.axElement1
= accessibilityController
.accessibleElementById(id1
);
76 window
.axElement2
= accessibilityController
.accessibleElementById(id2
);
78 if (axElement1
== null && axElement2
== null) {
79 shouldBe("axElement1 == null && axElement2 == null", "true");
83 shouldBe("axElement2.role", "axElement1.role");
84 shouldBe("collapseWhitespace(axElement2.deprecatedTitle)", "collapseWhitespace(axElement1.deprecatedTitle)");
85 shouldBe("axElement2.deprecatedTitleUIElement", "axElement1.deprecatedTitleUIElement");
89 check("nothing1", "nothing2");
90 check("text_label1", "text_label2");
91 check("text1", "text2");
92 check("check_label1", "check_label2");
93 check("check1", "check2");
94 check("radio_label1", "radio_label2");
95 check("radio1", "radio2");
96 check("slider_label1", "slider_label2");
97 check("slider1", "slider2");
98 check("list_label1", "list_label2");
99 check("list1", "list2");
100 check("label_for1", "label_for2");
101 check("text_for1", "text_for2");