@@ -15,24 +15,6 @@ QUnit.asyncTest("basic get request", function () {
15
15
} ) ;
16
16
} ) ;
17
17
18
- QUnit . asyncTest ( "abort" , function ( ) {
19
- var promise = ajax ( {
20
- type : "get" ,
21
- url : __dirname + "/test-result.json"
22
- } ) ;
23
- promise . catch ( function ( xhr ) {
24
- if ( xhr instanceof Error ) {
25
- // IE9 - see http://stackoverflow.com/questions/7287706/ie-9-javascript-error-c00c023f
26
- QUnit . equal ( xhr . message , 'Could not complete the operation due to error c00c023f.' ) ;
27
- } else {
28
- QUnit . equal ( xhr . readyState , 0 , "aborts the promise" ) ;
29
- }
30
-
31
- start ( ) ;
32
- } ) ;
33
- promise . abort ( ) ;
34
- } ) ;
35
-
36
18
QUnit . test ( "added to namespace (#99)" , function ( ) {
37
19
QUnit . equal ( namespace . ajax , ajax ) ;
38
20
} ) ;
@@ -111,3 +93,26 @@ QUnit.asyncTest("ignores case of type parameter for a post request (#100)", func
111
93
start ( ) ;
112
94
} ) ;
113
95
} ) ;
96
+
97
+ if ( "abort" in XMLHttpRequest . prototype || ( XMLHttpRequest . _XHR && "abort" in XMLHttpRequest . prototype ) ) {
98
+
99
+ QUnit . asyncTest ( "abort" , function ( ) {
100
+ var promise = ajax ( {
101
+ type : "get" ,
102
+ url : __dirname + "/test-result.json"
103
+ } ) ;
104
+ promise . catch ( function ( xhr ) {
105
+ if ( xhr instanceof Error ) {
106
+ // IE9 - see http://stackoverflow.com/questions/7287706/ie-9-javascript-error-c00c023f
107
+ QUnit . equal ( xhr . message , 'Could not complete the operation due to error c00c023f.' ) ;
108
+ start ( ) ;
109
+ } else {
110
+ setTimeout ( function ( ) {
111
+ QUnit . equal ( xhr . readyState , 0 , "aborts the promise" ) ;
112
+ start ( ) ;
113
+ } , 50 ) ;
114
+ }
115
+ } ) ;
116
+ promise . abort ( ) ;
117
+ } ) ;
118
+ }
0 commit comments