@@ -2,8 +2,24 @@ YUI.add('xdr-tests', function (Y) {
2
2
3
3
var URLS = Y . IO . URLS ,
4
4
suite = new Y . Test . Suite ( 'IO XDR Tests' ) ,
5
+ xdrNative = getNativeXDRSupport ( ) ,
5
6
xdrServer = getXDRServerLocation ( ) ;
6
7
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
+
7
23
function getXDRServerLocation ( ) {
8
24
var loc = window . location ,
9
25
port = window . YOGI_CONFIG && YOGI_CONFIG . xdrPort ;
@@ -19,7 +35,7 @@ YUI.add('xdr-tests', function (Y) {
19
35
20
36
_should : {
21
37
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 )
23
39
}
24
40
} ,
25
41
@@ -39,7 +55,7 @@ YUI.add('xdr-tests', function (Y) {
39
55
on : { success : handleSuccess }
40
56
} ) ;
41
57
42
- test . wait ( 5000 ) ;
58
+ test . wait ( 2000 ) ;
43
59
}
44
60
} ) ) ;
45
61
@@ -48,7 +64,7 @@ YUI.add('xdr-tests', function (Y) {
48
64
49
65
_should : {
50
66
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 )
52
68
}
53
69
} ,
54
70
@@ -67,10 +83,10 @@ YUI.add('xdr-tests', function (Y) {
67
83
data : data ,
68
84
headers : { 'Content-Type' : 'text/plain' } ,
69
85
xdr : { use : 'native' } ,
70
- on : { success : handleSuccess } ,
86
+ on : { success : handleSuccess }
71
87
} ) ;
72
88
73
- test . wait ( 5000 ) ;
89
+ test . wait ( 2000 ) ;
74
90
}
75
91
} ) ) ;
76
92
0 commit comments