mirror of
https://github.com/jquery/jquery.git
synced 2025-01-10 18:24:24 +00:00
Ref #14503: Cherry-pick tests.
(cherry picked from commit27b22f4ef5
) (cherry picked from commit8dc0f2ea84
) (cherry picked from commit936126f10d
)
This commit is contained in:
parent
14c19cf1a8
commit
8d09ee0506
@ -14,5 +14,10 @@ foreach( $_SERVER as $key => $value ) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
foreach( explode( "_" , $_GET[ "keys" ] ) as $key ) {
|
foreach( explode( "_" , $_GET[ "keys" ] ) as $key ) {
|
||||||
|
|
||||||
|
// Only echo if key exists in the header
|
||||||
|
if ( isset( $headers[ strtoupper( $key ) ] ) ) {
|
||||||
echo "$key: " . @$headers[ strtoupper( $key ) ] . "\n";
|
echo "$key: " . @$headers[ strtoupper( $key ) ] . "\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
@ -182,17 +182,24 @@ module( "ajax", {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
ajaxTest( "jQuery.ajax() - headers", 4, {
|
ajaxTest( "jQuery.ajax() - headers", 5, {
|
||||||
setup: function() {
|
setup: function() {
|
||||||
jQuery( document ).ajaxSend(function( evt, xhr ) {
|
jQuery( document ).ajaxSend(function( evt, xhr ) {
|
||||||
xhr.setRequestHeader( "ajax-send", "test" );
|
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: {
|
headers: {
|
||||||
"siMPle": "value",
|
"siMPle": "value",
|
||||||
"SometHing-elsE": "other 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 ) {
|
success: function( data, _, xhr ) {
|
||||||
var i, emptyHeader,
|
var i, emptyHeader,
|
||||||
@ -201,12 +208,13 @@ module( "ajax", {
|
|||||||
}),
|
}),
|
||||||
tmp = [];
|
tmp = [];
|
||||||
for ( i in requestHeaders ) {
|
for ( i in requestHeaders ) {
|
||||||
tmp.push( i, ": ", requestHeaders[ i ], "\n" );
|
tmp.push( i, ": ", requestHeaders[ i ] + "", "\n" );
|
||||||
}
|
}
|
||||||
tmp = tmp.join("");
|
tmp = tmp.join("");
|
||||||
|
|
||||||
strictEqual( data, tmp, "Headers were sent" );
|
strictEqual( data, tmp, "Headers were sent" );
|
||||||
strictEqual( xhr.getResponseHeader("Sample-Header"), "Hello World", "Sample header received" );
|
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");
|
emptyHeader = xhr.getResponseHeader("Empty-Header");
|
||||||
if ( emptyHeader === null ) {
|
if ( emptyHeader === null ) {
|
||||||
@ -243,7 +251,9 @@ module( "ajax", {
|
|||||||
url: url("data/headers.php?keys=content-type"),
|
url: url("data/headers.php?keys=content-type"),
|
||||||
contentType: false,
|
contentType: false,
|
||||||
success: function( data ) {
|
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" );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
]);
|
]);
|
||||||
|
Loading…
Reference in New Issue
Block a user