diff options
Diffstat (limited to 'test/unit/event.js')
-rw-r--r-- | test/unit/event.js | 51 |
1 files changed, 43 insertions, 8 deletions
diff --git a/test/unit/event.js b/test/unit/event.js index ea9b67f16..d0d451e11 100644 --- a/test/unit/event.js +++ b/test/unit/event.js @@ -2555,7 +2555,9 @@ testIframe( function( assert, framejQuery, frameWin, frameDoc ) { assert.expect( 1 ); - var input = jQuery( frameDoc ).find( "#frame-input" ); + var done = assert.async(), + focus = false, + input = jQuery( frameDoc ).find( "#frame-input" ); // Create a focusin handler on the parent; shouldn't affect the iframe's fate jQuery( "body" ).on( "focusin.iframeTest", function() { @@ -2563,23 +2565,56 @@ testIframe( } ); input.on( "focusin", function() { + focus = true; assert.ok( true, "fired a focusin event in the iframe" ); } ); // Avoid a native event; Chrome can't force focus to another frame - input.trigger( "focusin" ); - - // Must manually remove handler to avoid leaks in our data store - input.remove(); - - // Be sure it was removed; nothing should happen - input.trigger( "focusin" ); + input[ 0 ].focus(); // Remove body handler manually since it's outside the fixture jQuery( "body" ).off( "focusin.iframeTest" ); + + setTimeout( function() { + + // DOM focus is unreliable in TestSwarm + if ( QUnit.isSwarm && !focus ) { + assert.ok( true, "GAP: Could not observe focus change" ); + } + + done(); + }, 50 ); } ); +QUnit.test( "focusin on document & window", function( assert ) { + assert.expect( 1 ); + + var counter = 0, + input = jQuery( "<input />" ); + + input.appendTo( "#qunit-fixture" ); + + input[ 0 ].focus(); + + jQuery( window ).on( "focusout", function() { + counter++; + } ); + jQuery( document ).on( "focusout", function() { + counter++; + } ); + + input[ 0 ].blur(); + + // DOM focus is unreliable in TestSwarm + if ( QUnit.isSwarm && counter === 0 ) { + assert.ok( true, "GAP: Could not observe focus change" ); + } + + assert.strictEqual( counter, 2, + "focusout handlers on document/window fired once only" ); +} ); + testIframe( "jQuery.ready promise", "event/promiseReady.html", |