diff options
author | Michał Gołębiowski-Owczarek <m.goleb@gmail.com> | 2020-04-27 20:22:39 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-04-27 20:22:39 +0200 |
commit | 7b0864d0539bbfbb01d88d9bc95369580ffd99bc (patch) | |
tree | 26eff67e9e2b44102107326e276f50f639a543e8 /dist | |
parent | a62309e01b3c76d2b73560ca666c454b7bbfcb77 (diff) | |
download | jquery-7b0864d0539bbfbb01d88d9bc95369580ffd99bc.tar.gz jquery-7b0864d0539bbfbb01d88d9bc95369580ffd99bc.zip |
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
Diffstat (limited to 'dist')
0 files changed, 0 insertions, 0 deletions