aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorRichard Gibson <richard.gibson@gmail.com>2017-07-18 20:32:01 -0400
committerRichard Gibson <richard.gibson@gmail.com>2017-07-18 20:32:01 -0400
commitd9a099a58e1bb1f158ea66ec55534770be442907 (patch)
treea2480c24cff07ca6ac43d18cab7ee503b518aea6 /test
parent20cdf4e7de60f515a7acf6c70228c52668301d9b (diff)
downloadjquery-d9a099a58e1bb1f158ea66ec55534770be442907.tar.gz
jquery-d9a099a58e1bb1f158ea66ec55534770be442907.zip
Tests: Try extra hard to control focus
Ref gh-3732
Diffstat (limited to 'test')
-rw-r--r--test/unit/event.js33
1 files 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( "<input/>" ).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 ) {