Commit ed6209e8 authored by jaubourg's avatar jaubourg

Tweaks the logic in the 304-related unit tests so that they pass for versions...

Tweaks the logic in the 304-related unit tests so that they pass for versions of Opera that support manual 304 handling as well as for those that don't
parent 57d9dcd4
...@@ -972,93 +972,62 @@ module( "ajax", { ...@@ -972,93 +972,62 @@ module( "ajax", {
" (no cache)": false " (no cache)": false
}, },
function( label, cache ) { function( label, cache ) {
// Support: Opera 12.0
// Old Opera's XHR doesn't support 304/If-Modified-Since/If-None-Match
var isOpera = !!window.opera; var isOpera = !!window.opera;
asyncTest( "jQuery.ajax() - If-Modified-Since support" + label, 3, function() { asyncTest( "jQuery.ajax() - If-Modified-Since support" + label, 3, function() {
var url = "data/if_modified_since.php?ts=" + ifModifiedNow++; var url = "data/if_modified_since.php?ts=" + ifModifiedNow++;
jQuery.ajax({ jQuery.ajax({
url: url, url: url,
ifModified: true, ifModified: true,
cache: cache, cache: cache,
success: function( data, status ) { success: function( data, status ) {
strictEqual( status, "success" ); strictEqual( status, "success" );
jQuery.ajax({ jQuery.ajax({
url: url, url: url,
ifModified: true, ifModified: true,
cache: cache, cache: cache,
success: function( data, status ) { success: function( data, status ) {
if ( data === "FAIL" ) { if ( status === "success" ) {
ok( isOpera, "Opera is incapable of doing .setRequestHeader('If-Modified-Since')." ); ok( isOpera, "Old Opera is incapable of doing .setRequestHeader('If-Modified-Since')." );
ok( isOpera, "Opera is incapable of doing .setRequestHeader('If-Modified-Since')." ); ok( isOpera, "Old Opera is incapable of doing .setRequestHeader('If-Modified-Since')." );
} else { } else {
strictEqual( status, "notmodified" ); strictEqual( status, "notmodified" );
ok( data == null, "response body should be empty" ); ok( data == null, "response body should be empty" );
} }
start();
}, },
error: function() { complete: function() {
// Do this because opera simply refuses to implement 304 handling :(
// A feature-driven way of detecting this would be appreciated
// See: http://gist.github.com/599419
ok( isOpera, "error" );
ok( isOpera, "error" );
start(); start();
} }
}); });
},
error: function() {
strictEqual( false, "error" );
// Do this because opera simply refuses to implement 304 handling :(
// A feature-driven way of detecting this would be appreciated
// See: http://gist.github.com/599419
ok( isOpera, "error" );
start();
} }
}); });
}); });
asyncTest( "jQuery.ajax() - Etag support" + label, 3, function() { asyncTest( "jQuery.ajax() - Etag support" + label, 3, function() {
var url = "data/etag.php?ts=" + ifModifiedNow++; var url = "data/etag.php?ts=" + ifModifiedNow++;
jQuery.ajax({ jQuery.ajax({
url: url, url: url,
ifModified: true, ifModified: true,
cache: cache, cache: cache,
success: function( data, status ) { success: function( data, status ) {
strictEqual( status, "success" ); strictEqual( status, "success" );
jQuery.ajax({ jQuery.ajax({
url: url, url: url,
ifModified: true, ifModified: true,
cache: cache, cache: cache,
success: function( data, status ) { success: function( data, status ) {
if ( data === "FAIL" ) { if ( status === "success" ) {
ok( isOpera, "Opera is incapable of doing .setRequestHeader('If-None-Match')." ); ok( isOpera, "Old Opera is incapable of doing .setRequestHeader('If-None-Match')." );
ok( isOpera, "Opera is incapable of doing .setRequestHeader('If-None-Match')." ); ok( isOpera, "Old Opera is incapable of doing .setRequestHeader('If-None-Match')." );
} else { } else {
strictEqual( status, "notmodified" ); strictEqual( status, "notmodified" );
ok( data == null, "response body should be empty" ); ok( data == null, "response body should be empty" );
} }
start();
}, },
error: function() { complete: function() {
// Do this because opera simply refuses to implement 304 handling :(
// A feature-driven way of detecting this would be appreciated
// See: http://gist.github.com/599419
ok( isOpera, "error" );
ok( isOpera, "error" );
start(); start();
} }
}); });
},
error: function() {
// Do this because opera simply refuses to implement 304 handling :(
// A feature-driven way of detecting this would be appreciated
// See: http://gist.github.com/599419
ok( isOpera, "error" );
start();
} }
}); });
}); });
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment