mirror of
https://github.com/jquery/jquery.git
synced 2024-11-23 02:54:22 +00:00
strengthens and dries 304 unit tests
This commit is contained in:
parent
ce426c5d69
commit
d4e666d475
@ -973,64 +973,46 @@ module( "ajax", {
|
|||||||
},
|
},
|
||||||
function( label, cache ) {
|
function( label, cache ) {
|
||||||
// Support: Opera 12.0
|
// Support: Opera 12.0
|
||||||
// Old Opera's XHR doesn't support 304/If-Modified-Since/If-None-Match
|
// In Opera 12.0, XHR doesn't notify 304 back to the user properly
|
||||||
var isOpera = !!window.opera;
|
var opera = window.opera && window.opera.version();
|
||||||
asyncTest( "jQuery.ajax() - If-Modified-Since support" + label, 3, function() {
|
jQuery.each(
|
||||||
var url = "data/if_modified_since.php?ts=" + ifModifiedNow++;
|
{
|
||||||
jQuery.ajax({
|
"If-Modified-Since": "if_modified_since.php",
|
||||||
url: url,
|
"Etag": "etag.php"
|
||||||
ifModified: true,
|
},
|
||||||
cache: cache,
|
function( type, url ) {
|
||||||
success: function( data, status ) {
|
url = "data/" + url + "?ts=" + ifModifiedNow++;
|
||||||
strictEqual( status, "success" );
|
asyncTest( "jQuery.ajax() - " + type + " support" + label, 4, function() {
|
||||||
jQuery.ajax({
|
jQuery.ajax({
|
||||||
url: url,
|
url: url,
|
||||||
ifModified: true,
|
ifModified: true,
|
||||||
cache: cache,
|
cache: cache,
|
||||||
success: function( data, status ) {
|
success: function( _, status ) {
|
||||||
if ( status === "success" ) {
|
strictEqual( status, "success", "Initial status is 'success'" );
|
||||||
ok( isOpera, "Old Opera is incapable of doing .setRequestHeader('If-Modified-Since')." );
|
jQuery.ajax({
|
||||||
ok( isOpera, "Old Opera is incapable of doing .setRequestHeader('If-Modified-Since')." );
|
url: url,
|
||||||
} else {
|
ifModified: true,
|
||||||
strictEqual( status, "notmodified" );
|
cache: cache,
|
||||||
ok( data == null, "response body should be empty" );
|
success: function( data, status, jqXHR ) {
|
||||||
}
|
if ( status === "success" && opera === "12.00" ) {
|
||||||
},
|
strictEqual( status, "success", "Opera 12.0: Following status is 'success'" );
|
||||||
complete: function() {
|
strictEqual( jqXHR.status, 200, "Opera 12.0: XHR status is 200, not 304" );
|
||||||
start();
|
strictEqual( data, "", "Opera 12.0: response body is empty" );
|
||||||
|
} else {
|
||||||
|
strictEqual( status, "notmodified", "Following status is 'notmodified'" );
|
||||||
|
strictEqual( jqXHR.status, 304, "XHR status is 304" );
|
||||||
|
equal( data, null, "no response body is given" );
|
||||||
|
}
|
||||||
|
},
|
||||||
|
complete: function() {
|
||||||
|
start();
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
});
|
||||||
});
|
}
|
||||||
});
|
);
|
||||||
asyncTest( "jQuery.ajax() - Etag support" + label, 3, function() {
|
|
||||||
var url = "data/etag.php?ts=" + ifModifiedNow++;
|
|
||||||
jQuery.ajax({
|
|
||||||
url: url,
|
|
||||||
ifModified: true,
|
|
||||||
cache: cache,
|
|
||||||
success: function( data, status ) {
|
|
||||||
strictEqual( status, "success" );
|
|
||||||
jQuery.ajax({
|
|
||||||
url: url,
|
|
||||||
ifModified: true,
|
|
||||||
cache: cache,
|
|
||||||
success: function( data, status ) {
|
|
||||||
if ( status === "success" ) {
|
|
||||||
ok( isOpera, "Old Opera is incapable of doing .setRequestHeader('If-None-Match')." );
|
|
||||||
ok( isOpera, "Old Opera is incapable of doing .setRequestHeader('If-None-Match')." );
|
|
||||||
} else {
|
|
||||||
strictEqual( status, "notmodified" );
|
|
||||||
ok( data == null, "response body should be empty" );
|
|
||||||
}
|
|
||||||
},
|
|
||||||
complete: function() {
|
|
||||||
start();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
/* jQuery.each arguments end */
|
/* jQuery.each arguments end */
|
||||||
);
|
);
|
||||||
|
Loading…
Reference in New Issue
Block a user