Fixed the handling of .status == 304 in Opera (it always returns 0). Also silently...
[jquery.git] / test / unit / ajax.js
index fbff2d8..92d0739 100644 (file)
@@ -874,6 +874,68 @@ test("data option: evaluate function values (#2806)", function() {
        })
 });
 
+test("jQuery.ajax - If-Modified-Since support", function() {
+       expect( 3 );
+
+       stop();
+
+       var url = "data/if_modified_since.php?ts=" + new Date();
+
+       jQuery.ajax({
+               url: url,
+               ifModified: true,
+               success: function(data, status) { 
+                       equals(status, "success");
+                       
+                       jQuery.ajax({
+                               url: url,
+                               ifModified: true,
+                               success: function(data, status) { 
+                                       if ( data === "FAIL" ) {
+                                               ok(true, "Opera is incapable of doing .setRequestHeader('If-Modified-Since').");
+                                               ok(true, "Opera is incapable of doing .setRequestHeader('If-Modified-Since').");
+                                       } else {
+                                               equals(status, "notmodified");
+                                               ok(data == null, "response body should be empty")
+                                       }
+                                       start();
+                               }
+                       });
+               }
+       });
+});
+
+test("jQuery.ajax - Etag support", function() {
+       expect( 3 );
+
+       stop();
+
+       var url = "data/etag.php?ts=" + new Date();
+
+       jQuery.ajax({
+               url: url,
+               ifModified: true,
+               success: function(data, status) { 
+                       equals(status, "success");
+                       
+                       jQuery.ajax({
+                               url: url,
+                               ifModified: true,
+                               success: function(data, status) { 
+                                       if ( data === "FAIL" ) {
+                                               ok(true, "Opera is incapable of doing .setRequestHeader('If-None-Matches').");
+                                               ok(true, "Opera is incapable of doing .setRequestHeader('If-None-Matches').");
+                                       } else {
+                                               equals(status, "notmodified");
+                                               ok(data == null, "response body should be empty")
+                                       }
+                                       start();
+                               }
+                       });
+               }
+       });
+});
+
 }
 
 //}