@@ -1188,52 +1188,6 @@ describe('globals', function() {
1188
1188
} ) ;
1189
1189
1190
1190
describe ( 'makeRequest' , function ( ) {
1191
- beforeEach ( function ( ) {
1192
- // use fake xml http request so we can muck w/ its prototype
1193
- this . xhr = sinon . useFakeXMLHttpRequest ( ) ;
1194
- this . sinon . stub ( Raven , '_makeImageRequest' ) ;
1195
- this . sinon . stub ( Raven , '_makeXhrRequest' ) ;
1196
- } ) ;
1197
-
1198
- afterEach ( function ( ) {
1199
- this . xhr . restore ( ) ;
1200
- } ) ;
1201
-
1202
- it ( 'should call makeXhrRequest if CORS is supported' , function ( ) {
1203
- XMLHttpRequest . prototype . withCredentials = true ;
1204
-
1205
- Raven . _makeRequest ( {
1206
- url : 'http://localhost/' ,
1207
- auth : { a : '1' , b : '2' } ,
1208
- data : { foo : 'bar' } ,
1209
- options : Raven . _globalOptions
1210
- } ) ;
1211
-
1212
- assert . isTrue ( Raven . _makeImageRequest . notCalled ) ;
1213
- assert . isTrue ( Raven . _makeXhrRequest . calledOnce ) ;
1214
- } ) ;
1215
-
1216
- it ( 'should call makeImageRequest if CORS is NOT supported' , function ( ) {
1217
- delete XMLHttpRequest . prototype . withCredentials ;
1218
-
1219
- var oldXDR = window . XDomainRequest ;
1220
- window . XDomainRequest = undefined ;
1221
-
1222
- Raven . _makeRequest ( {
1223
- url : 'http://localhost/' ,
1224
- auth : { a : '1' , b : '2' } ,
1225
- data : { foo : 'bar' } ,
1226
- options : Raven . _globalOptions
1227
- } ) ;
1228
-
1229
- assert . isTrue ( Raven . _makeImageRequest . calledOnce ) ;
1230
- assert . isTrue ( Raven . _makeXhrRequest . notCalled ) ;
1231
-
1232
- window . XDomainRequest = oldXDR ;
1233
- } ) ;
1234
- } ) ;
1235
-
1236
- describe ( 'makeXhrRequest' , function ( ) {
1237
1191
beforeEach ( function ( ) {
1238
1192
// NOTE: can't seem to call useFakeXMLHttpRequest via sandbox; must
1239
1193
// restore manually
@@ -1252,7 +1206,7 @@ describe('globals', function() {
1252
1206
it ( 'should create an XMLHttpRequest object with body as JSON payload' , function ( ) {
1253
1207
XMLHttpRequest . prototype . withCredentials = true ;
1254
1208
1255
- Raven . _makeXhrRequest ( {
1209
+ Raven . _makeRequest ( {
1256
1210
url : 'http://localhost/' ,
1257
1211
auth : { a : '1' , b : '2' } ,
1258
1212
data : { foo : 'bar' } ,
@@ -1263,64 +1217,24 @@ describe('globals', function() {
1263
1217
assert . equal ( lastXhr . requestBody , '{"foo":"bar"}' ) ;
1264
1218
assert . equal ( lastXhr . url , 'http://localhost/?a=1&b=2' ) ;
1265
1219
} ) ;
1266
- } ) ;
1267
1220
1268
- describe ( 'makeImageRequest ', function ( ) {
1269
- var imageCache ;
1221
+ it ( 'should no-op if CORS is not supported ', function ( ) {
1222
+ delete XMLHttpRequest . prototype . withCredentials ;
1270
1223
1271
- beforeEach ( function ( ) {
1272
- imageCache = [ ] ;
1273
- this . sinon . stub ( Raven , '_newImage' , function ( ) { var img = { } ; imageCache . push ( img ) ; return img ; } ) ;
1274
- } ) ;
1224
+ var oldXDR = window . XDomainRequest ;
1225
+ window . XDomainRequest = undefined ;
1275
1226
1276
- it ( 'should load an Image' , function ( ) {
1277
- Raven . _makeImageRequest ( {
1227
+ Raven . _makeRequest ( {
1278
1228
url : 'http://localhost/' ,
1279
1229
auth : { a : '1' , b : '2' } ,
1280
1230
data : { foo : 'bar' } ,
1281
1231
options : Raven . _globalOptions
1282
1232
} ) ;
1283
- assert . equal ( imageCache . length , 1 ) ;
1284
- assert . equal ( imageCache [ 0 ] . src , 'http://localhost/?a=1&b=2&sentry_data=%7B%22foo%22%3A%22bar%22%7D' ) ;
1285
- } ) ;
1286
-
1287
- it ( 'should populate crossOrigin based on options' , function ( ) {
1288
- Raven . _makeImageRequest ( {
1289
- url : Raven . _globalEndpoint ,
1290
- auth : { lol : '1' } ,
1291
- data : { foo : 'bar' } ,
1292
- options : {
1293
- crossOrigin : 'something'
1294
- }
1295
- } ) ;
1296
- assert . equal ( imageCache . length , 1 ) ;
1297
- assert . equal ( imageCache [ 0 ] . crossOrigin , 'something' ) ;
1298
- } ) ;
1299
1233
1300
- it ( 'should populate crossOrigin if empty string' , function ( ) {
1301
- Raven . _makeImageRequest ( {
1302
- url : Raven . _globalEndpoint ,
1303
- auth : { lol : '1' } ,
1304
- data : { foo : 'bar' } ,
1305
- options : {
1306
- crossOrigin : ''
1307
- }
1308
- } ) ;
1309
- assert . equal ( imageCache . length , 1 ) ;
1310
- assert . equal ( imageCache [ 0 ] . crossOrigin , '' ) ;
1311
- } ) ;
1234
+ assert . equal ( this . requests . length , 1 ) ; // the "test" xhr
1235
+ assert . equal ( this . requests [ 0 ] . readyState , 0 ) ;
1312
1236
1313
- it ( 'should not populate crossOrigin if falsey' , function ( ) {
1314
- Raven . _makeImageRequest ( {
1315
- url : Raven . _globalEndpoint ,
1316
- auth : { lol : '1' } ,
1317
- data : { foo : 'bar' } ,
1318
- options : {
1319
- crossOrigin : false
1320
- }
1321
- } ) ;
1322
- assert . equal ( imageCache . length , 1 ) ;
1323
- assert . isUndefined ( imageCache [ 0 ] . crossOrigin ) ;
1237
+ window . XDomainRequest = oldXDR
1324
1238
} ) ;
1325
1239
} ) ;
1326
1240
0 commit comments