aboutsummaryrefslogtreecommitdiffstats
path: root/test
Commit message (Collapse)AuthorAgeFilesLines
* Tests: Exclude tests based on compilation flags, not API presence (3.x version)Michał Gołębiowski-Owczarek2022-07-1222-74/+153
| | | | | | | | | | | | | Introduces a new test API, `includesModule`. The method returns whether a particular module like "ajax" or "deprecated" is included in the current jQuery build; it handles the slim build as well. The util was created so that we don't treat presence of particular APIs to decide whether to run a test as then if we accidentally remove an API, the tests would still not fail. Closes gh-5071 Fixes gh-5069 Ref gh-5046 (partially cherry picked from commit fae5fee8b435cc20352d28b0a384b9784b1ad9ed)
* Tests: Workaround an XML parsing bug in FirefoxMichał Gołębiowski-Owczarek2022-02-281-1/+7
| | | | | | | | See https://bugzilla.mozilla.org/show_bug.cgi?id=1751796 Closes gh-5018 (cherry picked from commit af1cd6f218f699abc34b1582a910c0df00312aee)
* CSS: Skip falsy values in `addClass( array )`, compress codeMichał Gołębiowski-Owczarek2022-01-251-0/+38
| | | | | | | | | | | | | | | | | | This change makes jQuery skip falsy values in `addClass( array )` & `removeClass( array )` instead of stopping iteration when the first falsy value is detected. This makes code like: ```js elem.addClass( [ "a", "", "b" ] ); ``` add both the `a` & `b` classes. The code was also optimized for size a bit so it doesn't increase the minified gzipped size. Fixes gh-4998 Closes gh-5003 (partially cherry picked from commit a338b407f2479f82df40635055effc163835183f)
* Docs: Replace `#NUMBER` Trac issue references with `trac-NUMBER`Michał Gołębiowski-Owczarek2022-01-1229-352/+352
| | | | | | | | | | | | | | | | | This is a version of gh-4993 for the `3.x-stable` branch. The GitHub UI treats `#NUMBER` as referring to its own issues which is confusing when in jQuery source it's usually referring to the old deprecated Trac instance at https://bugs.jquery.com. This change replaces all such Trac references with `trac-NUMBER`. A few of the references came with the Sizzle integration and referred to the Sizzle GitHub bug tracker. Those have been replaced with full links instead. A new entry describing issue reference conventions has been added to README. Closes gh-4994 Ref gh-4993 Ref 5d5ea015114092c157311c4948f7cc3d8c8e7f8a
* Docs: remove expired links from old jquery sourceTimmy Willison2022-01-071-2/+0
| | | | | Ref gh-4981 Ref gh-4991
* Tests: Skip ETag AJAX tests on TestSwarmMichał Gołębiowski-Owczarek2021-12-011-5/+18
| | | | | | | | | | TestSwarm is now proxied via Cloudflare which cuts out headers relevant for ETag tests, failing them. We're still running those tests in Karma on Chrome & Firefox (including Firefox ESR). Closes gh-4974 (cherry picked from commit 00c060d1619d472a2d8c5b104ed76fa3afc2ce97)
* Tests: Allow statusText to be "success" in AJAX testsMichał Gołębiowski-Owczarek2021-12-011-1/+2
| | | | | | | | | | | | | | | In HTTP/2, status message is not supported and whatever is reported as statusText differs between browsers. In Chrome & Safari it's "success", in Firefox & IE it's "OK". So far "success" wasn't allowed. This made the tests pass locally if you're running an HTTP/1.1 server but on TestSwarm which is now proxied via an HTTP/2-equipped Cloudflare, the relevant test started failing in Chrome & Safari. Allow "success" to resolve the issue. Closes gh-4973 (cherry picked from commit 19ced963c63372eae5aca9e1a4baec80b78a2b8e)
* Tests: Disable CSS Custom Properties tests in old Safari/iOSMichał Gołębiowski-Owczarek2021-11-151-1/+11
| | | | | | | | Safari 9.1 & iOS 9.3 support CSS custom properties but that support is buggy which crashes our tests. Disable those tests there. See https://caniuse.com/css-variables Closes gh-4966
* CSS: Trim whitespace surrounding CSS Custom Properties valuesfecore12021-10-181-25/+28
| | | | | | | | | | | The spec has recently changed and CSS Custom Properties values are trimmed now. This change makes jQuery polyfill that new behavior for all browsers. Ref w3c/csswg-drafts#774 Fixes gh-4926 Closes gh-4930 (partially cherry picked from commit efadfe991a5c287af561a9326bf1427d726c91c1)
* Tests: Don't remove csp.log in the cspClean action of mock.phpMichał Gołębiowski-Owczarek2021-09-301-1/+0
| | | | | | | | | For some reason the current setup worked fine with Apache but broke for me when I migrated to nginx. Closes gh-4936 (cherry picked from commit 1019074f7b1df96ee9d6409ada3dc0562046f6c7)
* Tests: Load the TestSwarm listener via HTTPSMichał Gołębiowski-Owczarek2021-09-291-1/+1
| | | | (cherry picked from commit d225639a8ea62863482bd20249077688f60235db)
* Manipulation: Don't remove HTML comments from scriptsMichał Gołębiowski-Owczarek2021-07-191-1/+12
| | | | | | | | | | | | | | | | | | | | | When evaluating scripts, jQuery strips out the possible wrapping HTML comment and a CDATA section. However, all supported browsers are already doing that when loading JS via appending a script tag to the DOM which is how we've been doing `jQuery.globalEval` since jQuery 3.0.0. jQuery logic was imperfect, e.g. it just stripped the `<!--` and `-->` markers, respectively at the beginning or the end of the script contents. However, browsers are also stripping everything following those markers in the same line, treating them as single-line comments delimiters; this is now also mandated by ECMAScript 2015 in Annex B. Instead of fixing the jQuery logic, just let the browser do its thing. We still need to strip CDATA sections for backwards compatibility. This shouldn't be needed as in XML documents they're already not visible when inspecting element contents and in HTML documents they have no meaning but we're preserving that logic for backwards compatibility. This will be removed completely in 4.0. Fixes gh-4904 Closes gh-4905 Ref gh-4906
* Tests: Switch background image from online file to local 1x1.jpgTimo Tijhof2021-05-242-19/+9
| | | | | | | | Also, remove unused `expected` property in `css` test cases. Closes gh-4866 (cherry picked from commit 482f846203e82b1c2620f580e483bf41d11f9f49)
* Event: Don't break focus triggering after `.on(focus).off(focus)`Michał Gołębiowski-Owczarek2021-05-101-0/+16
| | | | | | | | | | | | | | | | | | | | | | 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 e539bac79e666bba95bba86d690b4e609dca2286)
* Build: Take core-js from the external directory as wellMichał Gołębiowski-Owczarek2021-04-141-1/+1
| | | | | | | | | | 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 345cd22e5664655ed315958ed2056610607c12ef)
* Tests: Strip untypical callback parameter characters from mock.phpMichał Gołębiowski-Owczarek2021-04-132-11/+21
| | | | | | | | | | | | | | 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 a70274632dc19ff4a64d7bb7657a2cc647ff38b9)
* Build: Rename master to main across the repositoryMichał Gołębiowski-Owczarek2021-02-051-3/+3
| | | | | | | | | The default branch was updated, this updates the remaining occurrences in code & comments. Closes gh-4838 (cherry picked from commit 8ae477a432f0924cd4bd3bdeaef2c4c15e483a8f)
* Tests: Fix tests for not auto-executing scripts without dataTypeMichał Gołębiowski-Owczarek2021-01-112-2/+2
| | | | | | | | | | | | | | | | 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)
* Dimensions: Modify reliableTrDimensions support test to account for FFTimmy Willison2021-01-112-8/+2
| | | | | | | | | 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
* Tests: Skip the jQuery.parseXML error reporting test in Legacy EdgeMichał Gołębiowski-Owczarek2020-12-081-3/+6
| | | | | | | | 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
* Tests: Fix the jQuery.parseXML error reporting testMichał Gołębiowski-Owczarek2020-12-081-2/+4
| | | | | | | | 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.
* Core: Report browser errors in parseXMLMichał Gołębiowski-Owczarek2020-12-081-2/+25
| | | | | | | Fixes gh-4784 Closes gh-4816 (cherry picked from commit 8969732518470a7f8e654d5bc5be0b0076cb0b87)
* Event: Make focus re-triggering not focus the original element backMichał Gołębiowski-Owczarek2020-12-071-0/+34
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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 dbcffb396c2db61ff96edc4162602e850797d61f)
* Event: Don't crash if an element is removed on blurMichał Gołębiowski-Owczarek2020-10-191-0/+27
| | | | | | | | | | | | | 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 5c2d08704e289dd2745bcb0557b35a9c0e6af4a4)
* Tests: Recognize callbacks with dots in the Node.js mock serverMichał Gołębiowski-Owczarek2020-09-021-1/+1
| | | | | | | | | | | | | | | 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 df6858df2ed3fc5c424591a5e09b900eb4ce0417)
* Tests: Skip the "jQuery.ajax() on unload" test in SafariMichał Gołębiowski-Owczarek2020-09-021-1/+4
| | | | | | | | | | | 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 c18dc49699bc27481a4af36ed1a0ee1b19c6eb03)
* Ajax: Execute JSONP error script responsesDallas Fraser2020-08-251-0/+13
| | | | | | | | | | | | | | | 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 a1e619b03a557b47c3e26a5e74af12b63a0d5e73)
* Tests: Remove an unused local variableWonhyoung Park2020-08-131-2/+1
| | | | | | Closes gh-4769 (cherry picked from commit 82b87f6f0e45ca4e717b4e3a4a20a592709a099f)
* Tests: Remove remaining obsolete jQuery.cache referencesMichał Gołębiowski-Owczarek2020-05-182-36/+5
| | | | | | | | | PR gh-4586 removed some of those but not all. Closes gh-4715 Ref gh-4586 (cherry picked from commit d96111e18b42ae1bc7def72a8a0d156ea39e4d0e)
* Tests: Remove obsolete jQuery data testsMichał Gołębiowski-Owczarek2020-05-184-115/+0
| | | | | | | | The tests relied on `jQuery.cache` so they only ever worked in jQuery 1.x. Closes gh-4586 (cherry picked from commit eb35be528fdea40faab4d89ac859d38dfd024271)
* Tests: Workaround failures in recent XSS tests in iOS 8 - 12Michał Gołębiowski-Owczarek2020-04-301-7/+15
| | | | | | | | | | 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 11066a9e6ac183dd710d1bc7aa74a3f809757136)
* Docs: Fix typosPierre Grimaud2020-04-291-2/+2
| | | | | | Closes gh-4686 (cherry picked from commit 1a7332ce83cdee7d6cd9d45c2a4b83067f53f14b)
* Tests: Add tests for recently fixed manipulation XSS issuesMichał Gołębiowski-Owczarek2020-04-291-0/+49
| | | | | | | | Closes gh-4685 Ref gh-4642 Ref gh-4647 (cherry picked from commit dc06d68bdc4c2562b5cc530f21e668a17d78ee2d)
* Tests: Cleanup `window` & `document` handlers in a new event testMichał Gołębiowski-Owczarek2020-04-271-6/+9
| | | | | | | The "focusin on document & window" test didn't cleanup `focusout` handlers on `window` & `document`. This has been fixed. Ref gh-4657
* Tests: Fix flakiness in the "jQuery.ajax() - JSONP - Same Domain" testMichał Gołębiowski-Owczarek2020-04-271-1/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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 7b0864d0539bbfbb01d88d9bc95369580ffd99bc)
* Data: Make the data object a regular object againMichał Gołębiowski-Owczarek2020-04-201-9/+12
| | | | | | | | | | | | | 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
* Ajax: Do not execute scripts for unsuccessful HTTP responsesSean Robinson2020-04-063-0/+140
| | | | | | | | | | | | 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 50871a5a85cc802421b40cc67e2830601968affe) Fixes gh-4250 Fixes gh-4655 Closes gh-4379
* Ajax: Overwrite s.contentType with content-type header value, if anyChristian Wenz2020-04-061-0/+46
| | | | | | | | | | | | | | 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 7fb90a6beaeffe16699800f73746748f6a5cc2de) Co-authored-by: Richard Gibson <richard.gibson@gmail.com> Co-authored-by: Michał Gołębiowski-Owczarek <m.goleb@gmail.com>
* Tests: Blacklist one focusin test in IEMichał Gołębiowski-Owczarek2020-04-061-1/+8
| | | | | | | 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.
* Event: Use only one focusin/out handler per matching window & documentMichał Gołębiowski-Owczarek2020-04-061-8/+43
| | | | | | | | | | | | | | | 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 1cecf64e5aa415367a7dae0b55c2dd17b591442d - the commit that introduced the regression - to make sure we don't regress on either front. Fixes gh-4652 Closes gh-4656
* Manipulation: Skip the select wrapper for <option> outside of IE 9Michał Gołębiowski-Owczarek2020-03-301-0/+13
| | | Closes gh-4647
* Manipulation: Make jQuery.htmlPrefilter an identity functionMichał Gołębiowski-Owczarek2020-03-1617-249/+245
| | | | | | Closes gh-4642 (cherry picked from 90fed4b453a5becdb7f173d9e3c1492390a1441f)
* Data:Event:Manipulation: Prevent collisions with Object.prototypeMichał Gołębiowski-Owczarek2020-03-022-0/+58
| | | | | | | | | | 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 9d76c0b163675505d1a901e5fe5249a2c55609bc)
* Build: Enable ESLint one-var rule for var declarations in browser codeMichał Gołębiowski-Owczarek2020-03-021-0/+1
| | | | | | | | | | 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 4a7fc8544e2020c75047456d11979e4e3a517fdf)
* Tests: Pass a number of necessary done() calls to assert.async()Michał Gołębiowski-Owczarek2020-03-022-10/+10
| | | | | | | | | 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 364476c3dc1231603ba61fc08068fa89fb095e1a)
* Core: Fire iframe script in its context, add doc param in globalEvalMichał Gołębiowski-Owczarek2020-02-105-4/+67
| | | | | | | | | | | | | 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 4592595b478be979141ce35c693dbc6b65647173)
* Build:Tests: Fix custom build tests, verify on Travis; name Travis jobsMichał Gołębiowski-Owczarek2020-01-2720-169/+248
| | | | | | | | | | | | | | | | 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
* Build: Make Karma work in AMD modeMichał Gołębiowski-Owczarek2020-01-216-93/+129
| | | | | | | | | | | Also, run such a suite in CI to make sure modules are working as expected when used directly. (partially cherry picked from 341c6d1b5abe4829f59fbc32e93f6a6a1afb900f) (partially cherry picked from 437f389a24a6bef213d4df507909e7e69062300b) Closes gh-4595 Ref gh-4550 Ref gh-4574
* Docs: Update links to EdgeHTML issues to go through Web ArchiveMichał Gołębiowski-Owczarek2020-01-081-22/+22
| | | | | | | | | | | | 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 1dad1185e0b2ca2a13bf411558eda75fb2d4da88) Closes gh-4584
* Tests: Make the support tests pass on Firefox 4x/5x/60Michał Gołębiowski-Owczarek2020-01-071-1/+1
| | | | | | | 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