Skip to content

Commit b2aa641

Browse files
committed
Accordion: Fix tests in IE 11 with jQuery 1.7-1.8
Closes jquerygh-1482 (cherry picked from commit 8ea36f5)
1 parent 82d4e60 commit b2aa641

File tree

1 file changed

+55
-12
lines changed

1 file changed

+55
-12
lines changed

tests/unit/accordion/accordion_core.js

Lines changed: 55 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -110,38 +110,81 @@ asyncTest( "keyboard support", function() {
110110
keyCode = $.ui.keyCode;
111111
equal( headers.filter( ".ui-state-focus" ).length, 0, "no headers focused on init" );
112112
headers.eq( 0 ).simulate( "focus" );
113-
setTimeout(function() {
113+
setTimeout( step1 );
114+
115+
function step1() {
114116
ok( headers.eq( 0 ).is( ".ui-state-focus" ), "first header has focus" );
115117
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() {
116125
ok( headers.eq( 1 ).is( ".ui-state-focus" ), "DOWN moves focus to next header" );
117126
headers.eq( 1 ).simulate( "keydown", { keyCode: keyCode.RIGHT } );
127+
setTimeout( step3 );
128+
}
129+
130+
function step3() {
118131
ok( headers.eq( 2 ).is( ".ui-state-focus" ), "RIGHT moves focus to next header" );
119132
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+
}
121135

136+
function step4() {
137+
ok( headers.eq( 0 ).is( ".ui-state-focus" ), "DOWN wraps focus to first header" );
122138
headers.eq( 0 ).simulate( "keydown", { keyCode: keyCode.UP } );
139+
setTimeout( step5 );
140+
}
141+
142+
function step5() {
123143
ok( headers.eq( 2 ).is( ".ui-state-focus" ), "UP wraps focus to last header" );
124144
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+
}
126147

148+
function step6() {
149+
ok( headers.eq( 1 ).is( ".ui-state-focus" ), "LEFT moves focus to previous header" );
127150
headers.eq( 1 ).simulate( "keydown", { keyCode: keyCode.HOME } );
151+
setTimeout( step7 );
152+
}
153+
154+
function step7() {
128155
ok( headers.eq( 0 ).is( ".ui-state-focus" ), "HOME moves focus to first header" );
129156
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+
}
131159

160+
function step8() {
161+
ok( headers.eq( 2 ).is( ".ui-state-focus" ), "END moves focus to last header" );
132162
headers.eq( 2 ).simulate( "keydown", { keyCode: keyCode.ENTER } );
163+
setTimeout( step9 );
164+
}
165+
166+
function step9() {
133167
equal( element.accordion( "option", "active" ) , 2, "ENTER activates panel" );
134168
headers.eq( 1 ).simulate( "keydown", { keyCode: keyCode.SPACE } );
135-
equal( element.accordion( "option", "active" ), 1, "SPACE activates panel" );
169+
setTimeout( step10 );
170+
}
136171

172+
function step10() {
173+
equal( element.accordion( "option", "active" ), 1, "SPACE activates panel" );
137174
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+
}
145188
});
146189

147190
}( jQuery ) );

0 commit comments

Comments
 (0)