Commit Graph

2544 Commits

Author SHA1 Message Date
Timo Tijhof
8d20cb9732 Tests: Switch background image from online file to local 1x1.jpg
Also, remove unused `expected` property in `css` test cases.

Closes gh-4866

(cherry picked from commit 482f846203)
2021-05-24 18:30:54 +02:00
Michał Gołębiowski-Owczarek
b3e4a7eb16 Event: Don't break focus triggering after .on(focus).off(focus)
The `_default` function in the special event settings for focus/blur has
always returned `true` since gh-4813 as the event was already being fired
from `leverageNative`. However, that only works if there's an active handler
on that element; this made a quick consecutive call:

```js
elem.on( "focus", function() {} ).off( "focus" );
```

make subsequent `.trigger( "focus" )` calls to not do any triggering.

The solution, already used in a similar `_default` method for the `click` event,
is to check for the `dataPriv` entry on the element for the focus event
(similarly for blur).

Fixes gh-4867
Closes gh-4885

(cherry picked from commit e539bac79e)
2021-05-10 19:13:25 +02:00
Michał Gołębiowski-Owczarek
752b8981f8 Build: Take core-js from the external directory as well
All the other files were already taken from the external directory.
The fact core-js was taken from node_modules broke IE core tests on TestSwarm.

Ref gh-4865
Ref gh-4870

(partially cherry picked from 345cd22e56)
2021-04-14 01:47:38 +02:00
Michał Gołębiowski-Owczarek
b14b62c8a2 Tests: Strip untypical callback parameter characters from mock.php
Only allow alphanumeric characters & underscores for callback parameters.
The change is done both for the PHP server as well as the Node.js-based version.
This is only test code so we're not fixing any security issue but it happens
often enough that the whole jQuery repository directory structure is deployed
onto the server with PHP enabled that it makes is easy to introduce security
issues if this cleanup is not done.

Ref gh-4764
Closes gh-4871

(cherry picked from a70274632d)
2021-04-13 22:36:19 +02:00
Michał Gołębiowski-Owczarek
627c573ac6 Build: Rename master to main across the repository
The default branch was updated, this updates the remaining occurrences in code
& comments.

Closes gh-4838

(cherry picked from commit 8ae477a432)
2021-02-05 23:21:21 +01:00
Michał Gołębiowski-Owczarek
7298e04fae Tests: Fix tests for not auto-executing scripts without dataType
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 39cdb8c9aa

(cherry picked from commit d38528b17a)
2021-01-11 18:41:36 +01:00
Timmy Willison
bcd40aa7a3
Dimensions: Modify reliableTrDimensions support test to account for FF
Firefox incorrectly (or perhaps correctly) includes table borders in computed
dimensions, but they are the only one. Workaround this by testing for it and
falling back to offset properties

Fixes gh-4529
Closes gh-4807
2021-01-11 11:56:38 -05:00
Michał Gołębiowski-Owczarek
bf06dd477a Tests: Skip the jQuery.parseXML error reporting test in Legacy Edge
Legacy Edge, similarly to IE, doesn't report XML parsing errors but just tries
to render the invalid document. Skip the error reporting test there, Edge Legacy
will return a generic "Invalid XML" error, just like IE.

Ref gh-4816
2020-12-08 14:27:05 +01:00
Michał Gołębiowski-Owczarek
1ec36332fc Tests: Fix the jQuery.parseXML error reporting test
Changes:
* Remove incorrect `QUnit.testUnlessIE` usage as that util is only available
  on `master`, not here.
* Change `firstCall.lastArg` to `firstCall.args[ 0 ]` as the former API is not
  available in older Sinon versions.
2020-12-08 12:05:41 +01:00
Michał Gołębiowski-Owczarek
54d98835b6 Core: Report browser errors in parseXML
Fixes gh-4784
Closes gh-4816

(cherry picked from commit 8969732518)
2020-12-08 11:34:50 +01:00
Michał Gołębiowski-Owczarek
2fadbc0a98 Event: Make focus re-triggering not focus the original element back
If during a focus handler another focus event is triggered:

```js
elem1.on( "focus", function() {
	elem2.trigger( "focus" );
} );
```

due to their synchronous nature everywhere outside of IE the hack added in
gh-4279 to leverage native events causes the native `.focus()` method to be
called last for the initial element, making it steal the focus back. Since
the native method is already being called in `leverageNative`, we can skip that
final call.

This aligns with changes to the `_default` method for the `click` event that
were added when `leverageNative` was introduced there.

A side effect of this change is that now `focusin` will only propagate to the
document for the last focused element. This is a change in behavior but it also
aligns us better with how this works with native methods.

Fixes gh-4382
Closes gh-4813
Ref gh-4279

(cherry picked from commit dbcffb396c)
2020-12-07 21:06:44 +01:00
Michał Gołębiowski-Owczarek
aaf9c55ad2 Event: Don't crash if an element is removed on blur
In Chrome, if an element having a `focusout` handler is blurred by
clicking outside of it, it invokes the handler synchronously. If
that handler calls `.remove()` on the element, the data is cleared,
leaving private data undefined. We're reading a property from that
data so we need to guard against this.

Fixes gh-4417
Closes gh-4799

(cherry picked from commit 5c2d08704e)
2020-10-19 21:21:54 +02:00
Michał Gołębiowski-Owczarek
4c572a7fee Tests: Recognize callbacks with dots in the Node.js mock server
This aligns the Node.js server with the previous PHP one in sending `mock.php`
as a callback if there's no `callback` parameter in the query string which is
triggered by a recently added test. This prevents the request crashing on that
Node.js server and printing a JS error:
```
TypeError: Cannot read property '1' of null
```

Closes gh-4764
Ref gh-4754

(cherry picked from commit df6858df2e)
2020-09-02 18:46:56 +02:00
Michał Gołębiowski-Owczarek
4f016c642c Tests: Skip the "jQuery.ajax() on unload" test in Safari
The test has been already skipped in Chrome as it dropped support for such
requests and now Safari has joined the squad.

This will resolve AJAX test errors we've had for a while in Safari 13 & iOS 13.

Closes gh-4779

(cherry picked from commit c18dc49699)
2020-09-02 18:05:47 +02:00
Dallas Fraser
3bae54aa50 Ajax: Execute JSONP error script responses
Issue gh-4379 was meant to be a bug fix but the JSONP case is a bit special:
under the hood it's a script but it simulates JSON responses in an environment
without a CORS setup and sending JSON payloads on error responses is quite
typical there.

This commit makes JSONP error responses still execute the payload. The regular
script error responses continue to be skipped.

Fixes gh-4771
Closes gh-4773

(cherry picked from commit a1e619b03a)
2020-08-25 21:43:02 +02:00
Wonhyoung Park
beea433d33 Tests: Remove an unused local variable
Closes gh-4769

(cherry picked from commit 82b87f6f0e)
2020-08-13 13:28:32 +02:00
Michał Gołębiowski-Owczarek
5e028c76f4 Tests: Remove remaining obsolete jQuery.cache references
PR gh-4586 removed some of those but not all.

Closes gh-4715
Ref gh-4586

(cherry picked from commit d96111e18b)
2020-05-18 18:53:26 +02:00
Michał Gołębiowski-Owczarek
8ad78cdbc4 Tests: Remove obsolete jQuery data tests
The tests relied on `jQuery.cache` so they only ever worked in jQuery 1.x.

Closes gh-4586

(cherry picked from commit eb35be528f)
2020-05-18 18:51:34 +02:00
Michał Gołębiowski-Owczarek
ea2d0d50c0 Tests: Workaround failures in recent XSS tests in iOS 8 - 12
iOS 8-12 parses `<noembed>` tags differently, executing this code. This is no
different to native behavior on that OS, though, so just accept it.

Ref gh-4685
Closes gh-4694

(cherry picked from commit 11066a9e6a)
2020-04-30 21:26:18 +02:00
Pierre Grimaud
ea3766c081 Docs: Fix typos
Closes gh-4686

(cherry picked from commit 1a7332ce83)
2020-04-29 21:18:55 +02:00
Michał Gołębiowski-Owczarek
58a8e87979 Tests: Add tests for recently fixed manipulation XSS issues
Closes gh-4685
Ref gh-4642
Ref gh-4647

(cherry picked from commit dc06d68bdc)
2020-04-29 16:50:27 +02:00
Michał Gołębiowski-Owczarek
c1c0598d8f Tests: Cleanup window & document handlers in a new event test
The "focusin on document & window" test didn't cleanup `focusout` handlers
on `window` & `document`. This has been fixed.

Ref gh-4657
2020-04-27 22:00:41 +02:00
Michał Gołębiowski-Owczarek
46ba70c5e8 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

(cherry picked from commit 7b0864d053)
2020-04-27 20:28:40 +02:00
Michał Gołębiowski-Owczarek
65e909844c
Data: Make the data object a regular object again
The change in gh-4603 made the object returned by `elem.data()`
a prototype-less object. That's a desired change to support keys
colliding with `Object.prototype` properties but it's also a breaking
change so it has to wait for jQuery 4.0.0.

A 3.x-only test was added to avoid breaking it in the future on this
branch.

Fixes gh-4665
Ref gh-4603
Closes gh-4666
2020-04-20 18:11:18 +02:00
Sean Robinson
da3dd85b63 Ajax: Do not execute scripts for unsuccessful HTTP responses
The script transport used to evaluate fetched script sources which is
undesirable for unsuccessful HTTP responses. This is different to other data
types where such a convention was fine (e.g. in case of JSON).

(cherry picked from 50871a5a85)

Fixes gh-4250
Fixes gh-4655
Closes gh-4379
2020-04-06 22:33:56 +02:00
Christian Wenz
065143c2e9 Ajax: Overwrite s.contentType with content-type header value, if any
This fixes the issue of "%20" in POST data being replaced with "+"
even for requests with content-type different from
"application/x-www-form-urlencoded", e.g. for "application/json".

Fixes gh-4119
Closes gh-4650

(cherry picked from 7fb90a6bea)

Co-authored-by: Richard Gibson <richard.gibson@gmail.com>
Co-authored-by: Michał Gołębiowski-Owczarek <m.goleb@gmail.com>
2020-04-06 21:19:25 +02:00
Michał Gołębiowski-Owczarek
1a4f10ddc3 Tests: Blacklist one focusin test in IE
The main part of the test was checking that focusin handling in an iframe works
and that's still checked. The test was also checking that it doesn't propagate
to the parent document, though, and, apparently, in IE it does. This one test
is now blacklisted in IE.
2020-04-06 20:56:02 +02:00
Michał Gołębiowski-Owczarek
9e15d6b469
Event: Use only one focusin/out handler per matching window & document
The `doc` variable in:
https://github.com/jquery/jquery/blob/3.4.1/src/event/focusin.js#L30
matched `document` for `document` & `window` for `window`, creating two
separate wrapper event handlers & calling handlers twice if at least one
`focusout` or `focusin` handler was attached on *both* `window` & `document`,
or on `window` & another regular node.

Also, fix the "focusin from an iframe" test to actually verify the behavior
from commit 1cecf64e5a - the commit that
introduced the regression - to make sure we don't regress on either front.

Fixes gh-4652
Closes gh-4656
2020-04-06 20:34:40 +02:00
Michał Gołębiowski-Owczarek
966a709090
Manipulation: Skip the select wrapper for <option> outside of IE 9
Closes gh-4647
2020-03-30 20:15:09 +02:00
Michał Gołębiowski-Owczarek
1d61fd9407 Manipulation: Make jQuery.htmlPrefilter an identity function
Closes gh-4642

(cherry picked from 90fed4b453)
2020-03-16 21:59:49 +01:00
Michał Gołębiowski-Owczarek
413ff796ae Data:Event:Manipulation: Prevent collisions with Object.prototype
Make sure events & data keys matching Object.prototype properties work.
A separate fix for such events on cloned elements was added as well.

Fixes gh-3256
Closes gh-4603

(cherry picked from commit 9d76c0b163)
2020-03-02 23:05:58 +01:00
Michał Gołębiowski-Owczarek
0fdfdd8290 Build: Enable ESLint one-var rule for var declarations in browser code
Node.js code is written more & more commonly in ES6+ so it doesn't make sense
to enable it there. There are many violations in test code so it's disabled
there as well.

Closes gh-4615

(cherry picked from commit 4a7fc8544e)
2020-03-02 22:30:00 +01:00
Michał Gołębiowski-Owczarek
5ea844f65a Tests: Pass a number of necessary done() calls to assert.async()
It is no longer needed to create `done` wrappers in tests that require
multiple async operations to complete.

Closes gh-4633

(cherry picked from commit 364476c3dc)
2020-03-02 22:18:10 +01:00
Michał Gołębiowski-Owczarek
3dedc3f2d4 Core: Fire iframe script in its context, add doc param in globalEval
1. Support passing custom document to jQuery.globalEval; the script will be
   invoked in the context of this document.
2. Fire external scripts appended to iframe contents in that iframe context;
   this was already supported & tested for inline scripts but not for external
   ones.

Fixes gh-4518
Closes gh-4601

(cherry picked from commit 4592595b47)
2020-02-10 19:20:50 +01:00
Michał Gołębiowski-Owczarek
d525ae3416
Build:Tests: Fix custom build tests, verify on Travis; name Travis jobs
This commit fixes unit tests for the following builds:

1. The no-deprecated build: `custom:-deprecated`
2. The current slim build: `custom:-ajax,-effects`
3. The 4.0 (#4553) slim build: `custom:-ajax,-callbacks,-deferred,-effects`

It also adds separate Travis jobs for the no-deprecated & slim builds.

Apart from that, add intuitive names to Travis jobs. Otherwise it's hard to see
at a glance that a particular job is running on Firefox ESR, for example.

Ref gh-4577
Ref gh-4596
Closes gh-4600
2020-01-27 18:54:47 +01:00
Michał Gołębiowski-Owczarek
46c284b12b
Build: Make Karma work in AMD mode
Also, run such a suite in CI to make sure modules are working as expected
when used directly.

(partially cherry picked from 341c6d1b5a)
(partially cherry picked from 437f389a24)

Closes gh-4595
Ref gh-4550
Ref gh-4574
2020-01-21 13:26:47 +01:00
Michał Gołębiowski-Owczarek
d72faced11 Docs: Update links to EdgeHTML issues to go through Web Archive
With Microsoft going Chromium with Edge, its old EdgeHTML issues were all
removed. :(

The commit also reformats one manipulation unit test to use tabs instead
of spaces for indentation.

(partially cherry-picked from 1dad1185e0)

Closes gh-4584
2020-01-08 01:30:30 +01:00
Michał Gołębiowski-Owczarek
f0d5ec62c3
Tests: Make the support tests pass on Firefox 4x/5x/60
The check for old Firefox versions with different support test result only
checked for Firefox 52 or 60. It now checks for 4x/5x/60 to understand more
versions.

Closes gh-4583
2020-01-07 17:05:14 +01:00
Michał Gołębiowski-Owczarek
f36f6abbb3 Event: Only attach events to objects that accept data - for real
There was a check in jQuery.event.add that was supposed to make it a noop
for objects that don't accept data like text or comment nodes. The problem was
the check was incorrect: it assumed `dataPriv.get( elem )` returns a falsy
value for an `elem` that doesn't accept data but that's not the case - we get
an empty object then. The check was changed to use `acceptData` directly.

(cherry picked from d5c505e35d)

Fixes gh-4397
Closes gh-4558
2019-12-09 19:53:17 +01:00
Michał Gołębiowski-Owczarek
c79e1d5fef
Tests: Skip a "width/height on a table row with phantom borders" test in Firefox
Firefox 70 & newer fail this test but the issue there is more profound - Firefox
doesn't subtract borders from table row computed widths.

Closes gh-4537
Ref jquery/jquery#4529
Ref https://bugzilla.mozilla.org/show_bug.cgi?id=1590837
Ref w3c/csswg-drafts#4444
2019-10-28 20:38:33 +01:00
Michał Gołębiowski-Owczarek
c5b48c8caa
Tests: Don't test synchronous XHR on unload in Chrome
Chrome 78 dropped support for synchronous XHR requests inside of
beforeunload, unload, pagehide, and visibilitychange event handlers.
See https://bugs.chromium.org/p/chromium/issues/detail?id=952452

Closes gh-4536
2019-10-28 20:27:49 +01:00
Michał Gołębiowski-Owczarek
6d31477a35
CSS: Workaround buggy getComputedStyle on table rows in IE/Edge
Fixes gh-4490
Closes gh-4503
2019-10-14 18:34:06 +02:00
Shashanka Nataraj
56e73e0c4a Core: Deprecate jQuery.trim
Fixes gh-4363
Closes gh-4461

(cherry picked from 5ea5946094)
2019-09-26 01:00:55 +02:00
Ahmed.S.ElAfifi
2f666c1dab Core: Use Array.prototype.flat where supported
Calling `Array.prototype.concat.apply( [], inputArray )` to flatten `inputArray`
crashes for large arrays; using `Array.prototype.flat` avoids these issues in
browsers that support it. In case it's necessary to support these large arrays
even in older browsers, a polyfill for `Array.prototype.flat` can be loaded.
This is already being done by many applications.

(cherry picked from 9df4f1de12)

Fixes gh-4320
Closes gh-4459
2019-09-25 17:49:32 +02:00
Michał Gołębiowski-Owczarek
409cbda7fe Core: Implement .even() & .odd() to replace POS :even & :odd
`:even` & `:odd` are deprecated since jQuery 3.4.0 & will be removed in 4.0.0.
The new `even()` & `odd()` methods will make the migration easier.

Closes gh-4485

(cherry picked from commit 78420d427c)
2019-09-24 02:05:39 +02:00
Michał Gołębiowski-Owczarek
0c67da4b74
Tests: Fix offset fractions tests in Chrome for Android
This commit backports a looser assertion from `master` where the browsers passes
offset tests.

Closes gh-4470
2019-09-24 00:58:53 +02:00
Michał Gołębiowski-Owczarek
6276cb2e23 Tests: Move Android user agent detection above iOS, put Safari last
Android was catching the generic iOS regex. Checking for Android first should
eliminate that issue as iOS user agents don't contain the word "Android".
Putting Safari last makes Android UAs not be tested against it.
2019-09-24 00:46:21 +02:00
Michał Gołębiowski-Owczarek
8167327fd9
Tests: Make support tests accept Safari 13 & newer
The regexes detecting browsers with their versions have been updated for iOS
and Safari so that all iOS >=11 & all Safari (desktop) >= 11 are recognized.
This is required to make Safari 13 & iOS 13 pass support tests but it'll also
make tests forward-compatible with future Safari/iOS versions.

Closes gh-4488
2019-09-23 19:28:43 +02:00
Michał Gołębiowski-Owczarek
2d9d6d5b47
Selector: Make selector-native's isXMLDoc recognize HTML-embedded SVG
This commit also backports some jQuery.isXMLDoc tests from master so that this
behavior doesn't regress.

(partially cherry-picked from 79b74e043a)

Closes gh-4438
Ref jquery/sizzle#378
Ref jquery/sizzle#436
2019-07-29 22:06:18 +02:00
Pat O'Callaghan
42badf3460 Traversing: Fix contents() on <object>s with children
(cherry-picked from 4d865d96aa)

Fixes gh-4384
Closes gh-4385
2019-05-06 21:07:53 +02:00