aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorJörn Zaefferer <joern.zaefferer@gmail.com>2014-06-10 13:51:25 +0200
committerJörn Zaefferer <joern.zaefferer@gmail.com>2014-06-10 13:59:45 +0200
commit226cc3e9e57c7591ff6a2ee02ffed52ac97786a9 (patch)
treee104fd5bb3b470d47c913917dbbbcd1ae4f89969 /tests
parenta0b84767a76098cdcc6375dfe28a7fee866bd395 (diff)
downloadjquery-ui-226cc3e9e57c7591ff6a2ee02ffed52ac97786a9.tar.gz
jquery-ui-226cc3e9e57c7591ff6a2ee02ffed52ac97786a9.zip
Dialog: Honor preventDefault when managing focus
If event.isDefaultPrevented() is true, the focus management is completely skipped, assuming the user manages focus manually. Fixes #10103 Closes gh-1265
Diffstat (limited to 'tests')
-rw-r--r--tests/unit/dialog/dialog_core.js27
1 files changed, 25 insertions, 2 deletions
diff --git a/tests/unit/dialog/dialog_core.js b/tests/unit/dialog/dialog_core.js
index c97f9585b..d72fef7b5 100644
--- a/tests/unit/dialog/dialog_core.js
+++ b/tests/unit/dialog/dialog_core.js
@@ -41,7 +41,7 @@ test("widget method", function() {
});
asyncTest( "focus tabbable", function() {
- expect( 6 );
+ expect( 8 );
var element,
options = {
buttons: [{
@@ -118,7 +118,30 @@ asyncTest( "focus tabbable", function() {
setTimeout(function() {
equal( document.activeElement, element.parent()[ 0 ], "6. the dialog itself" );
element.remove();
- start();
+ setTimeout( step7 );
+ });
+ }
+
+ function step7() {
+ element = $( "<div><input name='0'><input name='1' autofocus></div>" ).dialog({
+ open: function() {
+ var inputs = $( this ).find( "input" );
+ inputs.last().keydown(function( event ) {
+ event.preventDefault();
+ inputs.first().focus();
+ });
+ }
+ });
+ setTimeout(function() {
+ var inputs = element.find( "input" );
+ equal( document.activeElement, inputs[ 1 ], "Focus starts on second input" );
+ inputs.last().simulate( "keydown", { keyCode: $.ui.keyCode.TAB });
+ setTimeout(function() {
+ equal( document.activeElement, inputs[ 0 ],
+ "Honor preventDefault, allowing custom focus management" );
+ element.remove();
+ start();
+ }, 50 );
});
}