@@ -281,21 +281,39 @@ QUnit.test("url encodes POST requests when contentType=application/x-www-form-ur
281281} ) ;
282282
283283if ( typeof XDomainRequest === 'undefined' ) {
284- if ( ! helpers . isServer ( ) ) {
285- // There are timing issues with mocha-qunit-ui
286- QUnit . test ( "cross domain post request should change data to form data (#90)" , function ( assert ) {
287- var done = assert . async ( ) ;
288- ajax ( {
289- type : "POST" ,
290- url : "https://httpbin.org/post" ,
291- data : { 'message' : 'VALUE' } ,
292- dataType : 'application/json'
293- } ) . then ( function ( resp ) {
294- assert . equal ( resp . form . message , "VALUE" ) ;
295- done ( ) ;
296- } ) ;
284+
285+ QUnit . test ( "cross domain post request should change data to form data (#90)" , function ( assert ) {
286+ var done = assert . async ( ) ;
287+ var headers = { } ,
288+ restore = makeFixture ( function ( ) {
289+ this . open = function ( type , url ) { } ;
290+
291+ this . send = function ( ) {
292+ this . readyState = 4 ;
293+ this . status = 204 ;
294+ this . responseText = '' ;
295+ this . onreadystatechange ( ) ;
296+ } ;
297+
298+ this . setRequestHeader = function ( header , value ) {
299+ headers [ header ] = value ;
300+ } ;
301+ } ) ;
302+ ajax ( {
303+ type : "POST" ,
304+ url : "https://httpbin.org/post" ,
305+ data : { 'message' : 'VALUE' } ,
306+ dataType : 'application/json'
307+ } ) . then ( function ( resp ) {
308+ QUnit . deepEqual ( headers , { "Content-Type" : "application/x-www-form-urlencoded" } )
309+
310+ restore ( ) ;
311+ done ( ) ;
297312 } ) ;
298- }
313+
314+
315+ } ) ;
316+
299317
300318 // Test simple GET CORS:
301319 QUnit . test ( "GET CORS should be a simple request - without a preflight (#187)" , function ( assert ) {
0 commit comments