aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorMichał Gołębiowski <m.goleb@gmail.com>2015-03-30 20:00:38 +0200
committerMichał Gołębiowski <m.goleb@gmail.com>2015-05-18 22:26:00 +0200
commit61f812b7e7b88dd6e0078c241e4c88905ea51562 (patch)
treefeecff2c00dcdd227b34dcc07e12a5de733f8121 /test
parent3699ef463224a08233f9c37c6c7ad8235eb9a758 (diff)
downloadjquery-61f812b7e7b88dd6e0078c241e4c88905ea51562.tar.gz
jquery-61f812b7e7b88dd6e0078c241e4c88905ea51562.zip
Ajax: Use the native XHR for all non-local requests in IE9+
IE throws an error on cross-domain PATCH requests if issued via the ActiveX interface. This commit switches the logic to use the native XHR in all non-local requests. Fixes gh-1684 Closes gh-2183
Diffstat (limited to 'test')
-rw-r--r--test/integration/gh-1684-ajax.html52
-rw-r--r--test/unit/ajax.js6
2 files changed, 56 insertions, 2 deletions
diff --git a/test/integration/gh-1684-ajax.html b/test/integration/gh-1684-ajax.html
new file mode 100644
index 000000000..55e31d7fe
--- /dev/null
+++ b/test/integration/gh-1684-ajax.html
@@ -0,0 +1,52 @@
+<!DOCTYPE html>
+<html>
+<head lang="en">
+ <meta charset="UTF-8">
+ <meta http-equiv="X-UA-Compatible" content="IE=edge">
+ <title>Test for gh-1684</title>
+ <style>
+ #result {
+ font-size: 24px;
+ margin: 0.5em 0;
+ }
+ #response {
+ white-space: pre;
+ }
+ .error {
+ background-color: red;
+ }
+ .warn {
+ background-color: yellow;
+ }
+ .success {
+ background-color: lightgreen;
+ }
+ </style>
+</head>
+
+<body>
+ <div id="result"></div>
+ <div id="response"></div>
+ <script src="../../dist/jquery.js"></script>
+ <script>
+ if ( !jQuery.support.cors ) {
+ jQuery( "#result" )
+ .addClass( "success" )
+ .text( "CORS not supported in this browser. Test not run." );
+ } else {
+ jQuery.ajax( {
+ url: "http://httpbin.org/patch",
+ method: "PATCH",
+ success: function( data ) {
+ jQuery( "#result" ).addClass( "success" ).text( "Test passed." );
+ jQuery( "#response" ).text( "Response:\n" + JSON.stringify( data, null, 4 ) );
+ },
+ error: function( error ) {
+ jQuery( "#result" ).addClass( "error" ).text( "Test failed." );
+ jQuery( "#response" ).text( "Error:\n" + JSON.stringify( error, null, 4 ) );
+ }
+ } );
+ }
+ </script>
+</body>
+</html>
diff --git a/test/unit/ajax.js b/test/unit/ajax.js
index f030b48fc..1233f14ce 100644
--- a/test/unit/ajax.js
+++ b/test/unit/ajax.js
@@ -1578,8 +1578,10 @@ module( "ajax", {
}
} );
- // BrowserStack PATCH support sometimes breaks so on TestSwarm run the test in IE8 only.
- if ( location.search.indexOf( "swarmURL=" ) === -1 || document.documentMode < 9 ) {
+ // BrowserStack PATCH support sometimes breaks so on TestSwarm run the test in IE only.
+ // Unfortunately, all IE versions gets special treatment in request object creation
+ // so we need to test in all supported IE versions to be sure.
+ if ( location.search.indexOf( "swarmURL=" ) === -1 || document.documentMode ) {
ajaxTest( "#13240 - jQuery.ajax() - support non-RFC2616 methods", 1, {
url: "data/echoQuery.php",
method: "PATCH",