accessible/tests/mochitest/states/test_selects.html

changeset 0
6474c204b198
equal deleted inserted replaced
-1:000000000000 0:5a97c224c2e9
1 <html>
2
3 <head>
4 <title>HTML selects accessible states tests</title>
5 <link rel="stylesheet" type="text/css"
6 href="chrome://mochikit/content/tests/SimpleTest/test.css" />
7
8 <script type="application/javascript"
9 src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
10 <script type="application/javascript"
11 src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"></script>
12
13 <script type="application/javascript"
14 src="../common.js"></script>
15 <script type="application/javascript"
16 src="../role.js"></script>
17 <script type="application/javascript"
18 src="../states.js"></script>
19 <script type="application/javascript"
20 src="../events.js"></script>
21
22 <script type="application/javascript">
23 function openComboboxNCheckStates(aID)
24 {
25 this.combobox = getAccessible(aID);
26 this.comboboxList = this.combobox.firstChild;
27 this.comboboxOption = this.comboboxList.firstChild;
28
29 this.eventSeq = [
30 new invokerChecker(EVENT_FOCUS, this.comboboxOption)
31 ];
32
33 this.invoke = function openComboboxNCheckStates_invoke()
34 {
35 getNode(aID).focus();
36 synthesizeKey("VK_DOWN", { altKey: true });
37 }
38
39 this.finalCheck = function openComboboxNCheckStates_invoke()
40 {
41 // Expanded state on combobox.
42 testStates(this.combobox, STATE_EXPANDED);
43
44 // Floating state on combobox list.
45 testStates(this.comboboxList, STATE_FLOATING);
46 }
47
48 this.getID = function openComboboxNCheckStates_getID()
49 {
50 return "open combobox and test states";
51 }
52 }
53
54 //gA11yEventDumpToConsole = true;
55
56 var gQueue = null;
57 function doTest()
58 {
59 // combobox
60 var combobox = getAccessible("combobox");
61 testStates(combobox,
62 STATE_HASPOPUP | STATE_COLLAPSED | STATE_FOCUSABLE, 0,
63 STATE_FOCUSED, 0);
64
65 var comboboxList = combobox.firstChild;
66 testStates(comboboxList, STATE_INVISIBLE, 0, STATE_FOCUSABLE, 0);
67
68 var opt1 = comboboxList.firstChild;
69 testStates(opt1, STATE_SELECTABLE | STATE_SELECTED | STATE_FOCUSABLE,
70 EXT_STATE_ACTIVE, STATE_FOCUSED, 0);
71
72 var opt2 = comboboxList.lastChild;
73 testStates(opt2, STATE_SELECTABLE | STATE_FOCUSABLE, 0, STATE_SELECTED, 0,
74 STATE_FOCUSED, EXT_STATE_ACTIVE);
75
76 // collapsed combobox
77 testStates("collapsedcombobox",
78 STATE_COLLAPSED | STATE_FOCUSABLE, 0,
79 STATE_FOCUSED, 0);
80
81 testStates("collapsed-1",
82 STATE_FOCUSABLE | STATE_SELECTABLE, 0,
83 STATE_OFFSCREEN | STATE_INVISIBLE, 0);
84
85 testStates("collapsed-2",
86 STATE_OFFSCREEN, 0,
87 STATE_INVISIBLE, 0);
88
89 // listbox
90 testStates("listbox",
91 STATE_FOCUSABLE, 0,
92 STATE_HASPOPUP | STATE_COLLAPSED | STATE_FOCUSED);
93
94 testStates("listitem-active",
95 STATE_FOCUSABLE | STATE_SELECTABLE, EXT_STATE_ACTIVE,
96 STATE_SELECTED | STATE_FOCUSED);
97
98 testStates("listitem",
99 STATE_FOCUSABLE | STATE_SELECTABLE, 0,
100 STATE_SELECTED | STATE_FOCUSED, EXT_STATE_ACTIVE);
101
102 testStates("listitem-disabled",
103 STATE_UNAVAILABLE, 0,
104 STATE_SELECTABLE | STATE_SELECTED | STATE_FOCUSABLE,
105 EXT_STATE_ACTIVE);
106
107 testStates("listgroup",
108 0, 0,
109 STATE_UNAVAILABLE | STATE_SELECTABLE | STATE_SELECTED | STATE_FOCUSABLE,
110 EXT_STATE_ACTIVE);
111
112 testStates("listgroup-disabled",
113 STATE_UNAVAILABLE, 0,
114 STATE_SELECTABLE | STATE_SELECTED | STATE_FOCUSABLE,
115 EXT_STATE_ACTIVE);
116
117 todo(false, "no unavailable state on option in disabled group (bug 759666)");
118 // testStates("listitem-disabledgroup",
119 // STATE_UNAVAILABLE, 0,
120 // STATE_SELECTABLE | STATE_SELECTED | STATE_FOCUSABLE,
121 // EXT_STATE_ACTIVE);
122
123 testStates("listbox-disabled",
124 STATE_UNAVAILABLE, 0,
125 STATE_FOCUSABLE);
126
127 todo(false, "no unavailable state on option in disabled select (bug 759666)");
128 // testStates("listitem-disabledlistbox",
129 // STATE_UNAVAILABLE, 0,
130 // STATE_SELECTABLE | STATE_SELECTED | STATE_FOCUSABLE,
131 // EXT_STATE_ACTIVE);
132
133 // open combobox
134 gQueue = new eventQueue();
135 gQueue.push(new openComboboxNCheckStates("combobox"));
136 gQueue.invoke(); // Will call */SimpleTest.finish();
137 }
138
139 SimpleTest.waitForExplicitFinish();
140 addA11yLoadEvent(doTest);
141 </script>
142
143 </head>
144
145 <body>
146 <a target="_blank"
147 href="https://bugzilla.mozilla.org/show_bug.cgi?id=443889"
148 title="mochitest for selects and lists">
149 Mozilla Bug 443889
150 </a>
151 <a target="_blank"
152 href="https://bugzilla.mozilla.org/show_bug.cgi?id=640716"
153 title="mochitest for selects and lists">
154 Mozilla Bug 640716
155 </a>
156 <a target="_blank"
157 href="https://bugzilla.mozilla.org/show_bug.cgi?id=689847"
158 title="Expose active state on current item of selectable widgets">
159 Mozilla Bug 689847
160 </a>
161 <a target="_blank"
162 href="https://bugzilla.mozilla.org/show_bug.cgi?id=756983"
163 title="Isolate focusable and unavailable states from State()">
164 Mozilla Bug 756983
165 </a>
166 <a target="_blank"
167 href="https://bugzilla.mozilla.org/show_bug.cgi?id=907682"
168 title=" HTML:option group position is not correct when select is collapsed">
169 Mozilla Bug 907682
170 </a>
171 <p id="display"></p>
172 <div id="content" style="display: none"></div>
173 <pre id="test">
174 </pre>
175
176 <select id="combobox">
177 <option>item 1</option>
178 <option>item 2</option>
179 </select>
180
181 <select id="collapsedcombobox">
182 <option id="collapsed-1">item 1</option>
183 <option id="collapsed-2">item 2</option>
184 </select>
185
186 <select id="listbox" name="component" size="3">
187 <option id="listitem-active">Build</option>
188 <option id="listitem">Disability Access APIs</option>
189 <option id="listitem-disabled" disabled>General</option>
190 <optgroup id="listgroup" label="group">
191 <option>option</option>
192 </optgroup>
193 <optgroup id="listgroup-disabled" disabled label="group2">
194 <option id="listitem-disabledgroup">UI</option>
195 </optgroup>
196 </select>
197
198 <select id="listbox-disabled" size="3" disabled>
199 <option id="listitem-disabledlistbox">option</option>
200 </select>
201
202 </body>
203 </html>

mercurial