aboutsummaryrefslogtreecommitdiffstats
path: root/test/unit/ajax.js
diff options
context:
space:
mode:
authorDallas Fraser <dallas.fraser.waterloo@gmail.com>2020-08-25 15:41:06 -0400
committerGitHub <noreply@github.com>2020-08-25 21:41:06 +0200
commita1e619b03a557b47c3e26a5e74af12b63a0d5e73 (patch)
tree65175107663fb32b2be82f94599f3af57d8708fe /test/unit/ajax.js
parent07a8e4a177550025c1a08d7ac754839733943f55 (diff)
downloadjquery-a1e619b03a557b47c3e26a5e74af12b63a0d5e73.tar.gz
jquery-a1e619b03a557b47c3e26a5e74af12b63a0d5e73.zip
Ajax: Execute JSONP error script responses
Issue gh-4379 was meant to be a bug fix but the JSONP case is a bit special: under the hood it's a script but it simulates JSON responses in an environment without a CORS setup and sending JSON payloads on error responses is quite typical there. This commit makes JSONP error responses still execute the payload. The regular script error responses continue to be skipped. Fixes gh-4771 Closes gh-4773
Diffstat (limited to 'test/unit/ajax.js')
-rw-r--r--test/unit/ajax.js13
1 files changed, 13 insertions, 0 deletions
diff --git a/test/unit/ajax.js b/test/unit/ajax.js
index 125470519..fe831d0b1 100644
--- a/test/unit/ajax.js
+++ b/test/unit/ajax.js
@@ -810,6 +810,19 @@ QUnit.module( "ajax", {
};
} );
+ ajaxTest( "jQuery.ajax() - do execute scripts if JSONP from unsuccessful responses", 1, function( assert ) {
+ var testMsg = "Unsuccessful JSONP requests should have a JSON body";
+ return {
+ dataType: "jsonp",
+ url: url( "mock.php?action=errorWithScript" ),
+ // error is the significant assertion
+ error: function( xhr ) {
+ var expected = { "status": 404, "msg": "Not Found" };
+ assert.deepEqual( xhr.responseJSON, expected, testMsg );
+ }
+ };
+ } );
+
ajaxTest( "jQuery.ajax() - do not execute scripts from unsuccessful responses (gh-4250)", 11, function( assert ) {
var globalEval = jQuery.globalEval;