mirror of
https://github.com/jquery/jquery-ui.git
synced 2025-01-07 20:34:24 +00:00
Menu tests: Better handling of async focus in IE.
This commit is contained in:
parent
020abcf8a9
commit
694987f2f7
@ -87,7 +87,7 @@ asyncTest( "handle blur via click outside", function() {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
test( "handle focus of menu with active item", function() {
|
asyncTest( "handle focus of menu with active item", function() {
|
||||||
expect( 1 );
|
expect( 1 );
|
||||||
var element = $( "#menu1" ).menu({
|
var element = $( "#menu1" ).menu({
|
||||||
focus: function( event ) {
|
focus: function( event ) {
|
||||||
@ -96,11 +96,19 @@ test( "handle focus of menu with active item", function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
log( "focus", true );
|
log( "focus", true );
|
||||||
element.focus();
|
element[0].focus();
|
||||||
element.simulate( "keydown", { keyCode: $.ui.keyCode.DOWN } );
|
setTimeout(function() {
|
||||||
element.simulate( "keydown", { keyCode: $.ui.keyCode.DOWN } );
|
element.simulate( "keydown", { keyCode: $.ui.keyCode.DOWN } );
|
||||||
element.focus();
|
element.simulate( "keydown", { keyCode: $.ui.keyCode.DOWN } );
|
||||||
equal( logOutput(), "focus,0,1,2,2", "current active item remains active" );
|
element[0].blur();
|
||||||
|
setTimeout(function() {
|
||||||
|
element[0].focus();
|
||||||
|
setTimeout(function() {
|
||||||
|
equal( logOutput(), "focus,0,1,2,2", "current active item remains active" );
|
||||||
|
start();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
asyncTest( "handle submenu auto collapse: mouseleave", function() {
|
asyncTest( "handle submenu auto collapse: mouseleave", function() {
|
||||||
@ -162,7 +170,7 @@ asyncTest( "handle submenu auto collapse: mouseleave", function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
test( "handle keyboard navigation on menu without scroll and without submenus", function() {
|
asyncTest( "handle keyboard navigation on menu without scroll and without submenus", function() {
|
||||||
expect( 12 );
|
expect( 12 );
|
||||||
var element = $( "#menu1" ).menu({
|
var element = $( "#menu1" ).menu({
|
||||||
select: function( event, ui ) {
|
select: function( event, ui ) {
|
||||||
@ -174,54 +182,58 @@ test( "handle keyboard navigation on menu without scroll and without submenus",
|
|||||||
});
|
});
|
||||||
|
|
||||||
log( "keydown", true );
|
log( "keydown", true );
|
||||||
element.focus();
|
element[0].focus();
|
||||||
element.simulate( "keydown", { keyCode: $.ui.keyCode.DOWN } );
|
setTimeout(function() {
|
||||||
element.simulate( "keydown", { keyCode: $.ui.keyCode.DOWN } );
|
element.simulate( "keydown", { keyCode: $.ui.keyCode.DOWN } );
|
||||||
equal( logOutput(), "keydown,0,1,2", "Keydown DOWN" );
|
element.simulate( "keydown", { keyCode: $.ui.keyCode.DOWN } );
|
||||||
|
equal( logOutput(), "keydown,0,1,2", "Keydown DOWN" );
|
||||||
|
|
||||||
log( "keydown", true );
|
log( "keydown", true );
|
||||||
element.simulate( "keydown", { keyCode: $.ui.keyCode.UP } );
|
element.simulate( "keydown", { keyCode: $.ui.keyCode.UP } );
|
||||||
equal( logOutput(), "keydown,1", "Keydown UP" );
|
equal( logOutput(), "keydown,1", "Keydown UP" );
|
||||||
|
|
||||||
log( "keydown", true );
|
log( "keydown", true );
|
||||||
element.simulate( "keydown", { keyCode: $.ui.keyCode.LEFT } );
|
element.simulate( "keydown", { keyCode: $.ui.keyCode.LEFT } );
|
||||||
equal( logOutput(), "keydown", "Keydown LEFT (no effect)" );
|
equal( logOutput(), "keydown", "Keydown LEFT (no effect)" );
|
||||||
|
|
||||||
log( "keydown", true );
|
log( "keydown", true );
|
||||||
element.simulate( "keydown", { keyCode: $.ui.keyCode.RIGHT } );
|
element.simulate( "keydown", { keyCode: $.ui.keyCode.RIGHT } );
|
||||||
equal( logOutput(), "keydown", "Keydown RIGHT (no effect)" );
|
equal( logOutput(), "keydown", "Keydown RIGHT (no effect)" );
|
||||||
|
|
||||||
log( "keydown", true );
|
log( "keydown", true );
|
||||||
element.simulate( "keydown", { keyCode: $.ui.keyCode.PAGE_DOWN } );
|
element.simulate( "keydown", { keyCode: $.ui.keyCode.PAGE_DOWN } );
|
||||||
equal( logOutput(), "keydown,4", "Keydown PAGE_DOWN" );
|
equal( logOutput(), "keydown,4", "Keydown PAGE_DOWN" );
|
||||||
|
|
||||||
log( "keydown", true );
|
log( "keydown", true );
|
||||||
element.simulate( "keydown", { keyCode: $.ui.keyCode.PAGE_DOWN } );
|
element.simulate( "keydown", { keyCode: $.ui.keyCode.PAGE_DOWN } );
|
||||||
equal( logOutput(), "keydown", "Keydown PAGE_DOWN (no effect)" );
|
equal( logOutput(), "keydown", "Keydown PAGE_DOWN (no effect)" );
|
||||||
|
|
||||||
log( "keydown", true );
|
log( "keydown", true );
|
||||||
element.simulate( "keydown", { keyCode: $.ui.keyCode.PAGE_UP } );
|
element.simulate( "keydown", { keyCode: $.ui.keyCode.PAGE_UP } );
|
||||||
equal( logOutput(), "keydown,0", "Keydown PAGE_UP" );
|
equal( logOutput(), "keydown,0", "Keydown PAGE_UP" );
|
||||||
|
|
||||||
log( "keydown", true );
|
log( "keydown", true );
|
||||||
element.simulate( "keydown", { keyCode: $.ui.keyCode.PAGE_UP } );
|
element.simulate( "keydown", { keyCode: $.ui.keyCode.PAGE_UP } );
|
||||||
equal( logOutput(), "keydown", "Keydown PAGE_UP (no effect)" );
|
equal( logOutput(), "keydown", "Keydown PAGE_UP (no effect)" );
|
||||||
|
|
||||||
log( "keydown", true );
|
log( "keydown", true );
|
||||||
element.simulate( "keydown", { keyCode: $.ui.keyCode.END } );
|
element.simulate( "keydown", { keyCode: $.ui.keyCode.END } );
|
||||||
equal( logOutput(), "keydown,4", "Keydown END" );
|
equal( logOutput(), "keydown,4", "Keydown END" );
|
||||||
|
|
||||||
log( "keydown", true );
|
log( "keydown", true );
|
||||||
element.simulate( "keydown", { keyCode: $.ui.keyCode.HOME } );
|
element.simulate( "keydown", { keyCode: $.ui.keyCode.HOME } );
|
||||||
equal( logOutput(), "keydown,0", "Keydown HOME" );
|
equal( logOutput(), "keydown,0", "Keydown HOME" );
|
||||||
|
|
||||||
log( "keydown", true );
|
log( "keydown", true );
|
||||||
element.simulate( "keydown", { keyCode: $.ui.keyCode.ESCAPE } );
|
element.simulate( "keydown", { keyCode: $.ui.keyCode.ESCAPE } );
|
||||||
equal( logOutput(), "keydown", "Keydown ESCAPE (no effect)" );
|
equal( logOutput(), "keydown", "Keydown ESCAPE (no effect)" );
|
||||||
|
|
||||||
log( "keydown", true );
|
log( "keydown", true );
|
||||||
element.simulate( "keydown", { keyCode: $.ui.keyCode.ENTER } );
|
element.simulate( "keydown", { keyCode: $.ui.keyCode.ENTER } );
|
||||||
equal( logOutput(), "keydown,Aberdeen", "Keydown ENTER" );
|
equal( logOutput(), "keydown,Aberdeen", "Keydown ENTER" );
|
||||||
|
|
||||||
|
start();
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
asyncTest( "handle keyboard navigation on menu without scroll and with submenus", function() {
|
asyncTest( "handle keyboard navigation on menu without scroll and with submenus", function() {
|
||||||
@ -344,7 +356,7 @@ asyncTest( "handle keyboard navigation on menu without scroll and with submenus"
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
test( "handle keyboard navigation on menu with scroll and without submenus", function() {
|
asyncTest( "handle keyboard navigation on menu with scroll and without submenus", function() {
|
||||||
expect( 14 );
|
expect( 14 );
|
||||||
var element = $( "#menu3" ).menu({
|
var element = $( "#menu3" ).menu({
|
||||||
select: function( event, ui ) {
|
select: function( event, ui ) {
|
||||||
@ -356,63 +368,67 @@ test( "handle keyboard navigation on menu with scroll and without submenus", fun
|
|||||||
});
|
});
|
||||||
|
|
||||||
log( "keydown", true );
|
log( "keydown", true );
|
||||||
element.focus();
|
element[0].focus();
|
||||||
element.simulate( "keydown", { keyCode: $.ui.keyCode.DOWN } );
|
setTimeout(function() {
|
||||||
element.simulate( "keydown", { keyCode: $.ui.keyCode.DOWN } );
|
element.simulate( "keydown", { keyCode: $.ui.keyCode.DOWN } );
|
||||||
equal( logOutput(), "keydown,0,1,2", "Keydown DOWN" );
|
element.simulate( "keydown", { keyCode: $.ui.keyCode.DOWN } );
|
||||||
|
equal( logOutput(), "keydown,0,1,2", "Keydown DOWN" );
|
||||||
|
|
||||||
log( "keydown", true );
|
log( "keydown", true );
|
||||||
element.simulate( "keydown", { keyCode: $.ui.keyCode.UP } );
|
element.simulate( "keydown", { keyCode: $.ui.keyCode.UP } );
|
||||||
element.simulate( "keydown", { keyCode: $.ui.keyCode.UP } );
|
element.simulate( "keydown", { keyCode: $.ui.keyCode.UP } );
|
||||||
equal( logOutput(), "keydown,1,0", "Keydown UP" );
|
equal( logOutput(), "keydown,1,0", "Keydown UP" );
|
||||||
|
|
||||||
log( "keydown", true );
|
log( "keydown", true );
|
||||||
element.simulate( "keydown", { keyCode: $.ui.keyCode.LEFT } );
|
element.simulate( "keydown", { keyCode: $.ui.keyCode.LEFT } );
|
||||||
equal( logOutput(), "keydown", "Keydown LEFT (no effect)" );
|
equal( logOutput(), "keydown", "Keydown LEFT (no effect)" );
|
||||||
|
|
||||||
log( "keydown", true );
|
log( "keydown", true );
|
||||||
element.simulate( "keydown", { keyCode: $.ui.keyCode.RIGHT } );
|
element.simulate( "keydown", { keyCode: $.ui.keyCode.RIGHT } );
|
||||||
equal( logOutput(), "keydown", "Keydown RIGHT (no effect)" );
|
equal( logOutput(), "keydown", "Keydown RIGHT (no effect)" );
|
||||||
|
|
||||||
log( "keydown", true );
|
log( "keydown", true );
|
||||||
element.simulate( "keydown", { keyCode: $.ui.keyCode.PAGE_DOWN } );
|
element.simulate( "keydown", { keyCode: $.ui.keyCode.PAGE_DOWN } );
|
||||||
equal( logOutput(), "keydown,10", "Keydown PAGE_DOWN" );
|
equal( logOutput(), "keydown,10", "Keydown PAGE_DOWN" );
|
||||||
|
|
||||||
log( "keydown", true );
|
log( "keydown", true );
|
||||||
element.simulate( "keydown", { keyCode: $.ui.keyCode.PAGE_DOWN } );
|
element.simulate( "keydown", { keyCode: $.ui.keyCode.PAGE_DOWN } );
|
||||||
equal( logOutput(), "keydown,20", "Keydown PAGE_DOWN" );
|
equal( logOutput(), "keydown,20", "Keydown PAGE_DOWN" );
|
||||||
|
|
||||||
log( "keydown", true );
|
log( "keydown", true );
|
||||||
element.simulate( "keydown", { keyCode: $.ui.keyCode.PAGE_UP } );
|
element.simulate( "keydown", { keyCode: $.ui.keyCode.PAGE_UP } );
|
||||||
equal( logOutput(), "keydown,10", "Keydown PAGE_UP" );
|
equal( logOutput(), "keydown,10", "Keydown PAGE_UP" );
|
||||||
|
|
||||||
log( "keydown", true );
|
log( "keydown", true );
|
||||||
element.simulate( "keydown", { keyCode: $.ui.keyCode.PAGE_UP } );
|
element.simulate( "keydown", { keyCode: $.ui.keyCode.PAGE_UP } );
|
||||||
equal( logOutput(), "keydown,0", "Keydown PAGE_UP" );
|
equal( logOutput(), "keydown,0", "Keydown PAGE_UP" );
|
||||||
|
|
||||||
log( "keydown", true );
|
log( "keydown", true );
|
||||||
element.simulate( "keydown", { keyCode: $.ui.keyCode.PAGE_UP } );
|
element.simulate( "keydown", { keyCode: $.ui.keyCode.PAGE_UP } );
|
||||||
equal( logOutput(), "keydown", "Keydown PAGE_UP (no effect)" );
|
equal( logOutput(), "keydown", "Keydown PAGE_UP (no effect)" );
|
||||||
|
|
||||||
log( "keydown", true );
|
log( "keydown", true );
|
||||||
element.simulate( "keydown", { keyCode: $.ui.keyCode.END } );
|
element.simulate( "keydown", { keyCode: $.ui.keyCode.END } );
|
||||||
equal( logOutput(), "keydown,37", "Keydown END" );
|
equal( logOutput(), "keydown,37", "Keydown END" );
|
||||||
|
|
||||||
log( "keydown", true );
|
log( "keydown", true );
|
||||||
element.simulate( "keydown", { keyCode: $.ui.keyCode.PAGE_DOWN } );
|
element.simulate( "keydown", { keyCode: $.ui.keyCode.PAGE_DOWN } );
|
||||||
equal( logOutput(), "keydown", "Keydown PAGE_DOWN (no effect)" );
|
equal( logOutput(), "keydown", "Keydown PAGE_DOWN (no effect)" );
|
||||||
|
|
||||||
log( "keydown", true );
|
log( "keydown", true );
|
||||||
element.simulate( "keydown", { keyCode: $.ui.keyCode.HOME } );
|
element.simulate( "keydown", { keyCode: $.ui.keyCode.HOME } );
|
||||||
equal( logOutput(), "keydown,0", "Keydown HOME" );
|
equal( logOutput(), "keydown,0", "Keydown HOME" );
|
||||||
|
|
||||||
log( "keydown", true );
|
log( "keydown", true );
|
||||||
element.simulate( "keydown", { keyCode: $.ui.keyCode.ESCAPE } );
|
element.simulate( "keydown", { keyCode: $.ui.keyCode.ESCAPE } );
|
||||||
equal( logOutput(), "keydown", "Keydown ESCAPE (no effect)" );
|
equal( logOutput(), "keydown", "Keydown ESCAPE (no effect)" );
|
||||||
|
|
||||||
log( "keydown", true );
|
log( "keydown", true );
|
||||||
element.simulate( "keydown", { keyCode: $.ui.keyCode.ENTER } );
|
element.simulate( "keydown", { keyCode: $.ui.keyCode.ENTER } );
|
||||||
equal( logOutput(), "keydown,Aberdeen", "Keydown ENTER" );
|
equal( logOutput(), "keydown,Aberdeen", "Keydown ENTER" );
|
||||||
|
|
||||||
|
start();
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
asyncTest( "handle keyboard navigation on menu with scroll and with submenus", function() {
|
asyncTest( "handle keyboard navigation on menu with scroll and with submenus", function() {
|
||||||
@ -561,7 +577,7 @@ asyncTest( "handle keyboard navigation and mouse click on menu with disabled ite
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
test( "handle keyboard navigation with spelling of menu items", function() {
|
asyncTest( "handle keyboard navigation with spelling of menu items", function() {
|
||||||
expect( 2 );
|
expect( 2 );
|
||||||
var element = $( "#menu2" ).menu({
|
var element = $( "#menu2" ).menu({
|
||||||
focus: function( event ) {
|
focus: function( event ) {
|
||||||
@ -577,8 +593,9 @@ test( "handle keyboard navigation with spelling of menu items", function() {
|
|||||||
equal( logOutput(), "keydown,0,1,3", "Keydown focus Addyston by spelling the first 3 letters" );
|
equal( logOutput(), "keydown,0,1,3", "Keydown focus Addyston by spelling the first 3 letters" );
|
||||||
element.simulate( "keydown", { keyCode: 68 } );
|
element.simulate( "keydown", { keyCode: 68 } );
|
||||||
equal( logOutput(), "keydown,0,1,3,4", "Keydown focus Delphi by repeating the 'd' again" );
|
equal( logOutput(), "keydown,0,1,3,4", "Keydown focus Delphi by repeating the 'd' again" );
|
||||||
|
start();
|
||||||
});
|
});
|
||||||
element.focus();
|
element[0].focus();
|
||||||
});
|
});
|
||||||
|
|
||||||
})( jQuery );
|
})( jQuery );
|
||||||
|
Loading…
Reference in New Issue
Block a user