accessible/tests/mochitest/relations/test_general.xul

changeset 0
6474c204b198
equal deleted inserted replaced
-1:000000000000 0:c5f1b5497669
1 <?xml version="1.0"?>
2 <?xml-stylesheet href="chrome://global/skin" type="text/css"?>
3 <?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css"
4 type="text/css"?>
5
6 <window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
7 title="nsIAccessible::getAccessibleRelated() tests">
8
9 <script type="application/javascript"
10 src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js" />
11
12 <script type="application/javascript"
13 src="../common.js" />
14 <script type="application/javascript"
15 src="../relations.js" />
16 <script type="application/javascript"
17 src="../role.js" />
18
19 <script type="application/javascript">
20 <![CDATA[
21 function doTest()
22 {
23 // xul:label@control
24 testRelation("label1", RELATION_LABEL_FOR, "checkbox1");
25 testRelation("checkbox1", RELATION_LABELLED_BY, "label1");
26
27 // xul:label@control, multiple
28 testRelation("label1_1", RELATION_LABEL_FOR, "checkbox1_1");
29 testRelation("label1_2", RELATION_LABEL_FOR, "checkbox1_1");
30 testRelation("checkbox1_1", RELATION_LABELLED_BY,
31 [ "label1_1", "label1_2" ]);
32
33 // aria-labelledby
34 testRelation("label2", RELATION_LABEL_FOR, "checkbox2");
35 testRelation("checkbox2", RELATION_LABELLED_BY, "label2");
36
37 // aria-labelledby, multiple relations
38 testRelation("label3", RELATION_LABEL_FOR, "checkbox3");
39 testRelation("label4", RELATION_LABEL_FOR, "checkbox3");
40 testRelation("checkbox3", RELATION_LABELLED_BY, ["label3", "label4"]);
41
42 // aria-describedby
43 testRelation("descr1", RELATION_DESCRIPTION_FOR, "checkbox4");
44 testRelation("checkbox4", RELATION_DESCRIBED_BY, "descr1");
45
46 // aria-describedby, multiple relations
47 testRelation("descr2", RELATION_DESCRIPTION_FOR, "checkbox5");
48 testRelation("descr3", RELATION_DESCRIPTION_FOR, "checkbox5");
49 testRelation("checkbox5", RELATION_DESCRIBED_BY, ["descr2", "descr3"]);
50
51 // xul:description@control
52 testRelation("descr4", RELATION_DESCRIPTION_FOR, "checkbox6");
53 testRelation("checkbox6", RELATION_DESCRIBED_BY, "descr4");
54
55 // xul:description@control, multiple
56 testRelation("descr5", RELATION_DESCRIPTION_FOR, "checkbox7");
57 testRelation("descr6", RELATION_DESCRIPTION_FOR, "checkbox7");
58 testRelation("checkbox7", RELATION_DESCRIBED_BY,
59 [ "descr5", "descr6" ]);
60
61 // aria_owns, multiple relations
62 testRelation("treeitem1", RELATION_NODE_CHILD_OF, "tree");
63 testRelation("treeitem2", RELATION_NODE_CHILD_OF, "tree");
64
65 // 'node child of' relation for outlineitem role
66 testRelation("treeitem3", RELATION_NODE_CHILD_OF, "tree");
67 testRelation("treeitem4", RELATION_NODE_CHILD_OF, "tree");
68 testRelation("treeitem5", RELATION_NODE_CHILD_OF, "treeitem4");
69
70 // no relation node_child_of for accessible contained in an unexpected
71 // parent
72 testRelation("treeitem6", RELATION_NODE_CHILD_OF, null);
73
74 // 'node child of' relation for the document having window, returns
75 // direct accessible parent (fixed in bug 419770).
76 var iframeElmObj = {};
77 var iframeAcc = getAccessible("iframe", null, iframeElmObj);
78 var iframeDoc = iframeElmObj.value.contentDocument;
79 var iframeDocAcc = getAccessible(iframeDoc);
80 testRelation(iframeDocAcc, RELATION_NODE_CHILD_OF, iframeAcc);
81
82 // aria-controls
83 getAccessible("tab");
84 todo(false,
85 "Getting an accessible tab, otherwise relations for tabpanel aren't cached. Bug 606924 will fix that.");
86 testRelation("tabpanel", RELATION_CONTROLLED_BY, "tab");
87 testRelation("tab", RELATION_CONTROLLER_FOR, "tabpanel");
88
89 // aria-controls, multiple relations
90 testRelation("lr1", RELATION_CONTROLLED_BY, "button");
91 testRelation("lr2", RELATION_CONTROLLED_BY, "button");
92 testRelation("button", RELATION_CONTROLLER_FOR, ["lr1", "lr2"]);
93
94 // aria-flowto
95 testRelation("flowto", RELATION_FLOWS_TO, "flowfrom");
96 testRelation("flowfrom", RELATION_FLOWS_FROM, "flowto");
97
98 // aria-flowto, multiple relations
99 testRelation("flowto1", RELATION_FLOWS_TO, ["flowfrom1", "flowfrom2"]);
100 testRelation("flowfrom1", RELATION_FLOWS_FROM, "flowto1");
101 testRelation("flowfrom2", RELATION_FLOWS_FROM, "flowto1");
102
103 // 'default button' relation
104 testRelation("textbox", RELATION_DEFAULT_BUTTON, "submit");
105
106 // 'labelled by'/'label for' relation for xul:goupbox and xul:label of
107 // xul:caption
108 var groupboxAcc = getAccessible("groupbox");
109 var labelAcc = groupboxAcc.firstChild;
110 testRelation(labelAcc, RELATION_LABEL_FOR, groupboxAcc);
111 testRelation(groupboxAcc, RELATION_LABELLED_BY, labelAcc);
112
113 // 'labelled by'/'label for' relations for xul:tab and xul:tabpanel
114 // (fixed in bug 366527)
115 testRelation("tabpanel1", RELATION_LABELLED_BY, "tab1");
116 testRelation("tab1", RELATION_LABEL_FOR, "tabpanel1");
117 testRelation("tabpanel2", RELATION_LABELLED_BY, "tab2");
118 testRelation("tab2", RELATION_LABEL_FOR, "tabpanel2");
119 testRelation("tabpanel3", RELATION_LABELLED_BY, "tab3");
120 testRelation("tab3", RELATION_LABEL_FOR, "tabpanel3");
121
122 // finish test
123 SimpleTest.finish();
124 }
125
126 SimpleTest.waitForExplicitFinish();
127 addA11yLoadEvent(doTest);
128 ]]>
129 </script>
130
131 <vbox style="overflow: auto;" flex="1">
132 <body xmlns="http://www.w3.org/1999/xhtml">
133 <a target="_blank"
134 href="https://bugzilla.mozilla.org/show_bug.cgi?id=475298"
135 title="mochitests for accessible relations">
136 Mozilla Bug 475298
137 </a><br/>
138 <a target="_blank"
139 href="https://bugzilla.mozilla.org/show_bug.cgi?id=673389"
140 title="node_child_of on an item not in a proper container">
141 Mozilla Bug 67389
142 </a><br/>
143
144 <p id="display"></p>
145 <div id="content" style="display: none">
146 </div>
147 <pre id="test">
148 </pre>
149 </body>
150
151 <label id="label1" control="checkbox1">label</label>
152 <checkbox id="checkbox1"/>
153
154 <label id="label1_1" control="checkbox1_1">label</label>
155 <label id="label1_2" control="checkbox1_1">label</label>
156 <checkbox id="checkbox1_1"/>
157
158 <description id="label2">label</description>
159 <description role="checkbox" id="checkbox2" aria-labelledby="label2"/>
160
161 <description id="label3">label</description>
162 <description id="label4">label</description>
163 <description role="checkbox" id="checkbox3"
164 aria-labelledby="label3 label4"/>
165
166 <description id="descr1">description</description>
167 <description role="checkbox" id="checkbox4" aria-describedby="descr1"/>
168
169 <description id="descr2">label</description>
170 <description id="descr3">label</description>
171 <description role="checkbox" id="checkbox5"
172 aria-describedby="descr2 descr3"/>
173
174 <description id="descr4" control="checkbox6">description</description>
175 <checkbox id="checkbox6"/>
176
177 <description id="descr5" control="checkbox7">description</description>
178 <description id="descr6" control="checkbox7">description</description>
179 <checkbox id="checkbox7"/>
180
181 <description role="treeitem" id="treeitem1">Yellow</description>
182 <description role="treeitem" id="treeitem2">Orange</description>
183 <vbox id="tree" role="tree" aria-owns="treeitem1 treeitem2">
184 <description role="treeitem" id="treeitem3">Blue</description>
185 <description role="treeitem" id="treeitem4" aria-level="1">Green</description>
186 <description role="treeitem" id="treeitem5" aria-level="2">Light green</description>
187 </vbox>
188
189 <description role="treeitem" id="treeitem6">Dark green</description>
190
191 <iframe id="iframe"/>
192
193 <hbox id="tablist" role="tablist">
194 <description id="tab" role="tab" aria-controls="tabpanel">tab</description>
195 </hbox>
196 <description id="tabpanel" role="tabpanel">tabpanel</description>
197
198 <description id="lr1" aria-live="assertive">1</description>
199 <description id="lr2" aria-live="assertive">a</description>
200 <button id="button" aria-controls="lr1 lr2" label="button"
201 oncommand="getNode('lr1').textContent += '1'; getNode('lr2').textContent += 'a';"/>
202
203 <description id="flowto1" aria-flowto="flowfrom1 flowfrom2">flow to</description>
204 <description id="flowfrom1">flow from</description>
205 <description id="flowfrom2">flow from</description>
206
207 <description id="flowto" aria-flowto="flowfrom">flow to</description>
208 <description id="flowfrom">flow from</description>
209
210 <textbox id="textbox"/>
211 <button id="submit" default="true" label="Default"/>
212
213 <groupbox id="groupbox">
214 <caption label="caption"/>
215 </groupbox>
216
217 <tabbox>
218 <tabs>
219 <tab label="tab1" id="tab1"/>
220 <tab label="tab2" id="tab2" linkedpanel="tabpanel2"/>
221 <tab label="tab3" id="tab3" linkedpanel="tabpanel3"/>
222 </tabs>
223 <tabpanels>
224 <tabpanel id="tabpanel1">
225 <description>tabpanel1</description>
226 </tabpanel>
227 <tabpanel id="tabpanel3">
228 <description>tabpanel3</description>
229 </tabpanel>
230 <tabpanel id="tabpanel2">
231 <description>tabpanel2</description>
232 </tabpanel>
233 </tabpanels>
234 </tabbox>
235
236 </vbox>
237 </window>
238

mercurial