aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorhongymagic <d.hong@me.com>2013-11-11 13:28:36 +1100
committerRichard Gibson <richard.gibson@gmail.com>2013-11-15 12:19:05 -0500
commit8d09ee0506794e8a2b7cfae4bb804e4ca59348e1 (patch)
treee6a4353bba0796f3af487f0a37396499e86e4d77 /test
parent14c19cf1a8dc3845f3f6b82f27be75334b2591e3 (diff)
downloadjquery-8d09ee0506794e8a2b7cfae4bb804e4ca59348e1.tar.gz
jquery-8d09ee0506794e8a2b7cfae4bb804e4ca59348e1.zip
Ref #14503: Cherry-pick tests.
(cherry picked from commit 27b22f4ef5f3f291204f0e0f9f414ac503f6c8a8) (cherry picked from commit 8dc0f2ea84e1861d8d8dfa7699268368c659f8e9) (cherry picked from commit 936126f10de193e2bb1c8280dbc2361ca5d62e29)
Diffstat (limited to 'test')
-rw-r--r--test/data/headers.php7
-rw-r--r--test/unit/ajax.js20
2 files changed, 21 insertions, 6 deletions
diff --git a/test/data/headers.php b/test/data/headers.php
index 968f13f19..79c183055 100644
--- a/test/data/headers.php
+++ b/test/data/headers.php
@@ -14,5 +14,10 @@ foreach( $_SERVER as $key => $value ) {
}
foreach( explode( "_" , $_GET[ "keys" ] ) as $key ) {
- echo "$key: " . @$headers[ strtoupper( $key ) ] . "\n";
+
+ // Only echo if key exists in the header
+ if ( isset( $headers[ strtoupper( $key ) ] ) ) {
+ echo "$key: " . @$headers[ strtoupper( $key ) ] . "\n";
+ }
+
}
diff --git a/test/unit/ajax.js b/test/unit/ajax.js
index d446d64f1..ad44ba68b 100644
--- a/test/unit/ajax.js
+++ b/test/unit/ajax.js
@@ -182,17 +182,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,
@@ -201,12 +208,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 ) {
@@ -243,7 +251,9 @@ 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" );
+ // Some server/interpreter combinations always supply a Content-Type to scripts
+ data = data || "content-type: \n";
+ strictEqual( data, "content-type: \n", "Test content-type is not set when options.contentType===false" );
}
}
]);