jquery/test/unit
Michał Gołębiowski-Owczarek 37bded3522
Event: Increase robustness of an inner native event in leverageNative
In Firefox, alert displayed just before blurring an element dispatches
the native blur event twice which tripped the jQuery logic if a jQuery blur
handler was not attached before the trigger call.

This was because the `leverageNative` logic part for triggering first checked if
setup was done before (which, for example, is done if a jQuery handler was
registered before for this element+event pair) and - if it was not - added
a dummy handler that just returned `true`. The `leverageNative` logic made that
`true` then saved into private data, replacing the previous `saved` array. Since
`true` passed the truthy check, the second native inner handler treated `true`
as an array, crashing on the `slice` call.

The same issue could happen if a handler returning `true` is attached before
triggering. A bare `length` check would not be enough as the user handler may
return an array-like as well. To remove this potential data shape clash, capture
the inner result in an object with a `value` property instead of saving it
directly.

Since it's impossible to call `alert()` in unit tests, simulate the issue by
replacing the `addEventListener` method on a test button with a version that
calls attached blur handlers twice.

Fixes gh-5459
Closes gh-5466
Ref gh-5236

(cherry picked from commit 527fb3dcf0)
2024-05-20 18:05:38 +02:00
..
ajax.js Tests: migrate testing infrastructure to minimal dependencies 2024-03-05 13:53:39 -05:00
animation.js Tests: migrate testing infrastructure to minimal dependencies 2024-03-05 13:53:39 -05:00
attributes.js Build: migrate most grunt tasks off of grunt (3.x) 2023-09-20 18:18:42 -04:00
basic.js Tests: Exclude tests based on compilation flags, not API presence (3.x version) 2022-07-12 17:12:27 +02:00
callbacks.js Build: migrate most grunt tasks off of grunt (3.x) 2023-09-20 18:18:42 -04:00
core.js Tests: migrate testing infrastructure to minimal dependencies 2024-03-05 13:53:39 -05:00
css.js Tests: Workaround a tr width test issue in old iOS 2023-11-13 18:12:23 +01:00
data.js Build: migrate most grunt tasks off of grunt (3.x) 2023-09-20 18:18:42 -04:00
deferred.js Build: migrate most grunt tasks off of grunt (3.x) 2023-09-20 18:18:42 -04:00
deprecated.js Build: migrate most grunt tasks off of grunt (3.x) 2023-09-20 18:18:42 -04:00
dimensions.js Core: Simplify code post browser support reduction 2023-09-20 00:59:32 +02:00
effects.js Tests: migrate testing infrastructure to minimal dependencies 2024-03-05 13:53:39 -05:00
event.js Event: Increase robustness of an inner native event in leverageNative 2024-05-20 18:05:38 +02:00
exports.js Build: Update test code for compatibility with QUnit 2.x (#4297) 2019-02-18 19:03:26 +01:00
manipulation.js Manipulation: Generalize a test to support IE 2024-01-13 00:20:51 +01:00
offset.js Build: migrate most grunt tasks off of grunt (3.x) 2023-09-20 18:18:42 -04:00
queue.js Build: migrate most grunt tasks off of grunt (3.x) 2023-09-20 18:18:42 -04:00
ready.js Tests: Exclude tests based on compilation flags, not API presence (3.x version) 2022-07-12 17:12:27 +02:00
selector.js Tests: migrate testing infrastructure to minimal dependencies 2024-03-05 13:53:39 -05:00
serialize.js Build: migrate most grunt tasks off of grunt (3.x) 2023-09-20 18:18:42 -04:00
support.js Tests: migrate testing infrastructure to minimal dependencies 2024-03-05 13:53:39 -05:00
traversing.js Build: migrate most grunt tasks off of grunt (3.x) 2023-09-20 18:18:42 -04:00
tween.js Tests: migrate testing infrastructure to minimal dependencies 2024-03-05 13:53:39 -05:00
wrap.js Core: Simplify code post browser support reduction 2023-09-20 00:59:32 +02:00