aboutsummaryrefslogtreecommitdiffstats
path: root/test/unit/ajax.js
diff options
context:
space:
mode:
authorDave Methvin <dave.methvin@gmail.com>2017-09-12 12:40:00 -0400
committerDave Methvin <dave.methvin@gmail.com>2018-05-14 14:09:43 -0400
commit1f4375a34227f42570d2b72e190e51bcfb1e8597 (patch)
tree70bda12a0a500114c3ef540d85b7f08bbfdcc758 /test/unit/ajax.js
parent29e76e254059f8c2b695f4e41054260b52a6910d (diff)
downloadjquery-1f4375a34227f42570d2b72e190e51bcfb1e8597.tar.gz
jquery-1f4375a34227f42570d2b72e190e51bcfb1e8597.zip
Ajax: Allow custom attributes when script transport is used
Fixes gh-3028 Ref gh-2612 Useful, for example, to add `nonce`, `integrity`, or `crossorigin`.
Diffstat (limited to 'test/unit/ajax.js')
-rw-r--r--test/unit/ajax.js23
1 files changed, 23 insertions, 0 deletions
diff --git a/test/unit/ajax.js b/test/unit/ajax.js
index ff9fd8e70..8a13810fc 100644
--- a/test/unit/ajax.js
+++ b/test/unit/ajax.js
@@ -89,6 +89,29 @@ QUnit.module( "ajax", {
}
);
+ ajaxTest( "jQuery.ajax() - custom attributes for script tag", 4,
+ function( assert ) {
+ var nonceValue = "0123456789";
+ return {
+ create: function( options ) {
+ var xhr;
+ options.dataType = "script";
+ options.scriptAttrs = { id: "jquery-ajax-test", nonce: nonceValue };
+ xhr = jQuery.ajax( url( "data/script.php?header=ecma" ), options );
+ // Ensure the script tag has the nonce attr on it
+ assert.ok( nonceValue === jQuery( "#jquery-ajax-test" ).attr( "nonce" ), "nonce value" );
+ return xhr;
+ },
+ success: function() {
+ assert.ok( true, "success" );
+ },
+ complete: function() {
+ assert.ok( true, "complete" );
+ }
+ };
+ }
+ );
+
ajaxTest( "jQuery.ajax() - do not execute js (crossOrigin)", 2, function( assert ) {
return {
create: function( options ) {