Fixes #7881. Setting contentType to false will prevent the Content-Type header from...
[jquery.git] / test / unit / ajax.js
index 4019eb7..d5f2bc0 100644 (file)
@@ -135,7 +135,7 @@ test("jQuery.ajax() - success callbacks (oncomplete binding)", function() {
                                .error(function(){ ok(false, "error"); })
                                .complete(function(){ start(); });
                        }
-               })
+               });
        }, 13);
 });
 
@@ -173,7 +173,7 @@ test("jQuery.ajax() - success callbacks (very late binding)", function() {
                                        .complete(function(){ start(); });
                                },100);
                        }
-               })
+               });
        }, 13);
 });
 
@@ -276,6 +276,42 @@ test(".ajax() - headers" , function() {
 
 });
 
+test(".ajax() - contentType" , function() {
+
+       expect( 2 );
+
+       stop();
+
+       var count = 2;
+
+       function restart() {
+               if ( ! --count ) {
+                       start();
+               }
+       }
+
+       jQuery.ajax(url("data/headers.php?keys=content-type" ), {
+               contentType: "test",
+               success: function( data ) {
+                       strictEqual( data , "content-type: test\n" , "Test content-type is sent when options.contentType is set" );
+               },
+               complete: function() {
+                       restart();
+               }
+       });
+
+       jQuery.ajax(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" );
+               },
+               complete: function() {
+                       restart();
+               }
+       });
+
+});
+
 test(".ajax() - hash", function() {
        expect(3);
 
@@ -438,7 +474,7 @@ test("jQuery.ajax context modification", function() {
 
        stop();
 
-       var obj = {}
+       var obj = {};
 
        jQuery.ajax({
                url: url("data/name.html"),
@@ -650,20 +686,20 @@ test("serialize()", function() {
                'Check input serialization as query string');
 
        equals( jQuery('#testForm').serialize(),
-               'T3=%3F%0AZ&H1=x&H2=&PWD=&T1=&T2=YES&My+Name=me&S1=abc&S3=YES&S4=',
+               'T3=%3F%0D%0AZ&H1=x&H2=&PWD=&T1=&T2=YES&My+Name=me&S1=abc&S3=YES&S4=',
                'Check form serialization as query string');
 
        equals( jQuery('#testForm :input').serialize(),
-               'T3=%3F%0AZ&H1=x&H2=&PWD=&T1=&T2=YES&My+Name=me&S1=abc&S3=YES&S4=',
+               'T3=%3F%0D%0AZ&H1=x&H2=&PWD=&T1=&T2=YES&My+Name=me&S1=abc&S3=YES&S4=',
                'Check input serialization as query string');
 
        equals( jQuery('#form, #testForm').serialize(),
-               "action=Test&radio2=on&check=on&hidden=&foo%5Bbar%5D=&name=name&search=search&email=dave%40jquery.com&number=43&select1=&select2=3&select3=1&select3=2&select5=3&T3=%3F%0AZ&H1=x&H2=&PWD=&T1=&T2=YES&My+Name=me&S1=abc&S3=YES&S4=",
+               "action=Test&radio2=on&check=on&hidden=&foo%5Bbar%5D=&name=name&search=search&email=dave%40jquery.com&number=43&select1=&select2=3&select3=1&select3=2&select5=3&T3=%3F%0D%0AZ&H1=x&H2=&PWD=&T1=&T2=YES&My+Name=me&S1=abc&S3=YES&S4=",
                'Multiple form serialization as query string');
 
   /* Temporarily disabled. Opera 10 has problems with form serialization.
        equals( jQuery('#form, #testForm :input').serialize(),
-               "action=Test&radio2=on&check=on&hidden=&foo%5Bbar%5D=&name=name&search=search&email=dave%40jquery.com&number=43&select1=&select2=3&select3=1&select3=2&T3=%3F%0AZ&H1=x&H2=&PWD=&T1=&T2=YES&My+Name=me&S1=abc&S3=YES&S4=",
+               "action=Test&radio2=on&check=on&hidden=&foo%5Bbar%5D=&name=name&search=search&email=dave%40jquery.com&number=43&select1=&select2=3&select3=1&select3=2&T3=%3F%0D%0AZ&H1=x&H2=&PWD=&T1=&T2=YES&My+Name=me&S1=abc&S3=YES&S4=",
                'Mixed form/input serialization as query string');
        */
        jQuery("#html5email, #html5number").remove();
@@ -1522,7 +1558,7 @@ test("data option: evaluate function values (#2806)", function() {
                        equals( result, "key=value" );
                        start();
                }
-       })
+       });
 });
 
 test("data option: empty bodies for non-GET requests", function() {
@@ -1535,7 +1571,7 @@ test("data option: empty bodies for non-GET requests", function() {
                        equals( result, "" );
                        start();
                }
-       })
+       });
 });
 
 test("jQuery.ajax - If-Modified-Since support", function() {
@@ -1560,7 +1596,7 @@ test("jQuery.ajax - If-Modified-Since support", function() {
                                                ok(true, "Opera is incapable of doing .setRequestHeader('If-Modified-Since').");
                                        } else {
                                                equals(status, "notmodified");
-                                               ok(data == null, "response body should be empty")
+                                               ok(data == null, "response body should be empty");
                                        }
                                        start();
                        },
@@ -1607,7 +1643,7 @@ test("jQuery.ajax - Etag support", function() {
                                                ok(true, "Opera is incapable of doing .setRequestHeader('If-None-Match').");
                                        } else {
                                                equals(status, "notmodified");
-                                               ok(data == null, "response body should be empty")
+                                               ok(data == null, "response body should be empty");
                                        }
                                        start();
                        },
@@ -1638,7 +1674,7 @@ test("jQuery ajax - failing cross-domain", function() {
        stop();
 
        var i = 2;
-       
+
        if ( jQuery.ajax({
                url: 'http://somewebsitethatdoesnotexist-67864863574657654.com',
                success: function(){ ok( false , "success" ); },
@@ -1648,7 +1684,7 @@ test("jQuery ajax - failing cross-domain", function() {
                ok( true , "no transport" );
                if ( ! --i ) start();
        }
-       
+
        if ( jQuery.ajax({
                url: 'http://www.google.com',
                success: function(){ ok( false , "success" ); },
@@ -1658,7 +1694,7 @@ test("jQuery ajax - failing cross-domain", function() {
                ok( true , "no transport" );
                if ( ! --i ) start();
        }
-       
+
 });
 
 test("jQuery ajax - atom+xml", function() {