aboutsummaryrefslogtreecommitdiffstats
path: root/test/unit/manipulation.js
diff options
context:
space:
mode:
authorRichard Gibson <richard.gibson@gmail.com>2018-12-12 11:21:24 -0500
committerMichał Gołębiowski-Owczarek <m.goleb@gmail.com>2018-12-12 17:21:24 +0100
commitc2026b117d1ca5b2e42a52c7e2a8ae8988cf0d4b (patch)
treed90523792dd58825c1dc50c0a89080a5192078d9 /test/unit/manipulation.js
parent4ffb1df8e4738eb86bde429ec20efc7394e5e497 (diff)
downloadjquery-c2026b117d1ca5b2e42a52c7e2a8ae8988cf0d4b.tar.gz
jquery-c2026b117d1ca5b2e42a52c7e2a8ae8988cf0d4b.zip
Manipulation: Only evaluate HTTP-successful script src
Fixes gh-4126 Closes gh-4243
Diffstat (limited to 'test/unit/manipulation.js')
-rw-r--r--test/unit/manipulation.js17
1 files changed, 17 insertions, 0 deletions
diff --git a/test/unit/manipulation.js b/test/unit/manipulation.js
index ddb04c7d6..300add5ec 100644
--- a/test/unit/manipulation.js
+++ b/test/unit/manipulation.js
@@ -2818,3 +2818,20 @@ QUnit.test( "Insert script with data-URI (gh-1887)", 1, function( assert ) {
done();
}, 100 );
} );
+
+QUnit.test( "Ignore content from unsuccessful responses (gh-4126)", 1, function( assert ) {
+ var globalEval = jQuery.globalEval;
+ jQuery.globalEval = function( code ) {
+ assert.ok( false, "no attempt to evaluate code from an unsuccessful response" );
+ };
+
+ try {
+ jQuery( "#qunit-fixture" ).append(
+ "<script src='" + url( "mock.php?action=error" ) + "'/>" );
+ assert.ok( true, "no error thrown from embedding script with unsuccessful-response src" );
+ } catch ( e ) {
+ throw e;
+ } finally {
+ jQuery.globalEval = globalEval;
+ }
+} );