Debian Codegraph @

dijit/tests/layout/robot/TabContainer_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 TabContainer 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",
18 "dojo/dom", "dojo/keys", "dojo/query", "dojo/sniff", "dojo/window",
19 "dijit/tests/helpers"
20 ], function(doh, robot, dom, keys, query, has, winUtils, helpers){
21
22 robot.initRobot('../test_TabContainer.html');
23
24 var registry;
25
26 doh.register("setup", [
27 function setup(){
28 // get pointers to singletons loaded on test page
29 registry = robot.window.require("dijit/registry");
30 }
31 ]);
32
33 doh.register("aria", [
34 {
35 name: "tab container attributes",
36 timeout: 10000,
37 runTest: function(t){
38 var d = new doh.Deferred();
39 var tc = registry.byId("mainTabContainer");
40
41 doh.is("tabpanel", tc.containerNode.children[0].getAttribute("role"), "containerNode child role");
42 doh.is("mainTabContainer_tablist_tab1", tc.containerNode.children[0].getAttribute("aria-labelledby"), "containerNode.child (the tabpanel) labelledby");
43
44 var tablist = tc.tablist;
45
46 // The tablist that stretches across the top
47 doh.is("tablist", tablist.containerNode.getAttribute("role"), "tablist role");
48 doh.is("tab", tablist.getChildren()[0].focusNode.getAttribute("role"), "tablist child's role should be tab");
49
50 // Now the drop down button
51 doh.is("button", tablist._menuBtn.domNode.getAttribute("role"), "_menuBtn role");
52 doh.f(tablist._menuBtn.domNode.getAttribute("aria-expanded"), "aria-expanded should initially be absent");
53 doh.f(tablist._menuBtn.domNode.getAttribute("aria-owns"), "aria-owns should initially be absent");
54
55 // Now open the drop down to verify changes in aria-expanded, aria-owns, and aria-labelledby
56 tablist._menuBtn.focus();
57 robot.keyPress(keys.ENTER, 500, {});
58
59 robot.sequence(d.getTestCallback(function(){
60 doh.t(tablist._menuBtn.domNode.getAttribute("aria-expanded"), "aria-expanded with open dropdown");
61 doh.is("mainTabContainer_menu", tablist._menuBtn.domNode.getAttribute("aria-owns"), "menuBtn should own the menu dropdown");
62
63 var menu = registry.byId("mainTabContainer_menu");
64 doh.is("menu", menu.domNode.getAttribute("role"), "the dropdown role");
65 doh.is("mainTabContainer_tablist_menuBtn", menu.domNode.getAttribute("aria-labelledby"), "aria-labelledby on menu dropdown");
66
67 }), 500);
68
69 return d;
70 }
71 }
72 ]);
73
74 doh.register("basic navigation", [
75 {
76 name: "focus on button before TabContainer",
77 timeout: 10000,
78 runTest: function(t){
79 var d = new doh.Deferred();
80
81 // Note: for this to work, focus needs to start somewhere else; otherwise there will be no
82 // focus event.
83 helpers.onFocus(d.getTestCallback(function(node){
84 }));
85
86 query("button")[0].focus();
87
88 return d;
89 }
90 },
91 {
92 name: "tab into main TabContainer",
93 timeout: 10000,
94 runTest: function(t){
95 var d = new doh.Deferred();
96
97 helpers.onFocus(d.getTestCallback(function(node){
98 doh.is("mainTabContainer_tablist_tab2", node.id, "focus");
99 }));
100
101 robot.keyPress(keys.TAB, 500, {});
102
103 return d;
104 }
105 },
106 {
107 name: "move to tab 3 with RIGHT arrow",
108 timeout: 10000,
109 runTest: function(t){
110 var d = new doh.Deferred();
111
112 helpers.onFocus(d.getTestCallback(function(node){
113 var tc = registry.byId("mainTabContainer");
114 doh.is('mainTabContainer_tablist_tab3', node.id, "currently chosen tab");
115 doh.is("tab3", tc.selectedChildWidget.id, "currently displayed pane");
116 }));
117
118 robot.keyPress(keys.RIGHT_ARROW, 500, {});
119
120 return d;
121 }
122 },
123 {
124 name: "move to tab 2 with LEFT arrow",
125 timeout: 10000,
126 runTest: function(t){
127 var d = new doh.Deferred();
128
129 var tc = registry.byId("mainTabContainer");
130 helpers.onFocus(d.getTestCallback(function(node){
131 doh.is('mainTabContainer_tablist_tab2', node.id, "currently chosen tab");
132 doh.is("tab2", tc.selectedChildWidget.id, "currently chosen pane");
133 }));
134
135 robot.keyPress(keys.LEFT_ARROW, 500, {});
136
137 return d;
138 }
139 },
140
141 {
142 name: "move to tab 3 again with RIGHT arrow",
143 timeout: 10000,
144 runTest: function(t){
145 var d = new doh.Deferred();
146
147 helpers.onFocus(d.getTestCallback(function(node){
148 }));
149
150 robot.keyPress(keys.RIGHT_ARROW, 500, {});
151
152 return d;
153 }
154 },
155 {
156 name: "move to inlined subcontainer tab with RIGHT arrow",
157 timeout: 10000,
158 runTest: function(t){
159 var d = new doh.Deferred();
160
161 helpers.onFocus(d.getTestCallback(function(node){
162 }));
163
164 robot.keyPress(keys.RIGHT_ARROW, 500, {});
165
166 return d;
167 }
168 },
169
170 {
171 name: "TAB focus to nested tab",
172 timeout: 10000,
173 runTest: function(t){
174 var d = new doh.Deferred();
175
176 helpers.onFocus(d.getTestCallback(function(node){
177 doh.is('inlined_tablist_tab2href', node.id);
178 }));
179
180 robot.keyPress(keys.TAB, 750);
181
182 return d;
183 }
184 },
185
186 {
187 name: "move to second nested tab button",
188 timeout: 10000,
189 runTest: function(t){
190 var d = new doh.Deferred();
191
192 helpers.onFocus(d.getTestCallback(function(node){
193 }));
194
195 robot.keyPress(keys.RIGHT_ARROW, 500, {});
196
197 return d;
198 }
199 },
200 {
201 name: "shift-TAB to parent tabs from nested tabs",
202 timeout: 10000,
203 runTest: function(t){
204 var d = new doh.Deferred();
205
206 helpers.onFocus(d.getTestCallback(function(node){
207 }));
208
209 robot.keyPress(keys.TAB, 750, {shift:true});
210
211 return d;
212 }
213 },
214 {
215 name: "left arrow to tab 3",
216 timeout: 10000,
217 runTest: function(t){
218 var d = new doh.Deferred();
219
220 helpers.onFocus(d.getTestCallback(function(node){
221 doh.is('mainTabContainer_tablist_tab3', node.id);
222 }));
223
224 robot.keyPress(keys.LEFT_ARROW, 500, {});
225
226 return d;
227 }
228 },
229 {
230 name: "right arrow to inline subtabcontainer",
231 timeout: 10000,
232 runTest: function(t){
233 var d = new doh.Deferred();
234
235 helpers.onFocus(d.getTestCallback(function(node){
236 }));
237
238 robot.keyPress(keys.RIGHT_ARROW, 500, {});
239
240 return d;
241 }
242 },
243 {
244 name: "verify nested tablist keeps it's state",
245 timeout: 10000,
246 runTest: function(t){
247 var d = new doh.Deferred();
248
249 //verify that the third nested tab is still selected
250 helpers.onFocus(d.getTestCallback(function(node){
251 doh.is('inlined_tablist_subtab3', node.id);
252 }));
253
254 robot.keyPress(keys.TAB, 750, {}); // give IE8 time to complete slide animation
255
256 return d;
257 }
258 }
259 ]);
260
261 doh.register("HOME/END keys", [
262 {
263 name: "focus tab 3",
264 timeout: 10000,
265 runTest: function(t){
266 var d = new doh.Deferred();
267
268 registry.byId("mainTabContainer").selectChild(registry.byId("tab3"), false);
269
270 setTimeout(d.getTestErrback(function(){
271 // on IE the focus event lands after control releases (after the NEXT test has set its focus handler) so do 0 timeout to let focus happen
272 dom.byId("mainTabContainer_tablist_tab3href").focus();
273 setTimeout(d.getTestCallback(function(){}),0);
274 }), 500);
275
276 return d;
277 }
278 },
279 {
280 name: "home key",
281 timeout: 10000,
282 runTest: function(t){
283 var d = new doh.Deferred();
284
285 helpers.onFocus(d.getTestCallback(function(node){
286 doh.is('mainTabContainer_tablist_tab1', node.id);
287 }));
288
289 robot.keyPress(keys.HOME, 500, {});
290
291 return d;
292 }
293 },
294 {
295 name: "end key",
296 timeout: 10000,
297 runTest: function(t){
298 var d = new doh.Deferred();
299
300 helpers.onFocus(d.getTestCallback(function(node){
301 doh.is('mainTabContainer_tablist_embedded', node.id);
302 }));
303
304 robot.keyPress(keys.END, 500, {});
305
306 return d;
307 }
308 },
309 {
310 name: "verify left/right arrows still work",
311 timeout: 10000,
312 runTest: function(t){
313 var d = new doh.Deferred();
314
315 helpers.onFocus(d.getTestCallback(function(node){
316 doh.is('mainTabContainer_tablist_tab4href', node.id);
317 }));
318
319 robot.keyPress(keys.LEFT_ARROW, 500, {});
320
321 return d;
322 }
323 }
324 ]);
325
326 doh.register("disabled tabs",[
327 {
328 name: "setup",
329 runTest: function(){
330
331 // disable first, last, and middle tab
332 registry.byId("tab1").set("disabled", true);
333 registry.byId("tab3").set("disabled", true);
334 registry.byId("embedded").set("disabled", true);
335
336 // set second tab as selected
337 registry.byId("mainTabContainer").selectChild(registry.byId("tab2"));
338 }
339 },
340
341 {
342 name: "focus on button before TabContainer",
343 timeout: 10000,
344 runTest: function(t){
345 var d = new doh.Deferred();
346
347 helpers.onFocus(d.getTestCallback(function(node){
348 }));
349
350 query("button")[0].focus();
351
352 return d;
353 }
354 },
355 {
356 name: "tab into main TabContainer",
357 timeout: 10000,
358 runTest: function(t){
359 var d = new doh.Deferred();
360
361 helpers.onFocus(d.getTestCallback(function(node){
362 doh.is("mainTabContainer_tablist_tab2", node.id, "focus");
363 }));
364
365 robot.keyPress(keys.TAB, 500, {});
366
367 return d;
368 }
369 },
370 {
371 name: "skip over tab 3 with RIGHT arrow",
372 timeout: 10000,
373 runTest: function(t){
374 var d = new doh.Deferred();
375
376 helpers.onFocus(d.getTestCallback(function(node){
377 var tc = registry.byId("mainTabContainer");
378 doh.is('mainTabContainer_tablist_inlined', node.id, "currently chosen tab");
379 doh.is("inlined", tc.selectedChildWidget.id, "currently displayed pane");
380 }));
381
382 robot.keyPress(keys.RIGHT_ARROW, 500, {});
383
384 return d;
385 }
386 },
387 {
388 name: "skip over tab 3 with LEFT arrow",
389 timeout: 10000,
390 runTest: function(t){
391 var d = new doh.Deferred();
392
393 var tc = registry.byId("mainTabContainer");
394 helpers.onFocus(d.getTestCallback(function(node){
395 doh.is('mainTabContainer_tablist_tab2', node.id, "currently chosen tab");
396 doh.is("tab2", tc.selectedChildWidget.id, "currently chosen pane");
397 }));
398
399 robot.keyPress(keys.LEFT_ARROW, 500, {});
400
401 return d;
402 }
403 },
404 {
405 name: "end key should skip disabled tab",
406 timeout: 10000,
407 runTest: function(t){
408 var d = new doh.Deferred();
409
410 helpers.onFocus(d.getTestCallback(function(node){
411 doh.is('mainTabContainer_tablist_tab4href', node.id);
412 }));
413
414 robot.keyPress(keys.END, 500, {});
415
416 return d;
417 }
418 },
419 {
420 name: "home key should skip disabled tab",
421 timeout: 10000,
422 runTest: function(t){
423 var d = new doh.Deferred();
424
425 helpers.onFocus(d.getTestCallback(function(node){
426 doh.is('mainTabContainer_tablist_tab2', node.id);
427 }));
428
429 robot.keyPress(keys.HOME, 500, {});
430
431 return d;
432 }
433 },
434
435 {
436 name: "teardown",
437 runTest: function(){
438 // disable first, last, and middle tab
439 registry.byId("tab1").set("disabled", false);
440 registry.byId("tab3").set("disabled", false);
441 registry.byId("embedded").set("disabled", false);
442 }
443 }
444 ]);
445
446 doh.register("closing tabs", [
447 {
448 name: "close tab with DELETE button",
449 timeout: 10000,
450 runTest: function(t){
451 var d = new doh.Deferred();
452
453 var tc = registry.byId("mainTabContainer");
454
455 // Select "SplitContainer from href tab"
456 tc.selectChild("tab4href");
457
458 // Go to "Embedded layout widgets" tab, and close it.
459 // This puts focus back on "SplitContainer from href".
460 robot.keyPress(keys.RIGHT_ARROW, 500, {});
461 robot.keyPress(keys.DELETE, 750, {});
462
463 robot.sequence(d.getTestCallback(function(){
464 doh.is(6, tc.getChildren().length, "six tabs left");
465 doh.is("tab4href", tc.selectedChildWidget.id, "selection moved to previous tab");
466 }), 500);
467
468 return d;
469 }
470 },
471 {
472 name: "close tab with CTRL-W button",
473 timeout: 10000,
474 runTest: function(t){
475 var d = new doh.Deferred();
476
477 robot.sequence(function(){
478 dom.byId("mainTabContainer_tablist_tab1").focus();
479 }, 500);
480
481 // Go to "Tab 3", and close it.
482 // This puts the focus back on "Tab 2".
483 robot.keyPress(keys.LEFT_ARROW, 500, {});
484 robot.keyPress(keys.LEFT_ARROW, 750, {});
485 robot.keyPress(keys.LEFT_ARROW, 750, {});
486 if(has("chrome")){
487 // on chrome ctrl+w isn't trapped, and closes the whole browser!
488 robot.keyPress(keys.DELETE, 750, {});
489 }else{
490 robot.keyPress("w", 750, {ctrl:true});
491 }
492
493 var tc = registry.byId("mainTabContainer");
494 robot.sequence(d.getTestCallback(function(){
495 doh.is(5, tc.getChildren().length);
496 doh.is("tab2", tc.selectedChildWidget.id, "selection moved to previous tab");
497 }), 500);
498 return d;
499 }
500 }
501 ]);
502
503 // Run test about opening context menu via keyboard, except on:
504 // - safari/mac where it doesn't work unless VoiceOver is turned on (#9927)
505 // - webkit/win, where in suite mode (runTests.html), F10 triggers context menu
506 // in both the iframe and the outer window
507 if(!has("webkit")){
508 doh.register("closing tabs via context menu", {
509 name: "close tab through context menu",
510 timeout: 10000,
511 runTest: function(t){
512 var d = new doh.Deferred();
513
514 var tc = registry.byId("ttabs");
515 winUtils.scrollIntoView(tc.domNode);
516 doh.is(4, tc.getChildren().length, "num tabs before trying to close one");
517
518 dom.byId("ttabs_tablist_ttab1").focus();
519
520 // Open context menu via keyboard
521 if(has("mac")){
522 robot.keyPress(keys.SPACE, 500, {
523 ctrl: true
524 });
525 }else{
526 robot.keyPress(keys.F10, 500, {
527 shift: true
528 });
529 }
530
531 // Close tab
532 robot.keyPress(keys.ENTER, 500, {});
533
534 robot.sequence(d.getTestCallback(function(){
535 doh.is(3, tc.getChildren().length, "remaining tabs");
536 doh.is("ttab2", tc.selectedChildWidget.id,
537 "selection moved to next tab (since first tab was deleted)");
538 }), 500);
539
540 return d;
541 }
542 });
543 }
544
545 doh.register("up/down arrows", [
546 {
547 name: "move to tab with DOWN button",
548 timeout: 10000,
549 runTest: function(t){
550 var d = new doh.Deferred();
551
552 var tc = registry.byId("ltabs");
553 winUtils.scrollIntoView(tc.domNode);
554
555 dom.byId("ltabs_tablist_HanselGretel1").focus();
556 setTimeout(d.getTestErrback(function(){
557 helpers.onFocus(d.getTestCallback(function(node){
558 doh.is('ltabs_tablist_GreenTwigs1', node.id, "currently chosen tab");
559 doh.is("GreenTwigs1", tc.selectedChildWidget.id, "currently displayed pane");
560 }));
561
562 robot.keyPress(keys.DOWN_ARROW, 500, {});
563 }), 0);
564
565 return d;
566 }
567 },
568 {
569 name: "move to tab with UP button",
570 timeout: 10000,
571 runTest: function(t){
572 var d = new doh.Deferred();
573
574 var tc = registry.byId("ltabs");
575 helpers.onFocus(d.getTestCallback(function(node){
576 doh.is('ltabs_tablist_HanselGretel1', node.id, "currently chosen tab");
577 doh.is("HanselGretel1", tc.selectedChildWidget.id, "currently chosen pane");
578 }));
579
580 robot.keyPress(keys.UP_ARROW, 500, {});
581
582 return d;
583 }
584 }
585 ]);
586
587 doh.run();
588 });
589 </script>
590 </head>
591 </html>