Debian Codegraph @

dijit/tests/robot/Menu_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 Menu Keyboard Tests</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"></script>
13
14 <script type="text/javascript">
15 require([
16 "doh/runner", "dojo/robotx",
17 "dojo/_base/array", "dojo/dom", "dojo/dom-class", "dojo/dom-geometry",
18 "dojo/keys", "dojo/query", "dojo/sniff",
19 "dijit/tests/helpers", "dojo/domReady!"
20 ], function(doh, robot, array, dom, domClass, domGeom, keys, query, has, helpers){
21
22 robot.initRobot('../test_Menu.html');
23
24 doh.register(function setup(){
25 // get pointer to registry in the iframe
26 registry = robot.window.require("dijit/registry");
27 dfocus = robot.window.require("dijit/focus");
28 });
29
30 doh.register("dijit.MenuBar general keyboard tests", [
31 {
32 name: "start focus on the link, outside of menubar",
33 timeout: 5000,
34 runTest: function(){
35 var d = new doh.Deferred();
36
37 // Start at the link
38 robot.sequence(function(){
39 dom.byId("link").focus();
40 }, 500, 500);
41
42 robot.sequence(d.getTestCallback(function(){
43 doh.t(dfocus.curNode, "something has focus");
44 doh.is("random link", dfocus.curNode.innerHTML, "focus on the link");
45 }), 1000);
46
47 return d;
48 }
49 },
50
51 {
52 name: "tab to the menubar",
53 timeout: 5000,
54 runTest: function(){
55 var d = new doh.Deferred();
56
57 // tab to the MenuBar... then focus should automatically shift to "File" menu,
58 robot.keyPress(keys.TAB, 500, {});
59
60 robot.sequence(d.getTestCallback(function(){
61 doh.is("File", helpers.innerText(dfocus.curNode), "focus on File menu");
62 }), 1000);
63
64 return d;
65 }
66 },
67
68 {
69 name: "arrow to the edit menu",
70 timeout: 5000,
71 runTest: function(){
72 var d = new doh.Deferred();
73
74 robot.keyPress(keys.RIGHT_ARROW, 500, {}); // TODO: use left arrow in RTL mode
75
76 robot.sequence(d.getTestCallback(function(){
77 doh.is("Edit", helpers.innerText(dfocus.curNode), "focus on Edit MenuItem");
78 }), 1000);
79
80 return d;
81 }
82 },
83
84 {
85 name: "shift-tab back",
86 timeout: 5000,
87 runTest: function(){
88 var d = new doh.Deferred();
89
90 robot.keyPress(keys.TAB, 500, {shift:true});
91
92 robot.sequence(d.getTestCallback(function(){
93 doh.is("random link", helpers.innerText(dfocus.curNode),
94 "focus back on the link");
95 }), 1000);
96
97 return d;
98 }
99 },
100
101 {
102 name: "open file menu",
103 timeout: 5000,
104 runTest: function(){
105 var d = new doh.Deferred();
106
107 // Start at the link
108 robot.sequence(function(){
109 dom.byId("link").focus();
110 }, 500, 500);
111
112 // tab to the MenuBar... then focus should automatically shift to "File" menu
113 robot.keyPress(keys.TAB, 500, {});
114
115 // and then down arrow to menu... focus should go to "New"
116 robot.keyPress(keys.DOWN_ARROW, 500, {});
117
118 robot.sequence(d.getTestCallback(function(){
119 doh.is("New", helpers.innerText(dfocus.curNode).substr(0, 3),
120 "focus on New menu item of the File menu (indirectly checks that menu is visible)");
121
122 // Check aria-labelledby property
123 var menuNode;
124 for(var menuNode = dfocus.curNode; menuNode.getAttribute("role") != "menu";
125 menuNode = menuNode.parentNode){}
126 var menuLabelNode = dom.byId(menuNode.getAttribute("aria-labelledby"), robot.doc),
127 menuLabel = helpers.innerText(menuLabelNode);
128 doh.is("File", menuLabel, "label of menu");
129 }), 1000);
130
131 return d;
132 }
133 },
134
135 {
136 name: "click 'new' using enter key",
137 timeout: 5000,
138 runTest: function(){
139 var d = new doh.Deferred();
140
141 var clicked = false;
142 registry.byId("new").onClick = function(){ clicked = true; };
143
144 robot.keyPress(keys.ENTER, 500, {});
145
146 robot.sequence(d.getTestCallback(function(){
147 doh.t(clicked, "new was clicked");
148 doh.t(helpers.isHidden("fileMenu"), "File menu disappeared");
149 doh.f(domClass.contains("file", "dijitMenuItemSelected"),
150 "File MenuBarItem should no longer have selected effect, actual class is: " + dom.byId("file").className);
151 }), 1000);
152
153 return d;
154 }
155 },
156
157 {
158 name: "open submenu",
159 timeout: 8000,
160 runTest: function(){
161 var d = new doh.Deferred();
162
163 // Start at the link
164 robot.sequence(function(){
165 dom.byId("link").focus();
166 }, 500, 500);
167
168 // tab to the MenuBar... then focus should automatically shift to "File" menu item
169 robot.keyPress(keys.TAB, 500, {});
170
171 // and then move to "View" menu item
172 robot.typeKeys("v", 500, 200);
173
174 // open the Zoom submenu (landing on first item)
175 robot.typeKeys("z", 500, 200);
176
177 robot.sequence(d.getTestCallback(function(){
178 doh.t(/50%/.test(helpers.innerText(dfocus.curNode)), "focus on '50%'");
179 robot.keyPress(keys.ENTER, 0, {}, true); // close popup menus
180 }), 1000, 500);
181
182 return d;
183 }
184 }
185 ]);
186
187 doh.register("dijit.MenuBar focus after execute", [
188 {
189 name: "open edit menu",
190 timeout: 5000,
191 runTest: function(){
192 var d = new doh.Deferred();
193
194 // Start at the link
195 robot.sequence(function(){
196 dom.byId("link").focus();
197 }, 500, 500);
198
199 // tab to the MenuBar... then focus should automatically shift to "File" menu
200 robot.keyPress(keys.TAB, 500, {});
201
202 // arrow to edit menu
203 robot.keyPress(keys.RIGHT_ARROW, 500, {}); // TODO: use left arrow in RTL mode
204
205 // and then down arrow to menu... focus should go to "Cut"
206 robot.keyPress(keys.DOWN_ARROW, 500, {});
207
208 robot.sequence(d.getTestCallback(function(){
209 doh.is("Cut", helpers.innerText(dfocus.curNode).substr(0, 3));
210 }), 1000);
211
212 return d;
213 }
214 },
215
216 {
217 name: "click 'cut' using enter key",
218 timeout: 5000,
219 runTest: function(){
220 var d = new doh.Deferred();
221
222 robot.keyPress(keys.ENTER, 500, {});
223
224 robot.sequence(d.getTestCallback(function(){
225 // Although "Edit" is not marked as selected, and although the MenuBar is in passive
226 // mode, focus should be back on "Edit"
227 doh.is("Edit", helpers.innerText(dfocus.curNode), "focus back on Edit in MenuBar")
228 }), 1000);
229
230 return d;
231 }
232 },
233
234 {
235 name: "right arrow to view",
236 timeout: 5000,
237 runTest: function(){
238 var d = new doh.Deferred();
239
240 // arrow to view MenuBarItem
241 robot.keyPress(keys.RIGHT_ARROW, 500, {}); // TODO: use left arrow in RTL mode
242
243 robot.sequence(d.getTestCallback(function(){
244 doh.is("View", helpers.innerText(dfocus.curNode));
245 doh.t(domClass.contains(dom.byId("view"), "dijitMenuItemSelected"),
246 "View MenuBarItem should have selected class, actual class is:" + dom.byId("view").className);
247 }), 1000);
248
249 return d;
250 }
251 }
252 ]);
253
254 doh.register("dijit.MenuBar repeat open keyboard tests", [
255 {
256 name: "start focus on the link, outside of menubar",
257 timeout: 5000,
258 runTest: function(){
259 var d = new doh.Deferred();
260
261 // Start at the link
262 robot.sequence(function(){
263 dom.byId("link").focus();
264 }, 500, 500);
265
266 robot.sequence(d.getTestCallback(function(){
267 doh.t(dfocus.curNode, "something has focus");
268 doh.is("random link", dfocus.curNode.innerHTML, "focus on the link");
269 }), 1000);
270
271 return d;
272 }
273 },
274
275 {
276 name: "tab to the menubar",
277 timeout: 5000,
278 runTest: function(){
279 var d = new doh.Deferred();
280
281 // tab to the MenuBar... then focus should automatically shift to "File" menu,
282 robot.keyPress(keys.TAB, 500, {});
283
284 robot.sequence(d.getTestCallback(function(){
285 doh.is("File", helpers.innerText(dfocus.curNode), "focus on File menu");
286 }), 1000);
287
288 return d;
289 }
290 },
291
292 {
293 name: "open file menu #1",
294 timeout: 5000,
295 runTest: function(){
296 var d = new doh.Deferred();
297
298 robot.keyPress(keys.DOWN_ARROW, 500, {});
299
300 robot.sequence(d.getTestCallback(function(){
301 doh.is("New", helpers.innerText(dfocus.curNode).substr(0, 3),
302 "focus on New MenuItem");
303 }), 500);
304
305 return d;
306 }
307 },
308
309 {
310 name: "close file menu #1",
311 timeout: 5000,
312 runTest: function(){
313 var d = new doh.Deferred();
314
315 robot.keyPress(keys.ENTER, 500, {});
316
317 robot.sequence(d.getTestCallback(function(){
318 doh.is("File", helpers.innerText(dfocus.curNode),
319 "focus on File MenuBarItem again");
320 }), 500);
321
322 return d;
323 }
324 },
325
326 {
327 name: "open file menu #2",
328 timeout: 5000,
329 runTest: function(){
330 var d = new doh.Deferred();
331
332 robot.keyPress(keys.DOWN_ARROW, 500, {});
333
334 robot.sequence(d.getTestCallback(function(){
335 doh.is("New", helpers.innerText(dfocus.curNode).substr(0, 3),
336 "focus on New MenuItem again");
337 }), 750);
338
339 return d;
340 }
341 },
342
343 {
344 name: "close file menu #2",
345 timeout: 5000,
346 runTest: function(){
347 var d = new doh.Deferred();
348
349 robot.keyPress(keys.ENTER, 500, {});
350
351 robot.sequence(d.getTestCallback(function(){
352 doh.is("File", helpers.innerText(dfocus.curNode),
353 "focus on File MenuBarItem yet again");
354 }), 500);
355
356 return d;
357 }
358 }
359 ]);
360
361 // Using left-arrow to back up (#10437)
362 doh.register("dijit.MenuBar left arrow tests", [
363 {
364 name: "start focus on the link, outside of menubar",
365 timeout: 5000,
366 runTest: function(){
367 var d = new doh.Deferred();
368
369 // Start at the link
370 robot.sequence(function(){
371 dom.byId("link").focus();
372 }, 500, 500);
373
374 robot.sequence(d.getTestCallback(function(){
375 doh.t(dfocus.curNode, "something has focus");
376 doh.is("random link", dfocus.curNode.innerHTML, "focus on the link");
377 }), 1000);
378
379 return d;
380 }
381 },
382
383 {
384 name: "tab to the menubar",
385 timeout: 5000,
386 runTest: function(){
387 var d = new doh.Deferred();
388
389 // tab to the MenuBar... then focus should automatically shift to "File" menu,
390 robot.keyPress(keys.TAB, 500, {});
391
392 robot.sequence(d.getTestCallback(function(){
393 doh.is("{F}ile", registry.getEnclosingWidget(dfocus.curNode).label,
394 "focus on File MenuItem");
395 }), 1000);
396
397 return d;
398 }
399 },
400
401 {
402 name: "arrow to the view menu",
403 timeout: 5000,
404 runTest: function(){
405 var d = new doh.Deferred();
406
407 robot.keyPress(keys.RIGHT_ARROW, 500, {}); // TODO: use left arrow in RTL mode
408 robot.keyPress(keys.RIGHT_ARROW, 500, {}); // TODO: use left arrow in RTL mode
409
410 robot.sequence(d.getTestCallback(function(){
411 doh.is("View", helpers.innerText(dfocus.curNode),
412 "focus on View MenuItem");
413 }), 1000);
414
415 return d;
416 }
417 },
418
419 {
420 name: "down to the zoom menuitem",
421 timeout: 5000,
422 runTest: function(){
423 var d = new doh.Deferred();
424
425 robot.keyPress(keys.DOWN_ARROW, 500, {}); // focuses "Normal", first menu item
426 robot.keyPress(keys.DOWN_ARROW, 500, {}); // focuses "Outline", second menu item
427 robot.keyPress(keys.DOWN_ARROW, 500, {}); // focuses "Zoom", third menu item
428
429 robot.sequence(d.getTestCallback(function(){
430 doh.is("{Z}oom", registry.getEnclosingWidget(dfocus.curNode).label,
431 "focus on Zoom MenuItem");
432 }), 1000);
433
434 return d;
435 }
436 },
437
438 {
439 name: "open the zoom menu",
440 timeout: 5000,
441 runTest: function(){
442 var d = new doh.Deferred();
443
444 robot.keyPress(keys.RIGHT_ARROW, 500, {});
445
446 robot.sequence(d.getTestCallback(function(){
447 doh.is("50%", registry.getEnclosingWidget(dfocus.curNode).label,
448 "focus on Zoom MenuItem");
449 }), 1000);
450
451 return d;
452 }
453 },
454
455 {
456 name: "close Zoom menu, back to View menu",
457 timeout: 5000,
458 runTest: function(){
459 var d = new doh.Deferred();
460
461 robot.keyPress(keys.LEFT_ARROW, 500, {});
462
463 robot.sequence(d.getTestCallback(function(){
464 doh.is("{Z}oom", registry.getEnclosingWidget(dfocus.curNode).label,
465 "focus on Zoom MenuItem");
466
467 doh.is(0, query("#zoomMenu .dijitMenuItemSelected").length,
468 "dijitMenuItemSelected removed from Zoom Menu")
469 }), 1000);
470
471 return d;
472 }
473 },
474
475 {
476 name: "close View menu, back to MenuBar",
477 timeout: 5000,
478 runTest: function(){
479 var d = new doh.Deferred();
480
481 // This should move focus to "Edit" in the MenuBar, which then opens
482 // the drop down and focuses on the first item (Cut)
483 robot.keyPress(keys.LEFT_ARROW, 500, {});
484
485 robot.sequence(d.getTestCallback(function(){
486 doh.is("C{u}t", registry.getEnclosingWidget(dfocus.curNode).label,
487 "focus on first MenuItem in Edit Menu");
488
489 doh.is(0, query("#viewMenu .dijitMenuItemSelected").length,
490 "dijitMenuItemSelected removed from View Menu")
491 }), 1000);
492
493 return d;
494 }
495 }
496 ]);
497
498 doh.register("dijit.MenuBar nested click focus test", [
499 {
500 name: "start focus on the link, outside of menubar",
501 timeout: 5000,
502 runTest: function(){
503 var d = new doh.Deferred();
504
505 // Start at the link
506 robot.sequence(function(){
507 dom.byId("link").focus();
508 }, 500);
509
510 robot.sequence(d.getTestCallback(function(){
511 doh.t(dfocus.curNode, "something has focus");
512 doh.is("random link", dfocus.curNode.innerHTML, "focus on the link");
513 }), 1000);
514
515 return d;
516 }
517 },
518
519 {
520 name: "tab to the menubar",
521 timeout: 5000,
522 runTest: function(){
523 var d = new doh.Deferred();
524
525 // tab to the MenuBar... then focus should automatically shift to "File" menu,
526 robot.keyPress(keys.TAB, 500, {});
527
528 robot.sequence(d.getTestCallback(function(){
529 doh.is("{F}ile", registry.getEnclosingWidget(dfocus.curNode).label,
530 "focus on File MenuItem");
531 }), 1000);
532
533 return d;
534 }
535 },
536
537 {
538 name: "arrow to the view menu",
539 timeout: 5000,
540 runTest: function(){
541 var d = new doh.Deferred();
542
543 robot.keyPress(keys.RIGHT_ARROW, 500, {}); // TODO: use left arrow in RTL mode
544 robot.keyPress(keys.RIGHT_ARROW, 500, {}); // TODO: use left arrow in RTL mode
545
546 robot.sequence(d.getTestCallback(function(){
547 doh.is("View", helpers.innerText(dfocus.curNode), "focus on View MenuItem");
548 }), 1000);
549
550 return d;
551 }
552 },
553
554 {
555 name: "down to the zoom menuitem",
556 timeout: 5000,
557 runTest: function(){
558 var d = new doh.Deferred();
559
560 robot.keyPress(keys.DOWN_ARROW, 250, {}); // focuses "Normal", first menu item
561 robot.keyPress(keys.DOWN_ARROW, 250, {}); // focuses "Outline", second menu item
562 robot.keyPress(keys.DOWN_ARROW, 250, {}); // focuses "Zoom", third menu item
563
564 robot.sequence(d.getTestCallback(function(){
565 doh.is("{Z}oom", registry.getEnclosingWidget(dfocus.curNode).label,
566 "focus on Zoom MenuItem");
567 }), 250);
568
569 return d;
570 }
571 },
572
573 {
574 name: "open the zoom menu",
575 timeout: 5000,
576 runTest: function(){
577 var d = new doh.Deferred();
578
579 robot.keyPress(keys.RIGHT_ARROW, 250, {});
580
581 robot.sequence(d.getTestCallback(function(){
582 doh.is("50%", registry.getEnclosingWidget(dfocus.curNode).label,
583 "focus on Zoom MenuItem");
584 }), 1000);
585
586 return d;
587 }
588 },
589
590 {
591 name: "click to close Zoom menu, focus back to MenuBar",
592 timeout: 5000,
593 runTest: function(){
594 var d = new doh.Deferred();
595
596 // This should move focus to "Edit" in the MenuBar, which then opens
597 // the drop down and focuses on the first item (Cut)
598 robot.keyPress(keys.ENTER, 500, {});
599
600 robot.sequence(d.getTestCallback(function(){
601 doh.is("{V}iew", registry.getEnclosingWidget(dfocus.curNode).label,
602 "focus on first View item in MenuBar");
603 }), 1000);
604
605 return d;
606 }
607 }
608 ]);
609
610 doh.register("dijit.MenuBar MenuBarItem tests", [
611 {
612 name: "navigate to MenuBarItem",
613 timeout: 10000,
614 runTest: function(){
615 var d = new doh.Deferred();
616
617 // Start at the link
618 robot.sequence(function(){
619 dom.byId("link").focus();
620 }, 500, 500);
621
622 // tab to the MenuBar... then focus should automatically shift to "File" menu,
623 robot.keyPress(keys.TAB, 500, {});
624
625 // arrow six times gets to "Click me!"
626 for(var i=0; i<6; i++){
627 robot.keyPress(keys.RIGHT_ARROW, 250, {}); // TODO: use left arrow in RTL mode
628 }
629
630 robot.sequence(d.getTestCallback(function(){
631 doh.is("Click me! (Z)", helpers.innerText(dfocus.curNode),
632 "focus on MenuBarItem");
633 }), 500);
634
635 return d;
636 }
637 },
638 {
639 name: "down arrow",
640 timeout: 5000,
641 runTest: function(){
642 var d = new doh.Deferred();
643
644 // down arrow... should have no effect since there's no menu
645 robot.keyPress(keys.DOWN_ARROW, 250, {});
646
647 robot.sequence(d.getTestCallback(function(){
648 doh.is("Click me! (Z)", helpers.innerText(dfocus.curNode),
649 "focus is still on MenuBarItem");
650 }), 500);
651
652 return d;
653 }
654 },
655 {
656 name: "click",
657 timeout: 5000,
658 runTest: function(){
659 var d = new doh.Deferred();
660
661 var clicked;
662 robot.window.noPopupMenuBarItem.on("click", function(){ clicked = true; });
663
664 robot.keyPress(keys.SPACE, 250, {});
665
666 robot.sequence(d.getTestCallback(function(){
667 doh.t(clicked, "clicked");
668 }), 500);
669
670 return d;
671 }
672 },
673 {
674 name: "right arrow",
675 timeout: 5000,
676 runTest: function(){
677 var d = new doh.Deferred();
678
679 // right arrow show go back to File menu
680 robot.keyPress(keys.RIGHT_ARROW, 250, {});
681
682 robot.sequence(d.getTestCallback(function(){
683 doh.is("File", helpers.innerText(dfocus.curNode), "focus moved to File menu");
684 }), 500);
685
686 return d;
687 }
688 }
689 ]);
690
691 // Run test about opening context menu via keyboard, except on safari/mac where that isn't
692 // possible (#9927)
693 if(!has("mac") || !has("webkit")){
694 var tests = has("mac") ?
695 [
696 {label: "ctrl-space", key: keys.SPACE, options: {ctrl: true}}
697 ] :
698 [
699 {label: "context menu key", key: 525, options: {}}, // 93 in JS but 525 in Java
700 {label: "shift-F10", key: keys.F10, options: {shift: true}}
701 ];
702 doh.register("Context menu keyboard tests", array.map(tests, function(test){
703 return {
704 name: "open global context menu via " + test.label,
705 timeout: 5000,
706 runTest: function(){
707 var d = new doh.Deferred();
708
709 // Focus random element to make sure menu is opened near focus point.
710 robot.sequence(function(){
711 dom.byId("input").focus();
712 }, 500);
713
714 // open via keyboard
715 robot.keyPress(test.key, 500, test.options);
716
717 robot.sequence(d.getTestErrback(function(){
718 var menu = registry.byId("windowContextMenu");
719 doh.t(helpers.isVisible(menu), "menu is now shown");
720
721 var menuCoords = domGeom.position(menu.domNode),
722 aroundCoords = domGeom.position("input");
723
724 // Check that menu's top left corner is near focus point,
725 // rather than upper-left hand corner of browser window.
726 doh.t(menuCoords.x < aroundCoords.x + 100, "x < 100", "actual x: " + menuCoords.x);
727 doh.t(menuCoords.y < aroundCoords.y + 50, "y < 50", "actual y: " + menuCoords.y);
728 doh.t(menuCoords.x >= aroundCoords.x, "x >= 0", "actual x: " + menuCoords.x);
729 doh.t(menuCoords.y >= aroundCoords.y, "y >= 0", "actual y: " + menuCoords.y);
730 doh.t(domClass.contains("windowContextMenuFirstChoice", "dijitMenuItemSelected"),
731 "first choice selected");
732
733 robot.keyPress(keys.ESCAPE, 250, {}); // close context menu
734
735 robot.sequence(d.getTestCallback(function(){
736 doh.t(helpers.isHidden(menu), "menu disappeared");
737 }), 1000);
738 }), 1000);
739
740 return d;
741 }
742 };
743 }));
744 }
745
746 doh.register("Left click menu keyboard tests", {
747 name: "open left click context menu",
748 timeout: 5000,
749 runTest: function(){
750 var d = new doh.Deferred();
751
752 // Tab to node to be opened by keyboard.
753 robot.sequence(function(){
754 dom.byId("input").focus();
755 }, 500);
756 robot.keyPress(keys.TAB, 500);
757
758 // open via keyboard
759 robot.keyPress(keys.SPACE, 500);
760
761 robot.sequence(d.getTestErrback(function(){
762 var menu = registry.byId("leftClickContextMenu");
763 doh.t(helpers.isVisible(menu), "menu is now shown");
764
765 // Check that menu's top is near focus point, rather than upper-left hand corner of browser
766 // window. Since the focus node is on the right of the screen though, it might be to the
767 // left.
768 var menuCoords = domGeom.position(menu.domNode);
769 doh.t(menuCoords.x > 100, "actual x: " + menuCoords.x);
770 doh.t(menuCoords.y > 100, "actual y: " + menuCoords.y);
771 doh.t(domClass.contains("leftClickMenuFirstChoice", "dijitMenuItemSelected"),
772 "first choice selected");
773
774 robot.keyPress(keys.ESCAPE, 250, {}); // close context menu
775
776 robot.sequence(d.getTestCallback(function(){
777 doh.t(helpers.isHidden(menu), "menu disappeared");
778 }), 1000);
779 }), 1000);
780
781 return d;
782 }
783 });
784
785 doh.register("Cancellation (ESCAPE) tests", [
786 {
787 name: "MenuBar selection and cancellation",
788 timeout: 20000,
789 runTest: function(){
790 var d = new doh.Deferred();
791
792 // Start at the link
793 robot.sequence(function(){
794 dom.byId("link").focus();
795 }, 500, 500);
796
797 // tab to the MenuBar... then focus should automatically shift to "File" menu,
798 robot.keyPress(keys.TAB, 500, {});
799
800 robot.keyPress(keys.DOWN_ARROW, 500, {}); // open File menu
801
802 robot.sequence(d.getTestErrback(function(){
803 doh.t(helpers.isVisible("fileMenu"), "File menu should be visible");
804 }), 1000);
805
806 robot.keyPress(keys.ESCAPE, 250, {}); // close File menu
807 robot.sequence(d.getTestErrback(function(){
808 doh.t(helpers.isHidden("fileMenu"), "File menu is hidden after cancel");
809 doh.t(domClass.contains("file", "dijitMenuItemSelected"),
810 "File MenuBarItem should have selected class, actual class is: " + dom.byId("file").className);
811 }), 1000);
812
813 robot.keyPress(keys.RIGHT_ARROW, 250, {}); // move to Edit menu
814 robot.sequence(d.getTestErrback(function(){
815 doh.f(domClass.contains("file", "dijitMenuItemSelected"),
816 "File MenuBarItem should not have selected class, actual class is: " + dom.byId("file").className);
817 doh.t(helpers.isHidden("editMenu"), "Edit menu is hidden after cancel and select");
818 doh.t(domClass.contains("edit", "dijitMenuItemSelected"),
819 "Edit MenuBarItem should have selected class, actual class is: " + dom.byId("edit").className);
820 }), 500);
821
822 robot.typeKeys("e", 250, 1000); // open Edit menu
823 robot.sequence(d.getTestErrback(function(){
824 doh.t(helpers.isVisible("editMenu"), "edit menu appeared");
825 }), 1000);
826
827 robot.typeKeys("p", 250, 300); // select paste
828
829 robot.sequence(d.getTestErrback(function(){
830 doh.t(helpers.isHidden("editMenu"), "edit menu disappeared");
831 }), 1000);
832
833 robot.typeKeys("f", 250, 300); // open File menu
834 robot.sequence(d.getTestErrback(function(){
835 doh.t(helpers.isVisible("fileMenu"), "File menu should be visible");
836 }), 1000);
837
838 robot.keyPress(keys.RIGHT_ARROW, 75, {}); // #9846
839 robot.keyPress(keys.RIGHT_ARROW, 75, {}); // move to View menu
840 robot.keyPress(keys.LEFT_ARROW, 75, {}); // move to Edit menu
841 robot.sequence(d.getTestErrback(function(){
842 doh.t(helpers.isVisible("editMenu"), "Edit menu should be visible and File menu hidden");
843 doh.t(helpers.isHidden("fileMenu"), "File menu should be hidden and Edit menu visible");
844 }), 1000);
845
846 robot.keyPress(keys.ESCAPE, 250, {}); // close Edit menu
847
848 robot.sequence(d.getTestCallback(function(){
849 doh.t(helpers.isHidden("editMenu"), "edit menu disappeared");
850 }), 1000);
851
852 return d;
853 }
854 }
855 ]);
856
857 doh.register("CheckedMenuItem", [
858 {
859 name: "initial conditions",
860 runTest: function(){
861 doh.is("true", registry.byId("checked1").domNode.getAttribute("aria-checked"), "checked1 aria-checked");
862 doh.t(registry.byId("checked1").checked, "checked1 value");
863 doh.is("false", registry.byId("checked2").domNode.getAttribute("aria-checked"), "checked2 aria-checked");
864 doh.f(registry.byId("checked2").checked, "checked2 value");
865 }
866 },
867
868 {
869 name: "nav to checked1",
870 timeout: 10000,
871 runTest: function(){
872 var d = new doh.Deferred();
873
874 // Start at the link
875 robot.sequence(function(){
876 dom.byId("link").focus();
877 }, 500, 500);
878
879 // tab to the MenuBar, then to the left hand menu
880 robot.keyPress(keys.TAB, 500, {});
881 robot.keyPress(keys.TAB, 500, {});
882
883 // down arrow to "checked 1"
884 robot.keyPress(keys.DOWN_ARROW, 500, {});
885 robot.keyPress(keys.DOWN_ARROW, 250, {});
886 robot.keyPress(keys.DOWN_ARROW, 250, {});
887 robot.keyPress(keys.DOWN_ARROW, 250, {});
888 robot.keyPress(keys.DOWN_ARROW, 250, {});
889 robot.keyPress(keys.DOWN_ARROW, 250, {});
890 robot.keyPress(keys.DOWN_ARROW, 250, {});
891
892 robot.sequence(d.getTestCallback(function(){
893 doh.is("checked1", dfocus.curNode.getAttribute("id"), "focus on checked1");
894 }), 1000);
895
896 return d;
897 }
898 },
899
900 {
901 name: "click checked1",
902 timeout: 5000,
903 runTest: function(){
904 var d = new doh.Deferred();
905
906 robot.keyPress(keys.SPACE, 250, {});
907
908 robot.sequence(d.getTestCallback(function(){
909 doh.f(registry.byId("checked1").checked, "checked1 --> unchecked");
910 }), 500);
911
912 return d;
913 }
914 },
915
916 {
917 name: "nav to checked2",
918 timeout: 5000,
919 runTest: function(){
920 var d = new doh.Deferred();
921
922 robot.keyPress(keys.DOWN_ARROW, 250, {});
923
924 robot.sequence(d.getTestCallback(function(){
925 doh.is("checked2", dfocus.curNode.getAttribute("id"), "focus on checked2");
926 }), 500);
927
928 return d;
929 }
930 },
931
932 {
933 name: "click checked2",
934 timeout: 5000,
935 runTest: function(){
936 var d = new doh.Deferred();
937
938 robot.keyPress(keys.SPACE, 250, {});
939
940 robot.sequence(d.getTestCallback(function(){
941 doh.t(registry.byId("checked2").checked, "checked2 --> checked");
942 }), 500);
943
944 return d;
945 }
946 }
947 ]);
948
949 doh.register("keyboard search", [
950 {
951 name: "multi-char search failure",
952 timeout: 9000,
953 runTest: function(){
954 var d = new doh.Deferred();
955 dom.byId("link").focus();
956
957 // tab to the MenuBar, then to the left hand menu
958 robot.keyPress(keys.TAB, 500, {});
959 robot.keyPress(keys.TAB, 500, {});
960 robot.keyPress(keys.DOWN_ARROW, 250, {});
961 robot.keyPress(keys.DOWN_ARROW, 250, {});
962 robot.keyPress(keys.DOWN_ARROW, 250, {});
963 robot.keyPress(keys.DOWN_ARROW, 250, {});
964 robot.keyPress(keys.RIGHT_ARROW, 250, {});
965 robot.typeKeys("sd", 500, 400); // multi-char letter search should fail
966
967 robot.sequence(d.getTestCallback(function(){
968 var menu = registry.byId("navMenuSub2");
969 doh.f(helpers.isVisible(menu), "sub-sub-menu is not shown");
970 }), 500);
971
972 return d;
973 }
974 },
975 {
976 name: "search with SPACE",
977 timeout: 9000,
978 runTest: function(){
979 var d = new doh.Deferred();
980
981 robot.typeKeys("submenu Item t", 600, 2000); // multi letter search should work
982
983 robot.sequence(d.getTestCallback(function(){
984 doh.is("Submenu Item Two", registry.getEnclosingWidget(dfocus.curNode).label, "focus on second MenuItem in sub Menu");
985 }), 500);
986
987 return d;
988 }
989 },
990 {
991 name: "search with full text to make sure it's found",
992 timeout: 9000,
993 runTest: function(){
994 var d = new doh.Deferred();
995
996 robot.typeKeys("sUBMENU iTEM oNE", 600, 3000); // multi letter search should work
997
998 robot.sequence(d.getTestCallback(function(){
999 doh.is("Submenu Item One", registry.getEnclosingWidget(dfocus.curNode).label, "focus on second MenuItem in sub Menu");
1000 }), 500);
1001
1002 return d;
1003 }
1004 },
1005 {
1006 name: "search with full text to make sure it's moving",
1007 timeout: 9000,
1008 runTest: function(){
1009 var d = new doh.Deferred();
1010
1011 robot.typeKeys("submenu item two", 600, 3000); // multi letter search should work
1012
1013 robot.sequence(d.getTestCallback(function(){
1014 doh.is("Submenu Item Two", registry.getEnclosingWidget(dfocus.curNode).label, "focus on second MenuItem in sub Menu");
1015 }), 500);
1016
1017 return d;
1018 }
1019 },
1020 {
1021 name: "search again with the same full text to make sure it's not just picking the next item",
1022 timeout: 9000,
1023 runTest: function(){
1024 var d = new doh.Deferred();
1025
1026 robot.typeKeys("submenu item two", 600, 3000); // multi letter search should work
1027
1028 robot.sequence(d.getTestCallback(function(){
1029 doh.is("Submenu Item Two", registry.getEnclosingWidget(dfocus.curNode).label, "focus on second MenuItem in sub Menu");
1030 }), 500);
1031
1032 return d;
1033 }
1034 },
1035 {
1036 name: "search opens sub-menu",
1037 timeout: 9000,
1038 runTest: function(){
1039 var d = new doh.Deferred();
1040
1041 robot.typeKeys("sds", 600, 3500); // single letter search should work after long delays
1042
1043 robot.sequence(d.getTestCallback(function(){
1044 var menu = registry.byId("navMenuSub2");
1045 doh.t(helpers.isVisible(menu), "sub-sub-menu is shown");
1046 doh.is("Sub-sub-menu Item Two", registry.getEnclosingWidget(dfocus.curNode).label, "focus on second MenuItem in sub-sub Menu");
1047 }), 500);
1048
1049 return d;
1050 }
1051 },
1052 {
1053 name: "SPACE closes menu after keyboard search",
1054 timeout: 9000,
1055 runTest: function(){
1056 var d = new doh.Deferred();
1057
1058 robot.typeKeys(" ", 600, 300);
1059
1060 robot.sequence(d.getTestCallback(function(){
1061 doh.f(helpers.isVisible(registry.byId("navMenuSub1")), "sub-menu is shown");
1062 doh.f(helpers.isVisible(registry.byId("navMenuSub2")), "sub-sub-menu is shown");
1063 }), 500);
1064
1065 return d;
1066 }
1067 }
1068 ]);
1069
1070 doh.run();
1071 });
1072 </script>
1073 </head>
1074 </html>