Skip to content

Commit 30f6941

Browse files
Merge pull request #2 from ericf/ie-xdr-abort-fix
Ignore IO XDR tests when no native cross-domain transport is present.
2 parents 0cf80fb + b2ffce9 commit 30f6941

File tree

1 file changed

+21
-5
lines changed

1 file changed

+21
-5
lines changed

src/io/tests/unit/js/xdr-tests.js

+21-5
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,24 @@ YUI.add('xdr-tests', function (Y) {
22

33
var URLS = Y.IO.URLS,
44
suite = new Y.Test.Suite('IO XDR Tests'),
5+
xdrNative = getNativeXDRSupport(),
56
xdrServer = getXDRServerLocation();
67

8+
function getNativeXDRSupport() {
9+
var win = Y.config.win;
10+
11+
if (!win) { return false; }
12+
13+
// Checks for the presence of the `withCredentials` in an XHR instance
14+
// object, which will be present if the environment supports CORS.
15+
if (win.XMLHttpRequest && 'withCredentials' in (new XMLHttpRequest())) {
16+
return 'CORS';
17+
}
18+
19+
// IE's proprietary cross-domain transport.
20+
return win.XDomainRequest ? 'XDR' : false;
21+
}
22+
723
function getXDRServerLocation() {
824
var loc = window.location,
925
port = window.YOGI_CONFIG && YOGI_CONFIG.xdrPort;
@@ -19,7 +35,7 @@ YUI.add('xdr-tests', function (Y) {
1935

2036
_should: {
2137
ignore: {
22-
'XDR GET should return the queried data in the response': !xdrServer
38+
'XDR GET should return the queried data in the response': !(xdrNative && xdrServer)
2339
}
2440
},
2541

@@ -39,7 +55,7 @@ YUI.add('xdr-tests', function (Y) {
3955
on : {success: handleSuccess}
4056
});
4157

42-
test.wait(5000);
58+
test.wait(2000);
4359
}
4460
}));
4561

@@ -48,7 +64,7 @@ YUI.add('xdr-tests', function (Y) {
4864

4965
_should: {
5066
ignore: {
51-
'XDR POST should return the POSTed data in the response': !xdrServer
67+
'XDR POST should return the POSTed data in the response': !(xdrNative && xdrServer)
5268
}
5369
},
5470

@@ -67,10 +83,10 @@ YUI.add('xdr-tests', function (Y) {
6783
data : data,
6884
headers: {'Content-Type': 'text/plain'},
6985
xdr : {use: 'native'},
70-
on : {success: handleSuccess},
86+
on : {success: handleSuccess}
7187
});
7288

73-
test.wait(5000);
89+
test.wait(2000);
7490
}
7591
}));
7692

0 commit comments

Comments
 (0)