From d9a099a58e1bb1f158ea66ec55534770be442907 Mon Sep 17 00:00:00 2001 From: Richard Gibson Date: Tue, 18 Jul 2017 20:32:01 -0400 Subject: [PATCH] Tests: Try extra hard to control focus Ref gh-3732 --- test/unit/event.js | 33 +++++++++++++++++++++------------ 1 file changed, 21 insertions(+), 12 deletions(-) diff --git a/test/unit/event.js b/test/unit/event.js index 30e057a80..f1bf3bfa1 100644 --- a/test/unit/event.js +++ b/test/unit/event.js @@ -2792,21 +2792,30 @@ QUnit.test( "preventDefault() on focusin does not throw exception", function( as var done = assert.async(), input = jQuery( "" ).appendTo( "#form" ); - input - .on( "focusin", function( event ) { - var exceptionCaught; + input.on( "focusin", function( event ) { + if ( !done ) { + return; + } - try { - event.preventDefault(); - } catch ( theException ) { - exceptionCaught = theException; - } + var exceptionCaught; + try { + event.preventDefault(); + } catch ( theException ) { + exceptionCaught = theException; + } - assert.strictEqual( exceptionCaught, undefined, - "Preventing default on focusin throws no exception" ); + assert.strictEqual( exceptionCaught, undefined, + "Preventing default on focusin throws no exception" ); - done(); - } ).trigger( "focus" ); + done(); + done = null; + } ); + + // This test can be flaky in CI... try two methods to prompt a focusin event + input.trigger( "focus" ); + try { + input[ 0 ].focus(); + } catch ( e ) {} } ); QUnit.test( "Donor event interference", function( assert ) { -- 2.39.5