mirror of
https://github.com/jquery/jquery.git
synced 2025-01-10 18:24:24 +00:00
Tests: Fix the new focusin/focusout test in IE
In IE, focus & blur events fire asynchronously, the test now accounts for that. Ref gh-4362
This commit is contained in:
parent
8a74137693
commit
6f2fae7c41
@ -2952,11 +2952,20 @@ QUnit.test( "focusout/focusin support", function( assert ) {
|
||||
var focus,
|
||||
parent = jQuery( "<div>" ),
|
||||
input = jQuery( "<input>" ),
|
||||
inputExternal = jQuery( "<input>" );
|
||||
inputExternal = jQuery( "<input>" ),
|
||||
|
||||
// Support: IE <=9 - 11+
|
||||
// focus and blur events are asynchronous; this is the resulting mess.
|
||||
// The browser window must be topmost for this to work properly!!
|
||||
done = assert.async();
|
||||
|
||||
parent.append( input );
|
||||
jQuery( "#qunit-fixture" ).append( parent ).append( inputExternal );
|
||||
|
||||
// initially, lose focus
|
||||
inputExternal[ 0 ].focus();
|
||||
|
||||
setTimeout( function() {
|
||||
parent
|
||||
.on( "focus", function() {
|
||||
assert.ok( false, "parent: focus not fired" );
|
||||
@ -2974,10 +2983,10 @@ QUnit.test( "focusout/focusin support", function( assert ) {
|
||||
input
|
||||
.on( "focus", function() {
|
||||
assert.ok( true, "element: focus fired" );
|
||||
focus = true;
|
||||
} )
|
||||
.on( "focusin", function() {
|
||||
assert.ok( true, "element: focusin fired" );
|
||||
focus = true;
|
||||
} )
|
||||
.on( "blur", function() {
|
||||
assert.ok( true, "parent: blur fired" );
|
||||
@ -2987,14 +2996,12 @@ QUnit.test( "focusout/focusin support", function( assert ) {
|
||||
} );
|
||||
|
||||
// gain focus
|
||||
input.trigger( "focus" );
|
||||
input[ 0 ].focus();
|
||||
|
||||
// then lose it
|
||||
inputExternal.trigger( "focus" );
|
||||
inputExternal[ 0 ].focus();
|
||||
|
||||
// cleanup
|
||||
parent.off();
|
||||
input.off();
|
||||
setTimeout( function() {
|
||||
|
||||
// DOM focus is unreliable in TestSwarm
|
||||
if ( QUnit.isSwarm && !focus ) {
|
||||
@ -3005,6 +3012,14 @@ QUnit.test( "focusout/focusin support", function( assert ) {
|
||||
assert.ok( true, "GAP: Could not observe focus change" );
|
||||
assert.ok( true, "GAP: Could not observe focus change" );
|
||||
}
|
||||
|
||||
// cleanup
|
||||
parent.off();
|
||||
input.off();
|
||||
|
||||
done();
|
||||
}, 50 );
|
||||
}, 50 );
|
||||
} );
|
||||
|
||||
QUnit.test( "focus-blur order (#12868)", function( assert ) {
|
||||
|
Loading…
Reference in New Issue
Block a user