Skip to content

Commit e2f1928

Browse files
committed
Tests: only run ontimeout test if ontimeout exists
Fixes jquerygh-3742 Close jquerygh-3919
1 parent 7be448d commit e2f1928

File tree

1 file changed

+20
-16
lines changed

1 file changed

+20
-16
lines changed

test/unit/ajax.js

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -524,22 +524,26 @@ QUnit.module( "ajax", {
524524
};
525525
} );
526526

527-
ajaxTest( "jQuery.ajax() - native timeout", 2, function( assert ) {
528-
return {
529-
url: url( "mock.php?action=wait&wait=1" ),
530-
xhr: function() {
531-
var xhr = new window.XMLHttpRequest();
532-
xhr.timeout = 1;
533-
return xhr;
534-
},
535-
error: function( xhr, msg ) {
536-
assert.strictEqual( msg, "error", "Native timeout triggers error callback" );
537-
},
538-
complete: function() {
539-
assert.ok( true, "complete" );
540-
}
541-
};
542-
} );
527+
// Support: Android <= 4.0 - 4.3 only
528+
// Android 4.0-4.3 does not have ontimeout on an xhr
529+
if ( "ontimeout" in new window.XMLHttpRequest() ) {
530+
ajaxTest( "jQuery.ajax() - native timeout", 2, function( assert ) {
531+
return {
532+
url: url( "mock.php?action=wait&wait=1" ),
533+
xhr: function() {
534+
var xhr = new window.XMLHttpRequest();
535+
xhr.timeout = 1;
536+
return xhr;
537+
},
538+
error: function( xhr, msg ) {
539+
assert.strictEqual( msg, "error", "Native timeout triggers error callback" );
540+
},
541+
complete: function() {
542+
assert.ok( true, "complete" );
543+
}
544+
};
545+
} );
546+
}
543547

544548
ajaxTest( "jQuery.ajax() - events with context", 12, function( assert ) {
545549
var context = document.createElement( "div" );

0 commit comments

Comments
 (0)