Further fix for #3333, refactored marginRight css hook to use jQuery.swap and compute...
[jquery.git] / test / unit / ajax.js
index c9c0611..7c572a3 100644 (file)
@@ -344,7 +344,7 @@ test(".ajax() - retry with jQuery.ajax( this )", function() {
 
 test(".ajax() - headers" , function() {
 
-       expect( 2 );
+       expect( 4 );
 
        stop();
 
@@ -376,8 +376,14 @@ test(".ajax() - headers" , function() {
                        tmp.push(  "ajax-send: test\n" );
                        tmp = tmp.join( "" );
 
-                       equals( data , tmp , "Headers were sent" );
-                       equals( xhr.getResponseHeader( "Sample-Header" ) , "Hello World" , "Sample header received" );
+                       strictEqual( data , tmp , "Headers were sent" );
+                       strictEqual( xhr.getResponseHeader( "Sample-Header" ) , "Hello World" , "Sample header received" );
+                       if ( jQuery.browser.mozilla ) {
+                               ok( true, "Firefox doesn't support empty headers" );
+                       } else {
+                               strictEqual( xhr.getResponseHeader( "Empty-Header" ) , "" , "Empty header received" );
+                       }
+                       strictEqual( xhr.getResponseHeader( "Sample-Header2" ) , "Hello World 2" , "Second sample header received" );
                },
                error: function(){ ok(false, "error"); }
 
@@ -486,7 +492,7 @@ test(".ajax() - hash", function() {
 
 test("jQuery ajax - cross-domain detection", function() {
 
-       expect( 4 );
+       expect( 6 );
 
        var loc = document.location,
                otherPort = loc.port === 666 ? 667 : 666,
@@ -503,6 +509,15 @@ test("jQuery ajax - cross-domain detection", function() {
 
        jQuery.ajax({
                dataType: "jsonp",
+               url: 'app:/path',
+               beforeSend: function( _ , s ) {
+                       ok( s.crossDomain , "Adobe AIR app:/ URL detected as cross-domain" );
+                       return false;
+               }
+       });
+
+       jQuery.ajax({
+               dataType: "jsonp",
                url: loc.protocol + '//somewebsitethatdoesnotexist-656329477541.com:' + ( loc.port || 80 ),
                beforeSend: function( _ , s ) {
                        ok( s.crossDomain , "Test different hostnames are detected as cross-domain" );
@@ -521,6 +536,15 @@ test("jQuery ajax - cross-domain detection", function() {
 
        jQuery.ajax({
                dataType: "jsonp",
+               url: "about:blank",
+               beforeSend: function( _ , s ) {
+                       ok( s.crossDomain , "Test about:blank is detected as cross-domain" );
+                       return false;
+               }
+       });
+
+       jQuery.ajax({
+               dataType: "jsonp",
                url: loc.protocol + "//" + loc.host,
                crossDomain: true,
                beforeSend: function( _ , s ) {
@@ -1196,6 +1220,21 @@ test("load(String, String, Function)", function() {
        });
 });
 
+test("jQuery.get(String, Function) - data in ajaxSettings (#8277)", function() {
+       expect(1);
+       stop();
+       jQuery.ajaxSetup({
+               data: "helloworld"
+       });
+       jQuery.get(url('data/echoQuery.php'), function(data) {
+               ok( /helloworld$/.test( data ), 'Data from ajaxSettings was used');
+               jQuery.ajaxSetup({
+                       data: null
+               });
+               start();
+       });
+});
+
 test("jQuery.get(String, Hash, Function) - parse xml and use text() on nodes", function() {
        expect(2);
        stop();