@@ -110,38 +110,81 @@ asyncTest( "keyboard support", function() {
110
110
keyCode = $ . ui . keyCode ;
111
111
equal ( headers . filter ( ".ui-state-focus" ) . length , 0 , "no headers focused on init" ) ;
112
112
headers . eq ( 0 ) . simulate ( "focus" ) ;
113
- setTimeout ( function ( ) {
113
+ setTimeout ( step1 ) ;
114
+
115
+ function step1 ( ) {
114
116
ok ( headers . eq ( 0 ) . is ( ".ui-state-focus" ) , "first header has focus" ) ;
115
117
headers . eq ( 0 ) . simulate ( "keydown" , { keyCode : keyCode . DOWN } ) ;
118
+ setTimeout ( step2 ) ;
119
+ }
120
+
121
+ // Support: IE 11 with jQuery 1.7 - 1.8 only
122
+ // All of the setTimeouts() from keydowns aren't necessary with newer jQuery.
123
+ // Only the explicit focus simulations require them.
124
+ function step2 ( ) {
116
125
ok ( headers . eq ( 1 ) . is ( ".ui-state-focus" ) , "DOWN moves focus to next header" ) ;
117
126
headers . eq ( 1 ) . simulate ( "keydown" , { keyCode : keyCode . RIGHT } ) ;
127
+ setTimeout ( step3 ) ;
128
+ }
129
+
130
+ function step3 ( ) {
118
131
ok ( headers . eq ( 2 ) . is ( ".ui-state-focus" ) , "RIGHT moves focus to next header" ) ;
119
132
headers . eq ( 2 ) . simulate ( "keydown" , { keyCode : keyCode . DOWN } ) ;
120
- ok ( headers . eq ( 0 ) . is ( ".ui-state-focus" ) , "DOWN wraps focus to first header" ) ;
133
+ setTimeout ( step4 ) ;
134
+ }
121
135
136
+ function step4 ( ) {
137
+ ok ( headers . eq ( 0 ) . is ( ".ui-state-focus" ) , "DOWN wraps focus to first header" ) ;
122
138
headers . eq ( 0 ) . simulate ( "keydown" , { keyCode : keyCode . UP } ) ;
139
+ setTimeout ( step5 ) ;
140
+ }
141
+
142
+ function step5 ( ) {
123
143
ok ( headers . eq ( 2 ) . is ( ".ui-state-focus" ) , "UP wraps focus to last header" ) ;
124
144
headers . eq ( 2 ) . simulate ( "keydown" , { keyCode : keyCode . LEFT } ) ;
125
- ok ( headers . eq ( 1 ) . is ( ".ui-state-focus" ) , "LEFT moves focus to previous header" ) ;
145
+ setTimeout ( step6 ) ;
146
+ }
126
147
148
+ function step6 ( ) {
149
+ ok ( headers . eq ( 1 ) . is ( ".ui-state-focus" ) , "LEFT moves focus to previous header" ) ;
127
150
headers . eq ( 1 ) . simulate ( "keydown" , { keyCode : keyCode . HOME } ) ;
151
+ setTimeout ( step7 ) ;
152
+ }
153
+
154
+ function step7 ( ) {
128
155
ok ( headers . eq ( 0 ) . is ( ".ui-state-focus" ) , "HOME moves focus to first header" ) ;
129
156
headers . eq ( 0 ) . simulate ( "keydown" , { keyCode : keyCode . END } ) ;
130
- ok ( headers . eq ( 2 ) . is ( ".ui-state-focus" ) , "END moves focus to last header" ) ;
157
+ setTimeout ( step8 ) ;
158
+ }
131
159
160
+ function step8 ( ) {
161
+ ok ( headers . eq ( 2 ) . is ( ".ui-state-focus" ) , "END moves focus to last header" ) ;
132
162
headers . eq ( 2 ) . simulate ( "keydown" , { keyCode : keyCode . ENTER } ) ;
163
+ setTimeout ( step9 ) ;
164
+ }
165
+
166
+ function step9 ( ) {
133
167
equal ( element . accordion ( "option" , "active" ) , 2 , "ENTER activates panel" ) ;
134
168
headers . eq ( 1 ) . simulate ( "keydown" , { keyCode : keyCode . SPACE } ) ;
135
- equal ( element . accordion ( "option" , "active" ) , 1 , "SPACE activates panel" ) ;
169
+ setTimeout ( step10 ) ;
170
+ }
136
171
172
+ function step10 ( ) {
173
+ equal ( element . accordion ( "option" , "active" ) , 1 , "SPACE activates panel" ) ;
137
174
anchor . simulate ( "focus" ) ;
138
- setTimeout ( function ( ) {
139
- ok ( ! headers . eq ( 1 ) . is ( ".ui-state-focus" ) , "header loses focus when focusing inside the panel" ) ;
140
- anchor . simulate ( "keydown" , { keyCode : keyCode . UP , ctrlKey : true } ) ;
141
- ok ( headers . eq ( 1 ) . is ( ".ui-state-focus" ) , "CTRL+UP moves focus to header" ) ;
142
- start ( ) ;
143
- } , 1 ) ;
144
- } , 1 ) ;
175
+ setTimeout ( step11 ) ;
176
+ }
177
+
178
+ function step11 ( ) {
179
+ ok ( ! headers . eq ( 1 ) . is ( ".ui-state-focus" ) , "header loses focus when focusing inside the panel" ) ;
180
+ anchor . simulate ( "keydown" , { keyCode : keyCode . UP , ctrlKey : true } ) ;
181
+ setTimeout ( step12 ) ;
182
+ }
183
+
184
+ function step12 ( ) {
185
+ ok ( headers . eq ( 1 ) . is ( ".ui-state-focus" ) , "CTRL+UP moves focus to header" ) ;
186
+ start ( ) ;
187
+ }
145
188
} ) ;
146
189
147
190
} ( jQuery ) ) ;
0 commit comments