jquery/test
Michał Gołębiowski-Owczarek 7b0864d053
Tests: Fix flakiness in the "jQuery.ajax() - JSONP - Same Domain" test
The "jQuery.ajax() - JSONP - Same Domain" test is firing a request with
a duplicate "callback" parameter, something like (simplified):
```
mock.php?action=jsonp&callback=jQuery_1&callback=jQuery_2
```

There was a difference in how the PHP & Node.js implementations of the jsonp
action in the mock server handled situations like that. The PHP implementation
was using the latest parameter while the Node.js one was turning it into an
array but the code didn't handle this situation. Because of how JavaScript
stringifies arrays, while the PHP implementation injected the following code:
```js
jQuery_2(payload)
```
the Node.js one was injecting the following one:
```js
jQuery_1,jQuery_2(payload)
```
This is a comma expression in JavaScript; it so turned out that in the majority
of cases both callbacks were identical so it was more like:
```js
jQuery_1,jQuery_1(payload)
```
which evaluates to `jQuery_1(payload)` when `jQuery_1` is defined, making the
test go as expected. In many cases, though, especially on Travis, the callbacks
were different, triggering an `Uncaught ReferenceError` error & requiring
frequent manual re-runs of Travis builds.

This commit fixes the logic in the mock Node.js server, adding special handling
for arrays.

Closes gh-4687
2020-04-27 20:22:39 +02:00
..
data Manipulation: Make jQuery.htmlPrefilter an identity function 2020-03-16 21:49:29 +01:00
integration Event: Fix delegated radio events when arrow keys are used 2015-10-18 13:06:37 -04:00
node_smoke_tests Build: Update jsdom; migrate a test with Symbol polyfill to an iframe test 2019-03-04 18:30:51 +01:00
promises_aplus_adapters Build: Update jsdom; migrate a test with Symbol polyfill to an iframe test 2019-03-04 18:30:51 +01:00
unit Ajax: Overwrite s.contentType with content-type header value, if any 2020-04-06 21:15:55 +02:00
.eslintrc.json Build: Enable ESLint one-var rule for var declarations in browser code 2020-03-02 22:25:35 +01:00
delegatetest.html Tests: Change quotes according to style guidelines 2015-10-18 13:17:23 -04:00
hovertest.html Ref #13316: Sync all documents on full vs. minified source. Close gh-1147. 2013-02-07 15:16:28 -05:00
index.html Build: Make Karma work in ES modules mode 2019-12-16 19:33:49 +01:00
jquery.js Build: Make dev mode work in Karma again, serve source files from disk 2020-01-08 00:35:55 +01:00
karma.context.html Build: Make Karma work in ES modules mode 2019-12-16 19:33:49 +01:00
karma.debug.html Build: Make Karma work in ES modules mode 2019-12-16 19:33:49 +01:00
localfile.html Manipulation: Make jQuery.htmlPrefilter an identity function 2020-03-16 21:49:29 +01:00
middleware-mockserver.js Tests: Fix flakiness in the "jQuery.ajax() - JSONP - Same Domain" test 2020-04-27 20:22:39 +02:00
networkerror.html Docs: Updated links to https where they are supported. 2016-01-13 13:26:10 -05:00
xhtml.php Added a way to run the test suite as an XHTML page. 2009-01-19 18:14:51 +00:00