asyncTest( "Prevent tabbing out of dialogs", function() {
expect( 3 );
- var element = $( "<div><input><input></div>" ).dialog(),
- inputs = element.find( "input" ),
- widget = element.dialog( "widget" )[ 0 ];
+ var element = $( "<div><input name='0'><input name='1'></div>" ).dialog(),
+ inputs = element.find( "input" );
+
+ // Remove close button to test focus on just the two buttons
+ element.dialog( "widget" ).find( ".ui-button").remove();
function checkTab() {
- ok( $.contains( widget, document.activeElement ), "Tab key event moved focus within the modal" );
+ equal( document.activeElement, inputs[ 0 ], "Tab key event moved focus within the modal" );
// check shift tab
$( document.activeElement ).simulate( "keydown", { keyCode: $.ui.keyCode.TAB, shiftKey: true });
}
function checkShiftTab() {
- ok( $.contains( widget, document.activeElement ), "Shift-Tab key event moved focus within the modal" );
+ equal( document.activeElement, inputs[ 1 ], "Shift-Tab key event moved focus back to second input" );
element.remove();
setTimeout( start );
}
- inputs[1].focus();
+ inputs[ 1 ].focus();
setTimeout(function() {
- equal( document.activeElement, inputs[1], "Focus set on second input" );
+ equal( document.activeElement, inputs[ 1 ], "Focus set on second input" );
inputs.eq( 1 ).simulate( "keydown", { keyCode: $.ui.keyCode.TAB });
setTimeout( checkTab );