Debian Codegraph @

dijit/tests/robot/TooltipDialog_a11y.html

raw symbols SCIP
1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
2 "http://www.w3.org/TR/html4/strict.dtd">
3 <html>
4 <head>
5 <title>robot TooltipDialog A11y Test</title>
6
7 <style>
8 @import "../../../util/doh/robot/robot.css";
9 </style>
10
11 <!-- required: dojo.js -->
12 <script type="text/javascript" src="../../../dojo/dojo.js"
13 data-dojo-config="isDebug: true"></script>
14
15 <script type="text/javascript">
16 require([
17 "doh/runner", "dojo/robotx", "dojo/keys",
18 "dojo/domReady!"
19 ], function(doh, robot, keys){
20 robot.initRobot('../test_TooltipDialog.html');
21
22 doh.register(function setup(){
23 // get pointer to registry in the iframe
24 registry = robot.window.require("dijit/registry");
25 dfocus = robot.window.require("dijit/focus");
26 });
27
28 doh.register("TooltipDialog normal operation", [
29 {
30 name: "aria roles and attributes",
31 timeout: 5000,
32 button: null,
33 runTest: function(){
34 var d = new doh.Deferred();
35 button = registry.byId("tooltipDlgButton");
36
37 doh.is("button", button._popupStateNode.getAttribute("role"), "button _popupStateNode role");
38 doh.t(button._popupStateNode.getAttribute("aria-haspopup"), "aria-haspopup on button");
39 doh.is("tooltipDlgButton_label", button._popupStateNode.getAttribute("aria-labelledby"), "aria-labelledby");
40 doh.f(button._popupStateNode.getAttribute("aria-expanded"), "initially missing aria-expanded");
41 doh.f(button._popupStateNode.getAttribute("aria-owns"), "initally missing aria-owns");
42
43 // now open the drop down
44 robot.sequence(function(){
45 button.focus();
46 }, 500, 500);
47 robot.keyPress(keys.SPACE, 500, {});
48
49 robot.sequence(d.getTestCallback(function(){
50 doh.t(button._popupStateNode.getAttribute("aria-expanded"), "now aria-expanded should be true");
51 doh.is("tooltipDlg", button._popupStateNode.getAttribute("aria-owns"), "should aria-own the Dlg");
52
53 // Check roles and attributes on the dialog
54 var dlg = registry.byId("tooltipDlg");
55 doh.is("alertdialog", dlg.domNode.getAttribute("role"), "Dlg.domNode should have a role");
56 doh.is("tooltipDlgButton", dlg.domNode.getAttribute("aria-labelledby"), "aria-labelledby should point back to button");
57
58 var dd = dlg.domNode;
59 doh.is("region", dd.parentNode.getAttribute("role"), "TooltipDialog's wrapper needs role=region since the node gets appended to the end");
60 doh.is("tooltipDlg", dd.parentNode.getAttribute("aria-label"), "TooltipDialog's wrapper needs aria-label since role=region");
61 }), 1000);
62
63 return d;
64 },
65 tearDown: function(){
66 button.closeDropDown();
67 }
68 },
69 {
70 name: "basic navigation",
71 timeout: 10000,
72 runTest: function(){
73 var d = new doh.Deferred();
74 var button = registry.byId("tooltipDlgButton");
75
76 // open TooltipDialog
77 robot.sequence(function(){
78 button.focus();
79 }, 1000, 1000);
80 robot.keyPress(keys.SPACE, 500, {});
81 robot.sequence(d.getTestErrback(function(){
82 doh.t(button._opened, "TooltipDialog should be showing");
83 }), 1000);
84
85 // shift-tab should loop around to last field
86 robot.keyPress(keys.TAB, 500, {shift: true});
87 robot.sequence(d.getTestErrback(function(){
88 doh.is("submit", dfocus.curNode.id, "focused on button");
89 }), 1000);
90
91 // tab should loop around to first field
92 robot.keyPress(keys.TAB, 500, {});
93 robot.sequence(d.getTestErrback(function(){
94 doh.is("inline", dfocus.curNode.id, "focused on InlineEditBox");
95 }), 1000);
96
97 // close TooltipDialog
98 robot.keyPress(keys.ESCAPE, 500, {});
99 robot.sequence(d.getTestCallback(function(){
100 doh.f(button._opened, "TooltipDialog should not be showing after Esc");
101 }), 1000);
102 return d;
103 }
104 },
105 {
106 name: "nested popup",
107 timeout: 10000,
108 runTest: function(){
109 var d = new doh.Deferred();
110
111 var button = registry.byId("tooltipDlgButton"),
112 select = registry.byId("combo");
113
114 // open TooltipDialog, advance to FilteringSelect
115 robot.sequence(function(){
116 button.focus();
117 }, 500);
118 robot.keyPress(keys.SPACE, 500, {});
119 robot.keyPress(keys.TAB, 500, {});
120 robot.keyPress(keys.TAB, 500, {});
121 robot.keyPress(keys.TAB, 500, {});
122 robot.keyPress(keys.TAB, 500, {});
123
124 robot.sequence(d.getTestErrback(function(){
125 doh.t(button._opened, "TooltipDialog should be showing");
126 doh.is("combo", dfocus.curNode.id, "focused on combo");
127 }), 1000);
128
129 // pick second option
130 robot.keyPress(keys.DOWN_ARROW, 0, {});
131 robot.keyPress(keys.DOWN_ARROW, 1000, {});
132 robot.keyPress(keys.DOWN_ARROW, 500, {});
133 robot.keyPress(keys.ENTER, 500, {});
134
135 robot.sequence(d.getTestErrback(function(){
136 doh.t(button._opened, "TooltipDialog should still be showing");
137 doh.is("pepperoni", select.get("value"), "selected pepperoni");
138 }), 1000);
139
140 // close TooltipDialog
141 robot.keyPress(keys.ESCAPE, 0, {});
142
143 robot.sequence(d.getTestCallback(function(){
144 doh.f(button._opened, "TooltipDialog closed");
145 }), 500);
146
147 return d;
148 }
149 }
150 ]);
151
152 doh.register("interacton with autosave InlineEditBox", [
153 {
154 name: "InlineEditBox edit mode, change value, then Esc",
155 timeout: 10000,
156 runTest: function(){
157 var d = new doh.Deferred();
158
159 var button = registry.byId("tooltipDlgButton"),
160 inlineEditBox = registry.byId("inline"),
161 initialValue = inlineEditBox.get("value");
162
163 // open TooltipDialog
164 robot.sequence(function(){
165 button.focus();
166 }, 500);
167 robot.keyPress(keys.SPACE, 500, {});
168
169 robot.sequence(d.getTestErrback(function(){
170 doh.t(button._opened, "TooltipDialog should be showing");
171 doh.f(inlineEditBox.editing, "InlineEditBox not in edit mode yet");
172 }), 1000);
173
174 // edit InlineEditBox
175 robot.keyPress(keys.SPACE, 0, {});
176
177 robot.sequence(d.getTestErrback(function(){
178 doh.t(button._opened, "TooltipDialog should still be showing");
179 doh.t(inlineEditBox.editing, "InlineEditBox in edit mode");
180 }), 1000);
181
182 // type something
183 robot.typeKeys("esc", 0, 600);
184
185 // abort edit
186 robot.keyPress(keys.ESCAPE, 500, {});
187
188 robot.sequence(d.getTestErrback(function(){
189 doh.t(button._opened, "TooltipDialog should still still be showing");
190 doh.f(inlineEditBox.editing, "Esc should have exited InlineEditBox edit mode");
191 doh.is(initialValue, inlineEditBox.get("value"), "initial value was inline");
192 }), 1000);
193
194 // close TooltipDialog
195 robot.keyPress(keys.ESCAPE, 0, {});
196
197 robot.sequence(d.getTestCallback(function(){
198 doh.f(button._opened, "TooltipDialog closed");
199 }), 500);
200
201 return d;
202 }
203 },
204 {
205 name: "InlineEditBox edit mode, change value, then Tab",
206 timeout: 10000,
207 runTest: function(){
208 var d = new doh.Deferred();
209
210 var button = registry.byId("tooltipDlgButton"),
211 inlineEditBox = registry.byId("inline");
212
213 // open TooltipDialog
214 robot.sequence(function(){
215 button.focus();
216 }, 500);
217 robot.keyPress(keys.SPACE, 500, {});
218
219 robot.sequence(d.getTestErrback(function(){
220 doh.t(button._opened, "TooltipDialog should be showing");
221 doh.f(inlineEditBox.editing, "InlineEditBox not in edit mode yet");
222 }), 1000);
223
224 // edit InlineEditBox
225 robot.keyPress(keys.SPACE, 0, {});
226
227 robot.sequence(d.getTestErrback(function(){
228 doh.t(button._opened, "TooltipDialog should still be showing");
229 doh.t(inlineEditBox.editing, "InlineEditBox in edit mode");
230 }), 1000);
231
232 // type something
233 robot.typeKeys("tab", 0, 600);
234
235 // save edit
236 robot.keyPress(keys.TAB, 500, {});
237
238 robot.sequence(d.getTestErrback(function(){
239 doh.t(button._opened, "TooltipDialog should still still be showing");
240 doh.f(inlineEditBox.editing, "Tab should have exited InlineEditBox edit mode");
241 doh.is("tab", inlineEditBox.get("value"), "value changed to tab");
242 }), 1000);
243
244 // close TooltipDialog
245 robot.keyPress(keys.ESCAPE, 0, {});
246
247 robot.sequence(d.getTestCallback(function(){
248 doh.f(button._opened, "TooltipDialog closed");
249 }), 500);
250
251 return d;
252 }
253 },
254 {
255 name: "InlineEditBox edit mode, change value, then Enter",
256 timeout: 10000,
257 runTest: function(){
258 var d = new doh.Deferred();
259
260 var button = registry.byId("tooltipDlgButton"),
261 inlineEditBox = registry.byId("inline");
262
263 // open TooltipDialog
264 robot.sequence(function(){
265 button.focus();
266 }, 500);
267 robot.keyPress(keys.SPACE, 500, {});
268
269 robot.sequence(d.getTestErrback(function(){
270 doh.t(button._opened, "TooltipDialog should be showing");
271 doh.f(inlineEditBox.editing, "InlineEditBox not in edit mode yet");
272 }), 1000);
273
274 // edit InlineEditBox
275 robot.keyPress(keys.SPACE, 0, {});
276
277 robot.sequence(d.getTestErrback(function(){
278 doh.t(button._opened, "TooltipDialog should still be showing");
279 doh.t(inlineEditBox.editing, "InlineEditBox in edit mode");
280 }), 1000);
281
282 // type something
283 robot.typeKeys("enter", 0, 600);
284
285 // save edit
286 robot.keyPress(keys.ENTER, 500, {});
287
288 robot.sequence(d.getTestErrback(function(){
289 doh.t(button._opened, "TooltipDialog should still still be showing");
290 doh.f(inlineEditBox.editing, "Tab should have exited InlineEditBox edit mode");
291 doh.is("enter", inlineEditBox.get("value"), "value changed to enter");
292 }), 1000);
293
294 // close TooltipDialog
295 robot.keyPress(keys.ESCAPE, 0, {});
296
297 robot.sequence(d.getTestCallback(function(){
298 doh.f(button._opened, "TooltipDialog closed");
299 }), 500);
300
301 return d;
302 }
303 },
304 {
305 name: "InlineEditBox double edit (esc, enter)",
306 timeout: 10000,
307 runTest: function(){
308 var d = new doh.Deferred();
309 var button = registry.byId("tooltipDlgButton");
310 inlineEditBox = registry.byId("inline");
311
312 // open TooltipDialog
313 robot.sequence(function(){
314 button.focus();
315 }, 500);
316 robot.keyPress(keys.SPACE, 500, {});
317 robot.sequence(d.getTestErrback(function(){
318 doh.t(button._opened, "TooltipDialog should be showing");
319 }), 1000);
320
321 // start editing
322 robot.keyPress(keys.SPACE, 500, {});
323
324 // abort editing, then re-enter edit mode
325 robot.keyPress(keys.ESCAPE, 1000, {});
326 robot.keyPress(keys.ENTER, 1000, {});
327 robot.sequence(d.getTestCallback(function(){
328 doh.t(button._opened, "TooltipDialog should still be showing");
329 doh.t(inlineEditBox.editing, "Enter should have reentered edit mode");
330 inlineEditBox.cancel(true);
331 button.closeDropDown(true);
332 }), 2000);
333 return d;
334 }
335 },
336 {
337 name: "InlineEditBox double edit (enter, enter)",
338 timeout: 10000,
339 runTest: function(){
340 var d = new doh.Deferred();
341 var button = registry.byId("tooltipDlgButton"),
342 inlineEditBox = registry.byId("inline");
343
344 // open TooltipDialog
345 robot.sequence(function(){
346 button.focus();
347 }, 1000, 1000);
348 robot.keyPress(keys.SPACE, 500, {});
349 robot.sequence(d.getTestErrback(function(){
350 doh.t(button._opened, "TooltipDialog should be showing");
351 }), 1000);
352
353 // start editing
354 robot.keyPress(keys.SPACE, 500, {});
355 robot.typeKeys("enter #2", 1000, 1000);
356
357 // save via ENTER key, the press ENTER again to re-edit
358 robot.keyPress(keys.ENTER, 200, {});
359 robot.keyPress(keys.ENTER, 1000, {});
360
361 robot.sequence(d.getTestCallback(function(){
362 doh.t(button._opened, "TooltipDialog should still be showing");
363 doh.t(inlineEditBox.editing, "2nd Enter should have reentered edit mode");
364 inlineEditBox.cancel(true);
365 button.closeDropDown(true);
366 }), 2000);
367 return d;
368 }
369 },
370 {
371 name: "InlineEditBox focused after Tab/Shift+Tab",
372 timeout: 10000,
373 runTest: function(){
374 var d = new doh.Deferred();
375
376 var button = registry.byId("tooltipDlgButton"),
377 inlineEditBox = registry.byId("inline");
378
379 // open TooltipDialog
380 robot.sequence(function(){
381 button.focus();
382 }, 1000, 1000);
383 robot.keyPress(keys.SPACE, 500, {});
384 robot.sequence(d.getTestErrback(function(){
385 doh.t(button._opened, "TooltipDialog should be showing");
386 }), 1000);
387
388 // start editing
389 robot.keyPress(keys.SPACE, 500, {});
390 robot.typeKeys("tab", 1000, 600);
391
392 // tab forward, then back (first tab will cancel edit)
393 robot.keyPress(keys.TAB, 100, {});
394 robot.keyPress(keys.TAB, 1000, {shift:true});
395
396 // re-enter edit mode
397 robot.keyPress(keys.ENTER, 500, {});
398
399 robot.sequence(d.getTestCallback(function(){
400 doh.t(button._opened, "TooltipDialog should still be showing");
401 doh.t(inlineEditBox.editing, "Enter after shift+Tab should have reentered edit mode");
402 inlineEditBox.cancel(true);
403 button.closeDropDown(true);
404 }), 2000);
405 return d;
406 }
407 },
408 {
409 name: "href",
410 timeout: 10000,
411 runTest: function(){
412 var d = new doh.Deferred();
413 var button = registry.byId("slowLoadButton"),
414 dialog = registry.byId("slowLoad");
415
416 // Setup handler to continue test after dialog is opened and content loaded
417 dialog.onLoad = function(){
418 setTimeout(d.getTestErrback(function(){
419 doh.t(button._opened, "TooltipDialog should be showing");
420 doh.t(/Delayed by 0.5 sec/.test(dialog.domNode.innerHTML), "data was loaded");
421
422 // Close TooltipDialog
423 robot.keyPress(keys.ESCAPE, 500, {});
424 robot.sequence(d.getTestCallback(function(){
425 doh.f(button._opened, "TooltipDialog should not be showing after Esc");
426 }), 1000);
427 }), 0);
428 };
429
430 // Open TooltipDialog
431 robot.sequence(function(){
432 button.focus();
433 }, 0);
434 robot.keyPress(keys.SPACE, 500, {});
435
436 return d;
437 },
438 tearDown: function(){
439 registry.byId("slowLoad").onLoad = function(){};
440 }
441 }
442 ]);
443
444 doh.run();
445 });
446 </script>
447 </head>
448 </html>