X-Git-Url: http://git.asbjorn.biz/?a=blobdiff_plain;f=test%2Funit%2Fajax.js;h=d849cff246b8669e7ac610f9c4dfe902a9c1bef5;hb=7bc538623077abb48d94b33ef8e389d1022b13af;hp=14f8928572bd90963401f5f01594a342b57dcf9d;hpb=afefb4f3d28f47c0a93cc9dfddfcbadb595a8efb;p=jquery.git diff --git a/test/unit/ajax.js b/test/unit/ajax.js index 14f8928..d849cff 100644 --- a/test/unit/ajax.js +++ b/test/unit/ajax.js @@ -257,6 +257,29 @@ test("jQuery.ajax() - responseText on error", function() { }); }); +test(".ajax() - retry with jQuery.ajax( this )", function() { + + expect( 1 ); + + stop(); + + var firstTime = 1; + + jQuery.ajax({ + url: url("data/errorWithText.php"), + error: function() { + if ( firstTime ) { + firstTime = 0; + jQuery.ajax( this ); + } else { + ok( true , "Test retrying with jQuery.ajax(this) works" ); + start(); + } + } + }) + +}); + test(".ajax() - headers" , function() { expect( 2 ); @@ -360,53 +383,48 @@ test(".ajax() - hash", function() { test("jQuery ajax - cross-domain detection", function() { - expect( 3 ); + expect( 4 ); var loc = document.location, otherPort = loc.port === 666 ? 667 : 666, - otherProtocol = loc.protocol === "http:" ? "https:" : "http:", - protocolFlag, - hostFlag, - portFlag; + otherProtocol = loc.protocol === "http:" ? "https:" : "http:"; - if ( jQuery.ajax({ + jQuery.ajax({ + dataType: "jsonp", url: otherProtocol + "//" + loc.host, beforeSend: function( _ , s ) { - protocolFlag = 1; ok( s.crossDomain , "Test different protocols are detected as cross-domain" ); return false; } - }) === false ) { - if ( ! protocolFlag ) { - ok( ! jQuery.support.cors , "Test different protocols are detected as cross-domain (no transport)" ); - } - } + }); - if ( jQuery.ajax({ + jQuery.ajax({ + dataType: "jsonp", url: loc.protocol + '//somewebsitethatdoesnotexist-656329477541.com:' + ( loc.port || 80 ), beforeSend: function( _ , s ) { - hostFlag = 1; ok( s.crossDomain , "Test different hostnames are detected as cross-domain" ); return false; } - }) === false ) { - if ( ! hostFlag ) { - ok( ! jQuery.support.cors , "Test different hostnames are detected as cross-domain (no transport)" ); - } - } + }); - if ( jQuery.ajax({ + jQuery.ajax({ + dataType: "jsonp", url: loc.protocol + "//" + loc.hostname + ":" + otherPort, beforeSend: function( _ , s ) { - portFlag = 1; ok( s.crossDomain , "Test different ports are detected as cross-domain" ); return false; } - }) === false ) { - if ( ! portFlag ) { - ok( ! jQuery.support.cors , "Test different ports are detected as cross-domain (no transport)" ); + }); + + jQuery.ajax({ + dataType: "jsonp", + url: loc.protocol + "//" + loc.host, + crossDomain: true, + beforeSend: function( _ , s ) { + ok( s.crossDomain , "Test forced crossDomain is detected as cross-domain" ); + return false; } - } + }); });