]> source.dussan.org Git - jquery.git/commitdiff
Tests: only run ontimeout test if ontimeout exists
authorTimmy Willison <4timmywil@gmail.com>
Wed, 3 Jan 2018 16:39:19 +0000 (11:39 -0500)
committerTimmy Willison <4timmywil@gmail.com>
Mon, 8 Jan 2018 16:46:43 +0000 (11:46 -0500)
Fixes gh-3742
Close gh-3919

test/unit/ajax.js

index b84ce4872eff26d2b83fe9c3f17a9a240e5ee3cb..26aa3ad214fc396d0f22ec99c917dc0d3fb02187 100644 (file)
@@ -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" );