@@ -43,75 +43,27 @@ test( "hover over a menu item with no sub-menu should close open menu", function
43
43
menuItemWithDropdown . trigger ( "click" ) ;
44
44
menuItemWithoutDropdown . trigger ( "click" ) ;
45
45
46
- equal ( $ ( ".ui-menu:visible" ) . length , 0 , "After triggering a sub-menu, a click on a peer menu item should close the opened sub-menu" ) ;
46
+ equal ( $ ( ".ui-menu:visible" ) . length , 0 , "After triggering a sub-menu, a click on a peer menu item should close the opened sub-menu" ) ;
47
47
} ) ;
48
48
49
- test ( "_findNextFocusableTarget should find one and only one item" , function ( ) {
50
- expect ( 2 ) ;
51
-
52
- var element = $ ( "#bar1" ) . menubar ( ) ,
53
- menubarWidget = element . data ( "ui-menubar" ) ,
54
- firstMenuItem = $ ( "#bar1 .ui-menubar-item" ) . eq ( 0 ) ,
55
- expectedFocusableTarget = $ ( "#bar1 .ui-menubar-item .ui-widget" ) . eq ( 0 ) ,
56
- result = menubarWidget . _findNextFocusableTarget ( firstMenuItem ) ;
57
-
58
- equal ( expectedFocusableTarget [ 0 ] , result [ 0 ] , "_findNextFocusableTarget should return the focusable element underneath the menuItem" ) ;
59
- equal ( 1 , result . length , "One and only one item should be returned." ) ;
60
- } ) ;
61
-
62
- asyncTest ( "TAB order should be sane mirroring dialog's test" , function ( ) {
63
- expect ( 3 ) ;
49
+ test ( "Cursor keys should move focus within the menu items" , function ( ) {
50
+ expect ( 6 ) ;
64
51
65
52
var element = $ ( "#bar1" ) . menubar ( ) ,
66
- firstMenuItem = $ ( "#bar1 .ui-menubar-item .ui-button:first" ) ;
67
-
68
- function checkTab ( ) {
69
- setTimeout ( start ) ;
70
- ok ( ! firstMenuItem . hasClass ( "ui-state-focus" ) , "The manually focused item should no longer have focus after TAB" ) ;
71
- //setTimeout( start );
72
- }
53
+ firstMenuItem = $ ( "#bar1 .ui-menubar-item .ui-button:first" ) ,
54
+ nextLeftwardMenuElement = firstMenuItem . parent ( ) . siblings ( ) . last ( ) . children ( ) . eq ( 0 ) ;
73
55
56
+ equal ( element . find ( ":tabbable" ) . length , 1 , "A Menubar should have 1 tabbable element on init." ) ;
74
57
firstMenuItem [ 0 ] . focus ( ) ;
75
- ok ( $ ( firstMenuItem ) . hasClass ( "ui-state-focus" ) , "Should have focus class" ) ;
76
-
77
- setTimeout ( function ( ) {
78
- equal ( document . activeElement , firstMenuItem [ 0 ] , "Focus set on first menuItem" ) ;
79
- $ ( document . activeElement ) . simulate ( "keydown" , { keyCode : $ . ui . keyCode . TAB } ) ;
80
- setTimeout ( checkTab ) ;
81
- } )
82
-
83
- } ) ;
84
-
85
- asyncTest ( "TAB order should be sane" , function ( ) {
86
- expect ( 3 ) ;
87
-
88
-
89
- var element = $ ( "#bar1" ) . menubar ( ) ,
90
- debugDelay = 0 ,
91
- firstMenuItem = $ ( "#bar1 .ui-menubar-item .ui-button:first" ) ;
92
-
93
- /* Make the qunit fixture visible if we're debugging this test*/
94
- if ( debugDelay ) {
95
- $ ( '<link rel="stylesheet" href="../../../themes/base/jquery.ui.all.css" />' ) . appendTo ( "head" ) ;
96
- $ ( "#qunit-fixture" ) . css ( { right : "300px" , top : "300px" , left :0 } ) ;
97
- }
98
-
99
- setTimeout ( function ( ) {
100
- firstMenuItem [ 0 ] . focus ( ) ;
101
58
102
- function postFocus ( ) {
103
- ok ( ! firstMenuItem . hasClass ( "ui-state-focus" ) , "The manually focused item should no longer have focus after TAB" ) ;
104
- setTimeout ( start ) ;
105
- } ;
59
+ ok ( firstMenuItem . hasClass ( "ui-state-focus" ) , "After a focus event, the first element should have the focus class." ) ;
60
+ $ ( document . activeElement ) . simulate ( "keydown" , { keyCode : $ . ui . keyCode . LEFT } ) ;
106
61
107
- setTimeout ( function ( ) {
108
- ok ( firstMenuItem . hasClass ( "ui-state-focus" ) , "Should have focus class" ) ;
109
- equal ( document . activeElement , firstMenuItem , "Focus set on first menuItem" ) ;
110
- $ ( document . activeElement ) . simulate ( "keydown" , { keyCode : $ . ui . keyCode . TAB } ) ;
111
- setTimeout ( postFocus ) ;
112
- } ) ;
113
62
114
- } , debugDelay ) ;
63
+ ok ( ! firstMenuItem . hasClass ( "ui-state-focus" ) , "After a keypress event, the first element, should no longer have the focus class." ) ;
64
+ ok ( nextLeftwardMenuElement . hasClass ( "ui-state-focus" ) , "After a LEFT cursor event from the first element, the last element should have focus." ) ;
65
+ equal ( element . find ( ":tabbable" ) . length , 1 , "A Menubar, after a cursor key action, should have 1 tabbable." ) ;
66
+ equal ( element . find ( ":tabbable" ) [ 0 ] , nextLeftwardMenuElement [ 0 ] , "A Menubar, after a cursor key action, should have 1 tabbable." ) ;
115
67
116
68
} ) ;
117
69
0 commit comments