aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorJörn Zaefferer <joern.zaefferer@gmail.com>2014-06-10 12:38:26 +0200
committerJörn Zaefferer <joern.zaefferer@gmail.com>2014-06-10 13:54:58 +0200
commita0b84767a76098cdcc6375dfe28a7fee866bd395 (patch)
treec4fe087eefac47e109342f09b635fabc18057597 /tests
parentc31d5f06881069bae73b09c069a45b9d74c28bfe (diff)
downloadjquery-ui-a0b84767a76098cdcc6375dfe28a7fee866bd395.tar.gz
jquery-ui-a0b84767a76098cdcc6375dfe28a7fee866bd395.zip
Dialog: Fix shift-tab handling, focus the correct element
Copy-paste error introduced in df6110c0d424ff3306fdd5576011f2dcf4d242d0 Updates the tabbing test to be more specific about which element should have focus, instead of only checking if focus is within the dialog. Ref #9646 Ref #10103 Closes gh-1264
Diffstat (limited to 'tests')
-rw-r--r--tests/unit/dialog/dialog_core.js16
1 files changed, 9 insertions, 7 deletions
diff --git a/tests/unit/dialog/dialog_core.js b/tests/unit/dialog/dialog_core.js
index c08019da9..c97f9585b 100644
--- a/tests/unit/dialog/dialog_core.js
+++ b/tests/unit/dialog/dialog_core.js
@@ -140,12 +140,14 @@ test( "#7960: resizable handles below modal overlays", function() {
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 });
@@ -153,15 +155,15 @@ asyncTest( "Prevent tabbing out of dialogs", function() {
}
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 );