diff options
author | jaubourg <j@ubourg.net> | 2011-01-09 16:50:13 +0100 |
---|---|---|
committer | jaubourg <j@ubourg.net> | 2011-01-09 16:50:13 +0100 |
commit | 5a5f67800b048ae274e644547f4b8e03156ffa49 (patch) | |
tree | c5280f8af99b42e0439aed4c36e5f9a6456745d4 /test | |
parent | c55a76a23fdf8e9b22d9792a0f3a39051cc33993 (diff) | |
download | jquery-5a5f67800b048ae274e644547f4b8e03156ffa49.tar.gz jquery-5a5f67800b048ae274e644547f4b8e03156ffa49.zip |
Fixes #5955. Option crossDomain now forces ajax to consider a request as cross-domain even when it is not. Useful for when servers issue redirects to cross-domain urls. Unit test added.
Diffstat (limited to 'test')
-rw-r--r-- | test/unit/ajax.js | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/test/unit/ajax.js b/test/unit/ajax.js index 4c8c5009b..8bfd4d3e0 100644 --- a/test/unit/ajax.js +++ b/test/unit/ajax.js @@ -383,14 +383,15 @@ 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; + portFlag, + forcedFlag; if ( jQuery.ajax({ url: otherProtocol + "//" + loc.host, @@ -431,6 +432,20 @@ test("jQuery ajax - cross-domain detection", function() { } } + if ( jQuery.ajax({ + url: loc.protocol + "//" + loc.host, + crossDomain: true, + beforeSend: function( _ , s ) { + forcedFlag = 1; + ok( s.crossDomain , "Test forced crossDomain is detected as cross-domain" ); + return false; + } + }) === false ) { + if ( ! forcedFlag ) { + ok( ! jQuery.support.cors , "Test forced crossDomain is detected as cross-domain (no transport)" ); + } + } + }); test(".ajax() - 304", function() { |