|
1 <html> |
|
2 |
|
3 <head> |
|
4 <title>nsIAccessibleSelectable HTML select testing</title> |
|
5 |
|
6 <link rel="stylesheet" type="text/css" |
|
7 href="chrome://mochikit/content/tests/SimpleTest/test.css" /> |
|
8 |
|
9 </style> |
|
10 |
|
11 <script type="application/javascript" |
|
12 src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script> |
|
13 |
|
14 <script type="application/javascript" |
|
15 src="../common.js"></script> |
|
16 <script type="application/javascript" |
|
17 src="../role.js"></script> |
|
18 <script type="application/javascript" |
|
19 src="../states.js"></script> |
|
20 <script type="application/javascript" |
|
21 src="../selectable.js"></script> |
|
22 |
|
23 <script type="application/javascript"> |
|
24 |
|
25 function doTest() |
|
26 { |
|
27 ////////////////////////////////////////////////////////////////////////// |
|
28 // select@size="1" aka combobox |
|
29 |
|
30 var id = "combobox"; |
|
31 var combobox = getAccessible(id); |
|
32 var comboboxList = combobox.firstChild; |
|
33 ok(isAccessible(comboboxList, [nsIAccessibleSelectable]), |
|
34 "No selectable accessible for list of " + id); |
|
35 |
|
36 var select = getAccessible(comboboxList, [nsIAccessibleSelectable]); |
|
37 testSelectableSelection(select, [ "cb1_item1" ]); |
|
38 |
|
39 // select 2nd item |
|
40 select.addItemToSelection(1); |
|
41 testSelectableSelection(select, [ "cb1_item2" ], "addItemToSelection(1): "); |
|
42 |
|
43 // unselect 2nd item, 1st item gets selected automatically |
|
44 select.removeItemFromSelection(1); |
|
45 testSelectableSelection(select, [ "cb1_item1" ], |
|
46 "removeItemFromSelection(1): "); |
|
47 |
|
48 // doesn't change selection |
|
49 is(select.selectAll(), false, |
|
50 "No way to select all items in combobox '" + id + "'"); |
|
51 testSelectableSelection(select, [ "cb1_item1" ], "selectAll: "); |
|
52 |
|
53 // doesn't change selection |
|
54 select.unselectAll(); |
|
55 testSelectableSelection(select, [ "cb1_item1" ], "unselectAll: "); |
|
56 |
|
57 ////////////////////////////////////////////////////////////////////////// |
|
58 // select@size="1" with optgroups |
|
59 |
|
60 id = "combobox2"; |
|
61 combobox = getAccessible(id); |
|
62 comboboxList = combobox.firstChild; |
|
63 ok(isAccessible(comboboxList, [nsIAccessibleSelectable]), |
|
64 "No selectable accessible for list of " + id); |
|
65 |
|
66 select = getAccessible(comboboxList, [nsIAccessibleSelectable]); |
|
67 testSelectableSelection(select, [ "cb2_item1" ]); |
|
68 |
|
69 select.addItemToSelection(1); |
|
70 testSelectableSelection(select, [ "cb2_item2" ]); |
|
71 |
|
72 select.removeItemFromSelection(1); |
|
73 testSelectableSelection(select, [ "cb2_item1" ]); |
|
74 |
|
75 is(select.selectAll(), false, |
|
76 "No way to select all items in combobox " + id + "'"); |
|
77 testSelectableSelection(select, [ "cb2_item1" ]); |
|
78 |
|
79 select.unselectAll(); |
|
80 testSelectableSelection(select, [ "cb2_item1" ]); |
|
81 |
|
82 ////////////////////////////////////////////////////////////////////////// |
|
83 // select@size="4" aka single selectable listbox |
|
84 |
|
85 var id = "listbox"; |
|
86 ok(isAccessible(id, [nsIAccessibleSelectable]), |
|
87 "No selectable accessible for " + id); |
|
88 |
|
89 select = getAccessible(id, [nsIAccessibleSelectable]); |
|
90 testSelectableSelection(select, [ ]); |
|
91 |
|
92 // select 2nd item |
|
93 select.addItemToSelection(1); |
|
94 testSelectableSelection(select, [ "lb1_item2" ], "addItemToSelection(1): "); |
|
95 |
|
96 // unselect 2nd item, 1st item gets selected automatically |
|
97 select.removeItemFromSelection(1); |
|
98 testSelectableSelection(select, [ ], |
|
99 "removeItemFromSelection(1): "); |
|
100 |
|
101 // doesn't change selection |
|
102 is(select.selectAll(), false, |
|
103 "No way to select all items in single selectable listbox '" + id + "'"); |
|
104 testSelectableSelection(select, [ ], "selectAll: "); |
|
105 |
|
106 // doesn't change selection |
|
107 select.unselectAll(); |
|
108 testSelectableSelection(select, [ ], "unselectAll: "); |
|
109 |
|
110 ////////////////////////////////////////////////////////////////////////// |
|
111 // select@size="4" with optgroups, single selectable |
|
112 |
|
113 id = "listbox2"; |
|
114 ok(isAccessible(id, [nsIAccessibleSelectable]), |
|
115 "No selectable accessible for " + id); |
|
116 |
|
117 select = getAccessible(id, [nsIAccessibleSelectable]); |
|
118 testSelectableSelection(select, [ ]); |
|
119 |
|
120 select.addItemToSelection(1); |
|
121 testSelectableSelection(select, [ "lb2_item2" ]); |
|
122 |
|
123 select.removeItemFromSelection(1); |
|
124 testSelectableSelection(select, [ ]); |
|
125 |
|
126 is(select.selectAll(), false, |
|
127 "No way to select all items in single selectable listbox " + id + "'"); |
|
128 testSelectableSelection(select, [ ]); |
|
129 |
|
130 select.unselectAll(); |
|
131 testSelectableSelection(select, [ ]); |
|
132 |
|
133 ////////////////////////////////////////////////////////////////////////// |
|
134 // select@size="4" multiselect aka listbox |
|
135 |
|
136 id = "listbox3"; |
|
137 ok(isAccessible(id, [nsIAccessibleSelectable]), |
|
138 "No selectable accessible for " + id); |
|
139 |
|
140 select = getAccessible(id, [nsIAccessibleSelectable]); |
|
141 testSelectableSelection(select, [ ]); |
|
142 |
|
143 select.addItemToSelection(0); |
|
144 testSelectableSelection(select, [ "lb3_item1" ], "addItemToSelection: "); |
|
145 |
|
146 select.removeItemFromSelection(0); |
|
147 testSelectableSelection(select, [ ], "removeItemFromSelection: "); |
|
148 |
|
149 is(select.selectAll(), true, |
|
150 "All items in listbox '" + id + "' should be selected"); |
|
151 testSelectableSelection(select, [ "lb3_item1", "lb3_item2"], |
|
152 "selectAll: "); |
|
153 |
|
154 select.unselectAll(); |
|
155 testSelectableSelection(select, [ ], "unselectAll: "); |
|
156 |
|
157 ////////////////////////////////////////////////////////////////////////// |
|
158 // select@size="4" multiselect with optgroups |
|
159 |
|
160 var id = "listbox4"; |
|
161 ok(isAccessible(id, [nsIAccessibleSelectable]), |
|
162 "No selectable accessible for " + id); |
|
163 |
|
164 select = getAccessible(id, [nsIAccessibleSelectable]); |
|
165 testSelectableSelection(select, [ ]); |
|
166 |
|
167 select.addItemToSelection(0); |
|
168 testSelectableSelection(select, [ "lb4_item1" ]); |
|
169 |
|
170 select.removeItemFromSelection(0); |
|
171 testSelectableSelection(select, [ ]); |
|
172 |
|
173 is(select.selectAll(), true, |
|
174 "All items in listbox '" + id + "' should be selected"); |
|
175 testSelectableSelection(select, [ "lb4_item1", "lb4_item2"]); |
|
176 |
|
177 select.unselectAll(); |
|
178 testSelectableSelection(select, [ ]); |
|
179 |
|
180 SimpleTest.finish(); |
|
181 } |
|
182 |
|
183 SimpleTest.waitForExplicitFinish(); |
|
184 addA11yLoadEvent(doTest); |
|
185 </script> |
|
186 |
|
187 </head> |
|
188 |
|
189 <body> |
|
190 |
|
191 <a target="_blank" |
|
192 href="https://bugzilla.mozilla.org/show_bug.cgi?id=530014" |
|
193 title="ARIA single selectable widget should implement nsIAccessibleSelectable"> |
|
194 Mozilla Bug 530014 |
|
195 </a><br> |
|
196 <a target="_blank" |
|
197 href="https://bugzilla.mozilla.org/show_bug.cgi?id=590176" |
|
198 title="add pseudo SelectAccessible interface"> |
|
199 Mozilla Bug 590176 |
|
200 </a><br> |
|
201 <p id="display"></p> |
|
202 <div id="content" style="display: none"></div> |
|
203 <pre id="test"> |
|
204 </pre> |
|
205 |
|
206 <select id="combobox"> |
|
207 <option id="cb1_item1">option1</option> |
|
208 <option id="cb1_item2">option2</option> |
|
209 </select> |
|
210 |
|
211 <select id="combobox2"> |
|
212 <option id="cb2_item1">option1</option> |
|
213 <optgroup>optgroup |
|
214 <option id="cb2_item2">option2</option> |
|
215 </optgroup> |
|
216 </select> |
|
217 |
|
218 <select id="listbox" size="4"> |
|
219 <option id="lb1_item1">option1</option> |
|
220 <option id="lb1_item2">option2</option> |
|
221 </select> |
|
222 |
|
223 <select id="listbox2" size="4"> |
|
224 <option id="lb2_item1">option1</option> |
|
225 <optgroup>optgroup> |
|
226 <option id="lb2_item2">option2</option> |
|
227 </optgroup> |
|
228 </select> |
|
229 |
|
230 <select id="listbox3" size="4" multiple="true"> |
|
231 <option id="lb3_item1">option1</option> |
|
232 <option id="lb3_item2">option2</option> |
|
233 </select> |
|
234 |
|
235 <select id="listbox4" size="4" multiple="true"> |
|
236 <option id="lb4_item1">option1</option> |
|
237 <optgroup>optgroup> |
|
238 <option id="lb4_item2">option2</option> |
|
239 </optgroup> |
|
240 </select> |
|
241 |
|
242 </body> |
|
243 </html> |