diff options
author | hongymagic <d.hong@me.com> | 2013-11-11 13:28:36 +1100 |
---|---|---|
committer | Richard Gibson <richard.gibson@gmail.com> | 2013-11-14 20:32:56 -0500 |
commit | 27b22f4ef5f3f291204f0e0f9f414ac503f6c8a8 (patch) | |
tree | 6a53c35d54ea99c42d28b4e2381515238666abee /test/unit/ajax.js | |
parent | 5f325b1bee41d9fcf4b6c59ff44674524fa70400 (diff) | |
download | jquery-27b22f4ef5f3f291204f0e0f9f414ac503f6c8a8.tar.gz jquery-27b22f4ef5f3f291204f0e0f9f414ac503f6c8a8.zip |
Fix #14503: Cast to string before setting XHR header. Close gh-1427.
Diffstat (limited to 'test/unit/ajax.js')
-rw-r--r-- | test/unit/ajax.js | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/test/unit/ajax.js b/test/unit/ajax.js index fee2d8a04..6166e7bef 100644 --- a/test/unit/ajax.js +++ b/test/unit/ajax.js @@ -177,17 +177,24 @@ module( "ajax", { }); }); - ajaxTest( "jQuery.ajax() - headers", 4, { + ajaxTest( "jQuery.ajax() - headers", 5, { setup: function() { jQuery( document ).ajaxSend(function( evt, xhr ) { xhr.setRequestHeader( "ajax-send", "test" ); }); }, - url: url("data/headers.php?keys=siMPle_SometHing-elsE_OthEr_ajax-send"), + url: url("data/headers.php?keys=siMPle_SometHing-elsE_OthEr_Nullable_undefined_Empty_ajax-send"), headers: { "siMPle": "value", "SometHing-elsE": "other value", - "OthEr": "something else" + "OthEr": "something else", + "Nullable": null, + "undefined": undefined, + + // Support: Firefox + // Not all browsers allow empty-string headers + // https://bugzilla.mozilla.org/show_bug.cgi?id=815299 + //"Empty": "" }, success: function( data, _, xhr ) { var i, emptyHeader, @@ -196,12 +203,13 @@ module( "ajax", { }), tmp = []; for ( i in requestHeaders ) { - tmp.push( i, ": ", requestHeaders[ i ], "\n" ); + tmp.push( i, ": ", requestHeaders[ i ] + "", "\n" ); } tmp = tmp.join(""); strictEqual( data, tmp, "Headers were sent" ); strictEqual( xhr.getResponseHeader("Sample-Header"), "Hello World", "Sample header received" ); + ok( data.indexOf( "undefined" ) < 0 , "Undefined header value was not sent" ); emptyHeader = xhr.getResponseHeader("Empty-Header"); if ( emptyHeader === null ) { @@ -238,7 +246,7 @@ module( "ajax", { url: url("data/headers.php?keys=content-type"), contentType: false, success: function( data ) { - strictEqual( data, "content-type: \n", "Test content-type is not sent when options.contentType===false" ); + strictEqual( data, "", "Test content-type is not sent when options.contentType===false" ); } } ]); |