Skip to content

Commit

Permalink
Merge pull request #2 from ericf/ie-xdr-abort-fix
Browse files Browse the repository at this point in the history
Ignore IO XDR tests when no native cross-domain transport is present.
  • Loading branch information
benjamincochran committed Dec 20, 2012
2 parents 0cf80fb + b2ffce9 commit 30f6941
Showing 1 changed file with 21 additions and 5 deletions.
26 changes: 21 additions & 5 deletions src/io/tests/unit/js/xdr-tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,24 @@ YUI.add('xdr-tests', function (Y) {

var URLS = Y.IO.URLS,
suite = new Y.Test.Suite('IO XDR Tests'),
xdrNative = getNativeXDRSupport(),
xdrServer = getXDRServerLocation();

function getNativeXDRSupport() {
var win = Y.config.win;

if (!win) { return false; }

// Checks for the presence of the `withCredentials` in an XHR instance
// object, which will be present if the environment supports CORS.
if (win.XMLHttpRequest && 'withCredentials' in (new XMLHttpRequest())) {
return 'CORS';
}

// IE's proprietary cross-domain transport.
return win.XDomainRequest ? 'XDR' : false;
}

function getXDRServerLocation() {
var loc = window.location,
port = window.YOGI_CONFIG && YOGI_CONFIG.xdrPort;
Expand All @@ -19,7 +35,7 @@ YUI.add('xdr-tests', function (Y) {

_should: {
ignore: {
'XDR GET should return the queried data in the response': !xdrServer
'XDR GET should return the queried data in the response': !(xdrNative && xdrServer)
}
},

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

test.wait(5000);
test.wait(2000);
}
}));

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

_should: {
ignore: {
'XDR POST should return the POSTed data in the response': !xdrServer
'XDR POST should return the POSTed data in the response': !(xdrNative && xdrServer)
}
},

Expand All @@ -67,10 +83,10 @@ YUI.add('xdr-tests', function (Y) {
data : data,
headers: {'Content-Type': 'text/plain'},
xdr : {use: 'native'},
on : {success: handleSuccess},
on : {success: handleSuccess}
});

test.wait(5000);
test.wait(2000);
}
}));

Expand Down

0 comments on commit 30f6941

Please sign in to comment.