@@ -182,17 +182,24 @@ module( "ajax", {
182182 } ) ;
183183 } ) ;
184184
185- ajaxTest ( "jQuery.ajax() - headers" , 4 , {
185+ ajaxTest ( "jQuery.ajax() - headers" , 5 , {
186186 setup : function ( ) {
187187 jQuery ( document ) . ajaxSend ( function ( evt , xhr ) {
188188 xhr . setRequestHeader ( "ajax-send" , "test" ) ;
189189 } ) ;
190190 } ,
191- url : url ( "data/headers.php?keys=siMPle_SometHing-elsE_OthEr_ajax -send" ) ,
191+ url : url ( "data/headers.php?keys=siMPle_SometHing-elsE_OthEr_Nullable_undefined_Empty_ajax -send" ) ,
192192 headers : {
193193 "siMPle" : "value" ,
194194 "SometHing-elsE" : "other value" ,
195- "OthEr" : "something else"
195+ "OthEr" : "something else" ,
196+ "Nullable" : null ,
197+ "undefined" : undefined
198+
199+ // Support: Firefox
200+ // Not all browsers allow empty-string headers
201+ // https://bugzilla.mozilla.org/show_bug.cgi?id=815299
202+ //"Empty": ""
196203 } ,
197204 success : function ( data , _ , xhr ) {
198205 var i , emptyHeader ,
@@ -201,12 +208,13 @@ module( "ajax", {
201208 } ) ,
202209 tmp = [ ] ;
203210 for ( i in requestHeaders ) {
204- tmp . push ( i , ": " , requestHeaders [ i ] , "\n" ) ;
211+ tmp . push ( i , ": " , requestHeaders [ i ] + "" , "\n" ) ;
205212 }
206213 tmp = tmp . join ( "" ) ;
207214
208215 strictEqual ( data , tmp , "Headers were sent" ) ;
209216 strictEqual ( xhr . getResponseHeader ( "Sample-Header" ) , "Hello World" , "Sample header received" ) ;
217+ ok ( data . indexOf ( "undefined" ) < 0 , "Undefined header value was not sent" ) ;
210218
211219 emptyHeader = xhr . getResponseHeader ( "Empty-Header" ) ;
212220 if ( emptyHeader === null ) {
@@ -243,7 +251,9 @@ module( "ajax", {
243251 url : url ( "data/headers.php?keys=content-type" ) ,
244252 contentType : false ,
245253 success : function ( data ) {
246- strictEqual ( data , "content-type: \n" , "Test content-type is not sent when options.contentType===false" ) ;
254+ // Some server/interpreter combinations always supply a Content-Type to scripts
255+ data = data || "content-type: \n" ;
256+ strictEqual ( data , "content-type: \n" , "Test content-type is not set when options.contentType===false" ) ;
247257 }
248258 }
249259 ] ) ;
0 commit comments