Skip to content

Commit

Permalink
Tests: only run ontimeout test if ontimeout exists
Browse files Browse the repository at this point in the history
  • Loading branch information
timmywil committed Jan 8, 2018
1 parent 7be448d commit e2f1928
Showing 1 changed file with 20 additions and 16 deletions.
36 changes: 20 additions & 16 deletions test/unit/ajax.js
Original file line number Diff line number Diff line change
Expand Up @@ -524,22 +524,26 @@ QUnit.module( "ajax", {
};
} );

ajaxTest( "jQuery.ajax() - native timeout", 2, function( assert ) {
return {
url: url( "mock.php?action=wait&wait=1" ),
xhr: function() {
var xhr = new window.XMLHttpRequest();
xhr.timeout = 1;
return xhr;
},
error: function( xhr, msg ) {
assert.strictEqual( msg, "error", "Native timeout triggers error callback" );
},
complete: function() {
assert.ok( true, "complete" );
}
};
} );
// Support: Android <= 4.0 - 4.3 only
// Android 4.0-4.3 does not have ontimeout on an xhr
if ( "ontimeout" in new window.XMLHttpRequest() ) {
ajaxTest( "jQuery.ajax() - native timeout", 2, function( assert ) {
return {
url: url( "mock.php?action=wait&wait=1" ),
xhr: function() {
var xhr = new window.XMLHttpRequest();
xhr.timeout = 1;
return xhr;
},
error: function( xhr, msg ) {
assert.strictEqual( msg, "error", "Native timeout triggers error callback" );
},
complete: function() {
assert.ok( true, "complete" );
}
};
} );
}

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

0 comments on commit e2f1928

Please sign in to comment.