From: Scott González Date: Tue, 10 Mar 2015 19:16:27 +0000 (-0400) Subject: Dialog: Fix focus tests in IE8 with jQuery 1.7 X-Git-Tag: 1.12.0-beta.1~420 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=a6a18d1ed82ca68cf1a8551be706ea8b03841242;p=jquery-ui.git Dialog: Fix focus tests in IE8 with jQuery 1.7 Ref gh-1481 --- diff --git a/tests/unit/dialog/dialog_core.js b/tests/unit/dialog/dialog_core.js index d72fef7b5..56f1e3da8 100644 --- a/tests/unit/dialog/dialog_core.js +++ b/tests/unit/dialog/dialog_core.js @@ -59,90 +59,94 @@ asyncTest( "focus tabbable", function() { element = $( markup ).dialog( options ); setTimeout(function() { - testFn(); - element.remove(); - setTimeout( next ); + testFn(function done() { + element.remove(); + setTimeout( next ); + }); }); } function step1() { - element = $( "
" ).dialog( options ); - setTimeout(function() { + checkFocus( "
", options, function( done ) { var input = element.find( "input:last" ).focus().blur(); element.dialog( "instance" )._focusTabbable(); setTimeout(function() { equal( document.activeElement, input[ 0 ], "1. an element that was focused previously." ); - element.remove(); - setTimeout( step2 ); + done(); }); - }); + }, step2 ); } function step2() { - checkFocus( "
", options, function() { + checkFocus( "
", options, function( done ) { equal( document.activeElement, element.find( "input" )[ 1 ], "2. first element inside the dialog matching [autofocus]" ); + done(); }, step3 ); } function step3() { - checkFocus( "
", options, function() { + checkFocus( "
", options, function( done ) { equal( document.activeElement, element.find( "input" )[ 0 ], "3. tabbable element inside the content element" ); + done(); }, step4 ); } function step4() { - checkFocus( "
text
", options, function() { + checkFocus( "
text
", options, function( done ) { equal( document.activeElement, element.dialog( "widget" ).find( ".ui-dialog-buttonpane button" )[ 0 ], "4. tabbable element inside the buttonpane" ); + done(); }, step5 ); } function step5() { - checkFocus( "
text
", {}, function() { + checkFocus( "
text
", {}, function( done ) { equal( document.activeElement, element.dialog( "widget" ).find( ".ui-dialog-titlebar .ui-dialog-titlebar-close" )[ 0 ], "5. the close button" ); + done(); }, step6 ); } function step6() { - element = $( "
text
" ).dialog({ - autoOpen: false - }); - element.dialog( "widget" ).find( ".ui-dialog-titlebar-close" ).hide(); - element.dialog( "open" ); - setTimeout(function() { - equal( document.activeElement, element.parent()[ 0 ], "6. the dialog itself" ); - element.remove(); - setTimeout( step7 ); - }); + checkFocus( "
text
", { autoOpen: false }, function( done ) { + element.dialog( "widget" ).find( ".ui-dialog-titlebar-close" ).hide(); + element.dialog( "open" ); + setTimeout(function() { + equal( document.activeElement, element.parent()[ 0 ], "6. the dialog itself" ); + done(); + }); + }, step7 ); } function step7() { - element = $( "
" ).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 ); - }); + checkFocus( + "
", + { + open: function() { + var inputs = $( this ).find( "input" ); + inputs.last().keydown(function( event ) { + event.preventDefault(); + inputs.first().focus(); + }); + } + }, + function( done ) { + 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" ); + done(); + }, 50 ); + }, + start + ); } step1();