]> source.dussan.org Git - jquery.git/commitdiff
Tests: Fix tests for not auto-executing scripts without dataType
authorMichał Gołębiowski-Owczarek <m.goleb@gmail.com>
Mon, 11 Jan 2021 17:20:36 +0000 (18:20 +0100)
committerMichał Gołębiowski-Owczarek <m.goleb@gmail.com>
Mon, 11 Jan 2021 17:41:36 +0000 (18:41 +0100)
Two issues are fixed in testing for responses with a script Content-Type not
getting auto-executed unless an explicit `dataType: "script"` is provided:
* the test is now using a correct "text/javascript" Content-Type; it was using
  "text/html" until now which doesn't really check if the fix works
* the Node.js based version of the tests didn't account for an empty `header`
  query string parameter

Closes gh-4824
Ref gh-2432
Ref gh-2588
Ref 39cdb8c9aa0fde68f733553ba050a2ba9d86474c

(cherry picked from commit d38528b17a846b7ca4513b41150a05436546292d)

test/middleware-mockserver.js
test/unit/ajax.js

index bb31eabfa602c153d798327e7eeec2d55437525b..36216ecc195795f151d2d44b76bcb3d7270ac2b5 100644 (file)
@@ -62,7 +62,7 @@ var mocks = {
        script: function( req, resp ) {
                if ( req.query.header === "ecma" ) {
                        resp.writeHead( 200, { "content-type": "application/ecmascript" } );
-               } else if ( req.query.header ) {
+               } else if ( "header" in req.query ) {
                        resp.writeHead( 200, { "content-type": "text/javascript" } );
                } else {
                        resp.writeHead( 200, { "content-type": "text/html" } );
index 3f301f18f5b35d1ed665b5a18ecc01654f590bad..bcb2346400ad961d16a3bc74817be876060b029c 100644 (file)
@@ -114,7 +114,7 @@ QUnit.module( "ajax", {
                return {
                        create: function( options ) {
                                options.crossDomain = true;
-                               return jQuery.ajax( url( "mock.php?action=script" ), options );
+                               return jQuery.ajax( url( "mock.php?action=script&header" ), options );
                        },
                        success: function() {
                                assert.ok( true, "success" );