Skip to content

Commit 2c0e742

Browse files
committed
IE9 Ajax abort tests
1 parent c6d6264 commit 2c0e742

File tree

1 file changed

+23
-18
lines changed

1 file changed

+23
-18
lines changed

ajax-test.js

Lines changed: 23 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -15,24 +15,6 @@ QUnit.asyncTest("basic get request", function () {
1515
});
1616
});
1717

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-
3618
QUnit.test("added to namespace (#99)", function(){
3719
QUnit.equal(namespace.ajax, ajax);
3820
});
@@ -111,3 +93,26 @@ QUnit.asyncTest("ignores case of type parameter for a post request (#100)", func
11193
start();
11294
});
11395
});
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

Comments
 (0)