From f9f922618ab8919e6572688c30011141356bec91 Mon Sep 17 00:00:00 2001 From: Jennifer Shehane Date: Wed, 2 Oct 2024 13:38:30 -0400 Subject: [PATCH 01/18] remove jquery patch BREAKING: remove the patch that was preventing width/height calculation changes --- .../driver/patches/jquery+3.4.1.dev.patch | 253 ------------------ 1 file changed, 253 deletions(-) delete mode 100644 packages/driver/patches/jquery+3.4.1.dev.patch diff --git a/packages/driver/patches/jquery+3.4.1.dev.patch b/packages/driver/patches/jquery+3.4.1.dev.patch deleted file mode 100644 index 4b7abd8f32fd..000000000000 --- a/packages/driver/patches/jquery+3.4.1.dev.patch +++ /dev/null @@ -1,253 +0,0 @@ -diff --git a/node_modules/jquery/README.md b/node_modules/jquery/README.md -deleted file mode 100644 -index 411a859..0000000 ---- a/node_modules/jquery/README.md -+++ /dev/null -@@ -1,67 +0,0 @@ --# jQuery -- --> jQuery is a fast, small, and feature-rich JavaScript library. -- --For information on how to get started and how to use jQuery, please see [jQuery's documentation](http://api.jquery.com/). --For source files and issues, please visit the [jQuery repo](https://github.com/jquery/jquery). -- --If upgrading, please see the [blog post for 3.4.1](https://blog.jquery.com/2019/05/01/jquery-3-4-1-triggering-focus-events-in-ie-and-finding-root-elements-in-ios-10/). This includes notable differences from the previous version and a more readable changelog. -- --## Including jQuery -- --Below are some of the most common ways to include jQuery. -- --### Browser -- --#### Script tag -- --```html -- --``` -- --#### Babel -- --[Babel](http://babeljs.io/) is a next generation JavaScript compiler. One of the features is the ability to use ES6/ES2015 modules now, even though browsers do not yet support this feature natively. -- --```js --import $ from "jquery"; --``` -- --#### Browserify/Webpack -- --There are several ways to use [Browserify](http://browserify.org/) and [Webpack](https://webpack.github.io/). For more information on using these tools, please refer to the corresponding project's documention. In the script, including jQuery will usually look like this... -- --```js --var $ = require("jquery"); --``` -- --#### AMD (Asynchronous Module Definition) -- --AMD is a module format built for the browser. For more information, we recommend [require.js' documentation](http://requirejs.org/docs/whyamd.html). -- --```js --define(["jquery"], function($) { -- --}); --``` -- --### Node -- --To include jQuery in [Node](nodejs.org), first install with npm. -- --```sh --npm install jquery --``` -- --For jQuery to work in Node, a window with a document is required. Since no such window exists natively in Node, one can be mocked by tools such as [jsdom](https://github.com/tmpvar/jsdom). This can be useful for testing purposes. -- --```js --require("jsdom").env("", function(err, window) { -- if (err) { -- console.error(err); -- return; -- } -- -- var $ = require("jquery")(window); --}); --``` -diff --git a/node_modules/jquery/dist/jquery.js b/node_modules/jquery/dist/jquery.js -index 773ad95..84ca2f6 100644 ---- a/node_modules/jquery/dist/jquery.js -+++ b/node_modules/jquery/dist/jquery.js -@@ -1100,19 +1100,17 @@ setDocument = Sizzle.setDocument = function( node ) { - docElem = document.documentElement; - documentIsHTML = !isXML( document ); - -- // Support: IE 9-11, Edge -- // Accessing iframe documents after unload throws "permission denied" errors (jQuery #13936) -- if ( preferredDoc !== document && -- (subWindow = document.defaultView) && subWindow.top !== subWindow ) { -+ // Support: IE 9 - 11+, Edge 12 - 18+ -+ // Accessing iframe documents after unload throws "permission denied" errors (see trac-13936) -+ // Support: IE 11+, Edge 17 - 18+ -+ // IE/Edge sometimes throw a "Permission denied" error when strict-comparing -+ // two documents; shallow comparisons work. -+ // eslint-disable-next-line eqeqeq -+ if ( docElem.msMatchesSelector && preferredDoc != document && -+ ( subWindow = document.defaultView ) && subWindow.top !== subWindow ) { - -- // Support: IE 11, Edge -- if ( subWindow.addEventListener ) { -- subWindow.addEventListener( "unload", unloadHandler, false ); -- -- // Support: IE 9 - 10 only -- } else if ( subWindow.attachEvent ) { -- subWindow.attachEvent( "onunload", unloadHandler ); -- } -+ // Support: IE 9 - 11+, Edge 12 - 18+ -+ subWindow.addEventListener( "unload", unloadHandler ); - } - - /* Attributes -@@ -6534,69 +6491,100 @@ function boxModelAdjustment( elem, dimension, box, isBorderBox, styles, computed - return delta; - } - --function getWidthOrHeight( elem, dimension, extra ) { -+function augmentWidthOrHeight( elem, name, extra, isBorderBox, styles ) { -+ var i, -+ val = 0; - -- // Start with computed style -- var styles = getStyles( elem ), -+ // If we already have the right measurement, avoid augmentation -+ if ( extra === ( isBorderBox ? "border" : "content" ) ) { -+ i = 4; - -- // To avoid forcing a reflow, only fetch boxSizing if we need it (gh-4322). -- // Fake content-box until we know it's needed to know the true value. -- boxSizingNeeded = !support.boxSizingReliable() || extra, -- isBorderBox = boxSizingNeeded && -- jQuery.css( elem, "boxSizing", false, styles ) === "border-box", -- valueIsBorderBox = isBorderBox, -+ // Otherwise initialize for horizontal or vertical properties -+ } else { -+ i = name === "width" ? 1 : 0; -+ } - -- val = curCSS( elem, dimension, styles ), -- offsetProp = "offset" + dimension[ 0 ].toUpperCase() + dimension.slice( 1 ); -+ for ( ; i < 4; i += 2 ) { - -- // Support: Firefox <=54 -- // Return a confounding non-pixel value or feign ignorance, as appropriate. -- if ( rnumnonpx.test( val ) ) { -- if ( !extra ) { -- return val; -+ // Both box models exclude margin, so add it if we want it -+ if ( extra === "margin" ) { -+ val += jQuery.css( elem, extra + cssExpand[ i ], true, styles ); -+ } -+ -+ if ( isBorderBox ) { -+ -+ // border-box includes padding, so remove it if we want content -+ if ( extra === "content" ) { -+ val -= jQuery.css( elem, "padding" + cssExpand[ i ], true, styles ); -+ } -+ -+ // At this point, extra isn't border nor margin, so remove border -+ if ( extra !== "margin" ) { -+ val -= jQuery.css( elem, "border" + cssExpand[ i ] + "Width", true, styles ); -+ } -+ } else { -+ -+ // At this point, extra isn't content, so add padding -+ val += jQuery.css( elem, "padding" + cssExpand[ i ], true, styles ); -+ -+ // At this point, extra isn't content nor padding, so add border -+ if ( extra !== "padding" ) { -+ val += jQuery.css( elem, "border" + cssExpand[ i ] + "Width", true, styles ); -+ } - } -- val = "auto"; - } - -+ return val; -+} - -- // Fall back to offsetWidth/offsetHeight when value is "auto" -- // This happens for inline elements with no explicit setting (gh-3571) -- // Support: Android <=4.1 - 4.3 only -- // Also use offsetWidth/offsetHeight for misreported inline dimensions (gh-3602) -- // Support: IE 9-11 only -- // Also use offsetWidth/offsetHeight for when box sizing is unreliable -- // We use getClientRects() to check for hidden/disconnected. -- // In those cases, the computed value can be trusted to be border-box -- if ( ( !support.boxSizingReliable() && isBorderBox || -- val === "auto" || -- !parseFloat( val ) && jQuery.css( elem, "display", false, styles ) === "inline" ) && -- elem.getClientRects().length ) { -+function getWidthOrHeight( elem, name, extra ) { - -+ // Start with offset property, which is equivalent to the border-box value -+ var val, -+ valueIsBorderBox = true, -+ styles = getStyles( elem ), - isBorderBox = jQuery.css( elem, "boxSizing", false, styles ) === "border-box"; - -- // Where available, offsetWidth/offsetHeight approximate border box dimensions. -- // Where not available (e.g., SVG), assume unreliable box-sizing and interpret the -- // retrieved value as a content box dimension. -- valueIsBorderBox = offsetProp in elem; -- if ( valueIsBorderBox ) { -- val = elem[ offsetProp ]; -- } -+ // Support: IE <=11 only -+ // Running getBoundingClientRect on a disconnected node -+ // in IE throws an error. -+ if ( elem.getClientRects().length ) { -+ val = elem.getBoundingClientRect()[ name ]; - } - -- // Normalize "" and auto -- val = parseFloat( val ) || 0; -+ // Some non-html elements return undefined for offsetWidth, so check for null/undefined -+ // svg - https://bugzilla.mozilla.org/show_bug.cgi?id=649285 -+ // MathML - https://bugzilla.mozilla.org/show_bug.cgi?id=491668 -+ if ( val <= 0 || val == null ) { - -- // Adjust for the element's box model -+ // Fall back to computed then uncomputed css if necessary -+ val = curCSS( elem, name, styles ); -+ if ( val < 0 || val == null ) { -+ val = elem.style[ name ]; -+ } -+ -+ // Computed unit is not pixels. Stop here and return. -+ if ( rnumnonpx.test( val ) ) { -+ return val; -+ } -+ -+ // Check for style in case a browser which returns unreliable values -+ // for getComputedStyle silently falls back to the reliable elem.style -+ valueIsBorderBox = isBorderBox && -+ ( support.boxSizingReliable() || val === elem.style[ name ] ); -+ -+ // Normalize "", auto, and prepare for extra -+ val = parseFloat( val ) || 0; -+ } -+ -+ // Use the active box-sizing model to add/subtract irrelevant styles - return ( val + -- boxModelAdjustment( -+ augmentWidthOrHeight( - elem, -- dimension, -+ name, - extra || ( isBorderBox ? "border" : "content" ), - valueIsBorderBox, -- styles, -- -- // Provide the current computed size to request scroll gutter calculation (gh-3589) -- val -+ styles - ) - ) + "px"; - } \ No newline at end of file From f1b591fdc7710a7d3907d7191f88c326c00dc7d4 Mon Sep 17 00:00:00 2001 From: Jennifer Shehane Date: Wed, 2 Oct 2024 13:44:47 -0400 Subject: [PATCH 02/18] changelog entry --- cli/CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/cli/CHANGELOG.md b/cli/CHANGELOG.md index 187f1f691405..aa43ee41e9dd 100644 --- a/cli/CHANGELOG.md +++ b/cli/CHANGELOG.md @@ -7,6 +7,7 @@ _Released 12/3/2024 (PENDING)_ - Removed support for Node.js 16 and Node.js 21. Addresses [#29930](https://github.com/cypress-io/cypress/issues/29930). - Prebuilt binaries for Linux are no longer compatible with Linux distributions based on glibc <2.28, for example: Ubuntu 14-18, RHEL 7, CentOS 7, Amazon Linux 2. Addresses [#29601](https://github.com/cypress-io/cypress/issues/29601). +- Cypress's jQuery has been updated to now return the width and height excluding scrollbars. This matches jQuery 3.2.0+ behavior and more closely aligns with the CSS box model. `cy.scrollTo()` will now take these new calculations into account when scrolling and will scroll to a more accurate position. Also calls to`Cypress.$().height()` or `Cypress.$().width()` may return different, more correct values due to this change. Addresses [#30345](https://github.com/cypress-io/cypress/pull/30345). ## 13.15.1 From 844db79c034f86681efd408070ac5ea889055322 Mon Sep 17 00:00:00 2001 From: Jennifer Shehane Date: Wed, 2 Oct 2024 13:55:13 -0400 Subject: [PATCH 03/18] fix issue link --- cli/CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cli/CHANGELOG.md b/cli/CHANGELOG.md index aa43ee41e9dd..99dda35f53c6 100644 --- a/cli/CHANGELOG.md +++ b/cli/CHANGELOG.md @@ -7,7 +7,7 @@ _Released 12/3/2024 (PENDING)_ - Removed support for Node.js 16 and Node.js 21. Addresses [#29930](https://github.com/cypress-io/cypress/issues/29930). - Prebuilt binaries for Linux are no longer compatible with Linux distributions based on glibc <2.28, for example: Ubuntu 14-18, RHEL 7, CentOS 7, Amazon Linux 2. Addresses [#29601](https://github.com/cypress-io/cypress/issues/29601). -- Cypress's jQuery has been updated to now return the width and height excluding scrollbars. This matches jQuery 3.2.0+ behavior and more closely aligns with the CSS box model. `cy.scrollTo()` will now take these new calculations into account when scrolling and will scroll to a more accurate position. Also calls to`Cypress.$().height()` or `Cypress.$().width()` may return different, more correct values due to this change. Addresses [#30345](https://github.com/cypress-io/cypress/pull/30345). +- Cypress's jQuery has been updated to now return the width and height excluding scrollbars. This matches jQuery 3.2.0+ behavior and more closely aligns with the CSS box model. `cy.scrollTo()` will now take these new calculations into account when scrolling and will scroll to a more accurate position. Also calls to`Cypress.$().height()` or `Cypress.$().width()` may return different, more correct values due to this change. Addresses [#29846](https://github.com/cypress-io/cypress/issues/29846). ## 13.15.1 From eb86a7c627751ddc11ca8b5b7e2afc90b39891c8 Mon Sep 17 00:00:00 2001 From: Jennifer Shehane Date: Wed, 2 Oct 2024 14:58:08 -0400 Subject: [PATCH 04/18] Update halfScrollPixels to width/height that jQuery returns --- packages/driver/cypress/e2e/commands/actions/scroll.cy.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/driver/cypress/e2e/commands/actions/scroll.cy.js b/packages/driver/cypress/e2e/commands/actions/scroll.cy.js index d18f45fb3e7a..09d3a1773fae 100644 --- a/packages/driver/cypress/e2e/commands/actions/scroll.cy.js +++ b/packages/driver/cypress/e2e/commands/actions/scroll.cy.js @@ -28,9 +28,9 @@ describe('src/cy/commands/actions/scroll', () => { this.scrollBoth.scrollTop = 0 this.scrollBoth.scrollLeft = 0 - // width/height of scrollable container - width of parent viewport (minux scrollbars) / 2 to get the center + // width/height of scrollable container - width of parent viewport (without scrollbars) / 2 to get the center // browsers round up the pixel value so we need to round it - this.halfScrollPixels = Math.round((500 - 100) / 2) + this.halfScrollPixels = Math.round((500 - 85) / 2) }) describe('subject', () => { From 34a02db93c716d40092f9bc214feddee0ce52a1e Mon Sep 17 00:00:00 2001 From: Jennifer Shehane Date: Thu, 3 Oct 2024 14:36:19 -0400 Subject: [PATCH 05/18] Update scroll tests to properly check for half with no scrollbar --- .../cypress/e2e/commands/actions/scroll.cy.js | 45 +++++++++++-------- 1 file changed, 26 insertions(+), 19 deletions(-) diff --git a/packages/driver/cypress/e2e/commands/actions/scroll.cy.js b/packages/driver/cypress/e2e/commands/actions/scroll.cy.js index 09d3a1773fae..664ae9988144 100644 --- a/packages/driver/cypress/e2e/commands/actions/scroll.cy.js +++ b/packages/driver/cypress/e2e/commands/actions/scroll.cy.js @@ -28,9 +28,16 @@ describe('src/cy/commands/actions/scroll', () => { this.scrollBoth.scrollTop = 0 this.scrollBoth.scrollLeft = 0 - // width/height of scrollable container - width of parent viewport (without scrollbars) / 2 to get the center + // width or height of DOM in pixels + this.scrollableContainerWidthHeight = 500 + this.elementWidthHeight = 100 + this.scrollBarWidthHeight = 15 + + // divide by 2 to get the center // browsers round up the pixel value so we need to round it - this.halfScrollPixels = Math.round((500 - 85) / 2) + // this.halfScroll = Math.round((this.scrollableContainerWidthHeight - this.elementWidthHeight) / 2) + this.halfScrollNoScrollbar = Math.round((this.scrollableContainerWidthHeight - (this.elementWidthHeight - this.scrollBarWidthHeight)) / 2) + this.fullScrollNoScrollbar = Math.round((this.scrollableContainerWidthHeight - (this.elementWidthHeight - this.scrollBarWidthHeight))) }) describe('subject', () => { @@ -90,7 +97,7 @@ describe('src/cy/commands/actions/scroll', () => { // in the percentage of the scroll (since going the height // of the container wouldn't scroll at all...) expect(this.scrollHoriz.get(0).scrollTop).to.eq(0) - expect(this.scrollHoriz.get(0).scrollLeft).to.eq(this.halfScrollPixels) + expect(this.scrollHoriz.get(0).scrollLeft).to.eq(this.halfScrollNoScrollbar) }) }) }) @@ -112,7 +119,7 @@ describe('src/cy/commands/actions/scroll', () => { cy.get('#scroll-to-both').scrollTo('top').then(function () { expect(this.scrollBoth.get(0).scrollTop).to.eq(0) - expect(this.scrollBoth.get(0).scrollLeft).to.eq(this.halfScrollPixels) + expect(this.scrollBoth.get(0).scrollLeft).to.eq(this.halfScrollNoScrollbar) }) }) @@ -122,7 +129,7 @@ describe('src/cy/commands/actions/scroll', () => { cy.get('#scroll-to-both').scrollTo('topRight').then(function () { expect(this.scrollBoth.get(0).scrollTop).to.eq(0) - expect(this.scrollBoth.get(0).scrollLeft).to.eq((500 - 100)) + expect(this.scrollBoth.get(0).scrollLeft).to.eq(this.fullScrollNoScrollbar) }) }) @@ -131,7 +138,7 @@ describe('src/cy/commands/actions/scroll', () => { expect(this.scrollBoth.get(0).scrollLeft).to.eq(0) cy.get('#scroll-to-both').scrollTo('left').then(function () { - expect(this.scrollBoth.get(0).scrollTop).to.eq(this.halfScrollPixels) + expect(this.scrollBoth.get(0).scrollTop).to.eq(this.halfScrollNoScrollbar) expect(this.scrollBoth.get(0).scrollLeft).to.eq(0) }) }) @@ -141,8 +148,8 @@ describe('src/cy/commands/actions/scroll', () => { expect(this.scrollBoth.get(0).scrollLeft).to.eq(0) cy.get('#scroll-to-both').scrollTo('center').then(function () { - expect(this.scrollBoth.get(0).scrollTop).to.eq(this.halfScrollPixels) - expect(this.scrollBoth.get(0).scrollLeft).to.eq(this.halfScrollPixels) + expect(this.scrollBoth.get(0).scrollTop).to.eq(this.halfScrollNoScrollbar) + expect(this.scrollBoth.get(0).scrollLeft).to.eq(this.halfScrollNoScrollbar) }) }) @@ -151,8 +158,8 @@ describe('src/cy/commands/actions/scroll', () => { expect(this.scrollBoth.get(0).scrollLeft).to.eq(0) cy.get('#scroll-to-both').scrollTo('right').then(function () { - expect(this.scrollBoth.get(0).scrollTop).to.eq(this.halfScrollPixels) - expect(this.scrollBoth.get(0).scrollLeft).to.eq((500 - 100)) + expect(this.scrollBoth.get(0).scrollTop).to.eq(this.halfScrollNoScrollbar) + expect(this.scrollBoth.get(0).scrollLeft).to.eq((this.fullScrollNoScrollbar)) }) }) @@ -161,7 +168,7 @@ describe('src/cy/commands/actions/scroll', () => { expect(this.scrollBoth.get(0).scrollLeft).to.eq(0) cy.get('#scroll-to-both').scrollTo('bottomLeft').then(function () { - expect(this.scrollBoth.get(0).scrollTop).to.eq((500 - 100)) + expect(this.scrollBoth.get(0).scrollTop).to.eq((this.fullScrollNoScrollbar)) expect(this.scrollBoth.get(0).scrollLeft).to.eq(0) }) }) @@ -171,8 +178,8 @@ describe('src/cy/commands/actions/scroll', () => { expect(this.scrollBoth.get(0).scrollLeft).to.eq(0) cy.get('#scroll-to-both').scrollTo('bottom').then(function () { - expect(this.scrollBoth.get(0).scrollTop).to.eq((500 - 100)) - expect(this.scrollBoth.get(0).scrollLeft).to.eq(this.halfScrollPixels) + expect(this.scrollBoth.get(0).scrollTop).to.eq((this.fullScrollNoScrollbar)) + expect(this.scrollBoth.get(0).scrollLeft).to.eq(this.halfScrollNoScrollbar) }) }) @@ -181,8 +188,8 @@ describe('src/cy/commands/actions/scroll', () => { expect(this.scrollBoth.get(0).scrollLeft).to.eq(0) cy.get('#scroll-to-both').scrollTo('bottomRight').then(function () { - expect(this.scrollBoth.get(0).scrollTop).to.eq((500 - 100)) - expect(this.scrollBoth.get(0).scrollLeft).to.eq((500 - 100)) + expect(this.scrollBoth.get(0).scrollTop).to.eq((this.fullScrollNoScrollbar)) + expect(this.scrollBoth.get(0).scrollLeft).to.eq((this.fullScrollNoScrollbar)) }) }) }) @@ -233,8 +240,8 @@ describe('src/cy/commands/actions/scroll', () => { expect(this.scrollBoth.get(0).scrollLeft).to.eq(0) cy.get('#scroll-to-both').scrollTo('50%', '50%').then(function () { - expect(this.scrollBoth.get(0).scrollTop).to.eq(this.halfScrollPixels) - expect(this.scrollBoth.get(0).scrollLeft).to.eq(this.halfScrollPixels) + expect(this.scrollBoth.get(0).scrollTop).to.eq(this.halfScrollNoScrollbar) + expect(this.scrollBoth.get(0).scrollLeft).to.eq(this.halfScrollNoScrollbar) }) }) @@ -243,7 +250,7 @@ describe('src/cy/commands/actions/scroll', () => { expect(this.scrollBoth.get(0).scrollLeft).to.eq(0) cy.get('#scroll-to-both').scrollTo('0%', '50%').then(function () { - expect(this.scrollBoth.get(0).scrollTop).to.eq(this.halfScrollPixels) + expect(this.scrollBoth.get(0).scrollTop).to.eq(this.halfScrollNoScrollbar) expect(this.scrollBoth.get(0).scrollLeft).to.eq(0) }) }) @@ -254,7 +261,7 @@ describe('src/cy/commands/actions/scroll', () => { cy.get('#scroll-to-both').scrollTo('50%', '0%').then(function () { expect(this.scrollBoth.get(0).scrollTop).to.eq(0) - expect(this.scrollBoth.get(0).scrollLeft).to.eq(this.halfScrollPixels) + expect(this.scrollBoth.get(0).scrollLeft).to.eq(this.halfScrollNoScrollbar) }) }) }) From 19bbd98f32a3f4943c513b2e7244905f4831a6b2 Mon Sep 17 00:00:00 2001 From: Jennifer Shehane Date: Thu, 3 Oct 2024 14:36:42 -0400 Subject: [PATCH 06/18] remove passing variable that doesn't exist in jquery scrollto --- packages/driver/src/cy/commands/actions/scroll.ts | 4 ---- 1 file changed, 4 deletions(-) diff --git a/packages/driver/src/cy/commands/actions/scroll.ts b/packages/driver/src/cy/commands/actions/scroll.ts index 840fe5ca43c7..04b7f31fa958 100644 --- a/packages/driver/src/cy/commands/actions/scroll.ts +++ b/packages/driver/src/cy/commands/actions/scroll.ts @@ -381,10 +381,6 @@ export default (Commands, Cypress, cy, state) => { axis: options.axis, easing: options.easing, duration: options.duration, - // TODO: ensureScrollable option does not exist on jQuery or config/jquery.scrollto.ts. - // It can be removed. - // @ts-ignore - ensureScrollable: options.ensureScrollable, done () { return resolve(options.$el) }, From 30ef0decf99d961b39377861c4c574c18278a63b Mon Sep 17 00:00:00 2001 From: Jennifer Shehane Date: Thu, 3 Oct 2024 14:37:05 -0400 Subject: [PATCH 07/18] bump to jQuery 3.5.0 + fix invalid DOM in tests --- package.json | 2 +- packages/driver/cypress/e2e/dom/visibility.cy.ts | 2 +- .../driver/cypress/e2e/dom/visibility_shadow_dom.cy.ts | 2 +- packages/driver/package.json | 2 +- yarn.lock | 8 ++++---- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/package.json b/package.json index 8f6aeb311e83..85b7149656a4 100644 --- a/package.json +++ b/package.json @@ -262,7 +262,7 @@ "**/@types/cheerio": "0.22.21", "**/@types/enzyme": "3.10.5", "**/@types/react": "16.9.50", - "**/jquery": "3.4.1", + "**/jquery": "3.5.0", "**/pretty-format": "26.4.0", "**/sharp": "0.29.3", "**/socket.io-parser": "4.0.5", diff --git a/packages/driver/cypress/e2e/dom/visibility.cy.ts b/packages/driver/cypress/e2e/dom/visibility.cy.ts index fc747350b5c3..f6d94412e10b 100644 --- a/packages/driver/cypress/e2e/dom/visibility.cy.ts +++ b/packages/driver/cypress/e2e/dom/visibility.cy.ts @@ -168,7 +168,7 @@ describe('src/cypress/dom/visibility', () => { } // ensure all tests run against a scrollable window - const scrollThisIntoView = add('
Should be in view
') + const scrollThisIntoView = add('
Should be in view
') this.$visHidden = add('
    ') this.$parentVisHidden = add('') diff --git a/packages/driver/cypress/e2e/dom/visibility_shadow_dom.cy.ts b/packages/driver/cypress/e2e/dom/visibility_shadow_dom.cy.ts index 5d1b6779e432..18e353ee1691 100644 --- a/packages/driver/cypress/e2e/dom/visibility_shadow_dom.cy.ts +++ b/packages/driver/cypress/e2e/dom/visibility_shadow_dom.cy.ts @@ -27,7 +27,7 @@ describe('src/cypress/dom/visibility - shadow dom', () => { } // ensure all tests run against a scrollable window - const scrollThisIntoView = $(`
    Should be in view
    `).appendTo(cy.$$('body')) + const scrollThisIntoView = $(`
    Should be in view
    `).appendTo(cy.$$('body')) // scroll the 2nd element into view so that // there is always a scrollTop so we ensure diff --git a/packages/driver/package.json b/packages/driver/package.json index a59fb2d116f4..621256136fe9 100644 --- a/packages/driver/package.json +++ b/packages/driver/package.json @@ -55,7 +55,7 @@ "is-valid-domain": "0.0.20", "is-valid-hostname": "1.0.1", "jimp": "0.22.12", - "jquery": "3.4.1", + "jquery": "3.5.0", "js-cookie": "3.0.5", "json-stable-stringify": "1.0.1", "lodash": "^4.17.21", diff --git a/yarn.lock b/yarn.lock index a9c5a88e94cb..74ac44985265 100644 --- a/yarn.lock +++ b/yarn.lock @@ -19798,10 +19798,10 @@ jpeg-js@^0.4.4: resolved "https://registry.yarnpkg.com/jpeg-js/-/jpeg-js-0.4.4.tgz#a9f1c6f1f9f0fa80cdb3484ed9635054d28936aa" integrity sha512-WZzeDOEtTOBK4Mdsar0IqEU5sMr3vSV2RqkAIzUEV2BHnUfKGyswWFPFwK5EeDo93K3FohSHbLAjj0s1Wzd+dg== -jquery@3.4.1: - version "3.4.1" - resolved "https://registry.yarnpkg.com/jquery/-/jquery-3.4.1.tgz#714f1f8d9dde4bdfa55764ba37ef214630d80ef2" - integrity sha512-36+AdBzCL+y6qjw5Tx7HgzeGCzC81MDDgaUP8ld2zhx58HdqXGoBd+tHdrBMiyjGQs0Hxs/MLZTu/eHNJJuWPw== +jquery@3.5.0: + version "3.5.0" + resolved "https://registry.yarnpkg.com/jquery/-/jquery-3.5.0.tgz#9980b97d9e4194611c36530e7dc46a58d7340fc9" + integrity sha512-Xb7SVYMvygPxbFMpTFQiHh1J7HClEaThguL15N/Gg37Lri/qKyhRGZYzHRyLH8Stq3Aow0LsHO2O2ci86fCrNQ== js-beautify@1.14.6, js-beautify@^1.6.12: version "1.14.6" From 91cfc14bfc966c30527f62433fc12fe959b3f79f Mon Sep 17 00:00:00 2001 From: Jennifer Shehane Date: Thu, 3 Oct 2024 15:12:40 -0400 Subject: [PATCH 08/18] bump down jquery - got too excited --- package.json | 2 +- packages/driver/package.json | 2 +- yarn.lock | 8 ++++---- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/package.json b/package.json index 85b7149656a4..8f6aeb311e83 100644 --- a/package.json +++ b/package.json @@ -262,7 +262,7 @@ "**/@types/cheerio": "0.22.21", "**/@types/enzyme": "3.10.5", "**/@types/react": "16.9.50", - "**/jquery": "3.5.0", + "**/jquery": "3.4.1", "**/pretty-format": "26.4.0", "**/sharp": "0.29.3", "**/socket.io-parser": "4.0.5", diff --git a/packages/driver/package.json b/packages/driver/package.json index 621256136fe9..a59fb2d116f4 100644 --- a/packages/driver/package.json +++ b/packages/driver/package.json @@ -55,7 +55,7 @@ "is-valid-domain": "0.0.20", "is-valid-hostname": "1.0.1", "jimp": "0.22.12", - "jquery": "3.5.0", + "jquery": "3.4.1", "js-cookie": "3.0.5", "json-stable-stringify": "1.0.1", "lodash": "^4.17.21", diff --git a/yarn.lock b/yarn.lock index 74ac44985265..a9c5a88e94cb 100644 --- a/yarn.lock +++ b/yarn.lock @@ -19798,10 +19798,10 @@ jpeg-js@^0.4.4: resolved "https://registry.yarnpkg.com/jpeg-js/-/jpeg-js-0.4.4.tgz#a9f1c6f1f9f0fa80cdb3484ed9635054d28936aa" integrity sha512-WZzeDOEtTOBK4Mdsar0IqEU5sMr3vSV2RqkAIzUEV2BHnUfKGyswWFPFwK5EeDo93K3FohSHbLAjj0s1Wzd+dg== -jquery@3.5.0: - version "3.5.0" - resolved "https://registry.yarnpkg.com/jquery/-/jquery-3.5.0.tgz#9980b97d9e4194611c36530e7dc46a58d7340fc9" - integrity sha512-Xb7SVYMvygPxbFMpTFQiHh1J7HClEaThguL15N/Gg37Lri/qKyhRGZYzHRyLH8Stq3Aow0LsHO2O2ci86fCrNQ== +jquery@3.4.1: + version "3.4.1" + resolved "https://registry.yarnpkg.com/jquery/-/jquery-3.4.1.tgz#714f1f8d9dde4bdfa55764ba37ef214630d80ef2" + integrity sha512-36+AdBzCL+y6qjw5Tx7HgzeGCzC81MDDgaUP8ld2zhx58HdqXGoBd+tHdrBMiyjGQs0Hxs/MLZTu/eHNJJuWPw== js-beautify@1.14.6, js-beautify@^1.6.12: version "1.14.6" From b5fe393b24948c3049e1def66a64013290008c5f Mon Sep 17 00:00:00 2001 From: Jennifer Shehane Date: Fri, 4 Oct 2024 13:13:06 -0400 Subject: [PATCH 09/18] Fix the tests to be accurate --- .../cypress/e2e/commands/actions/scroll.cy.js | 49 +++++++++---------- 1 file changed, 22 insertions(+), 27 deletions(-) diff --git a/packages/driver/cypress/e2e/commands/actions/scroll.cy.js b/packages/driver/cypress/e2e/commands/actions/scroll.cy.js index 664ae9988144..d4a8f8c3fc80 100644 --- a/packages/driver/cypress/e2e/commands/actions/scroll.cy.js +++ b/packages/driver/cypress/e2e/commands/actions/scroll.cy.js @@ -35,9 +35,9 @@ describe('src/cy/commands/actions/scroll', () => { // divide by 2 to get the center // browsers round up the pixel value so we need to round it - // this.halfScroll = Math.round((this.scrollableContainerWidthHeight - this.elementWidthHeight) / 2) - this.halfScrollNoScrollbar = Math.round((this.scrollableContainerWidthHeight - (this.elementWidthHeight - this.scrollBarWidthHeight)) / 2) - this.fullScrollNoScrollbar = Math.round((this.scrollableContainerWidthHeight - (this.elementWidthHeight - this.scrollBarWidthHeight))) + this.halfScroll = Math.round((this.scrollableContainerWidthHeight - this.elementWidthHeight) / 2) + this.halfScrollWithScrollbar = Math.round((this.scrollableContainerWidthHeight - (this.elementWidthHeight - this.scrollBarWidthHeight)) / 2) + this.fullScrollWithScrollbar = Math.round((this.scrollableContainerWidthHeight - (this.elementWidthHeight - this.scrollBarWidthHeight))) }) describe('subject', () => { @@ -93,11 +93,10 @@ describe('src/cy/commands/actions/scroll', () => { expect(this.scrollHoriz.get(0).scrollLeft).to.eq(0) cy.get('#scroll-to-horizontal').scrollTo('50%').then(function () { - // they don't calculate the height of the container - // in the percentage of the scroll (since going the height - // of the container wouldn't scroll at all...) expect(this.scrollHoriz.get(0).scrollTop).to.eq(0) - expect(this.scrollHoriz.get(0).scrollLeft).to.eq(this.halfScrollNoScrollbar) + // since there is no veritical scrollbar to take into account + // this is just half of the basic width + expect(this.scrollHoriz.get(0).scrollLeft).to.eq(this.halfScroll) }) }) }) @@ -119,7 +118,7 @@ describe('src/cy/commands/actions/scroll', () => { cy.get('#scroll-to-both').scrollTo('top').then(function () { expect(this.scrollBoth.get(0).scrollTop).to.eq(0) - expect(this.scrollBoth.get(0).scrollLeft).to.eq(this.halfScrollNoScrollbar) + expect(this.scrollBoth.get(0).scrollLeft).to.eq(this.halfScrollWithScrollbar) }) }) @@ -129,7 +128,7 @@ describe('src/cy/commands/actions/scroll', () => { cy.get('#scroll-to-both').scrollTo('topRight').then(function () { expect(this.scrollBoth.get(0).scrollTop).to.eq(0) - expect(this.scrollBoth.get(0).scrollLeft).to.eq(this.fullScrollNoScrollbar) + expect(this.scrollBoth.get(0).scrollLeft).to.eq(this.fullScrollWithScrollbar) }) }) @@ -138,7 +137,7 @@ describe('src/cy/commands/actions/scroll', () => { expect(this.scrollBoth.get(0).scrollLeft).to.eq(0) cy.get('#scroll-to-both').scrollTo('left').then(function () { - expect(this.scrollBoth.get(0).scrollTop).to.eq(this.halfScrollNoScrollbar) + expect(this.scrollBoth.get(0).scrollTop).to.eq(this.halfScrollWithScrollbar) expect(this.scrollBoth.get(0).scrollLeft).to.eq(0) }) }) @@ -148,8 +147,8 @@ describe('src/cy/commands/actions/scroll', () => { expect(this.scrollBoth.get(0).scrollLeft).to.eq(0) cy.get('#scroll-to-both').scrollTo('center').then(function () { - expect(this.scrollBoth.get(0).scrollTop).to.eq(this.halfScrollNoScrollbar) - expect(this.scrollBoth.get(0).scrollLeft).to.eq(this.halfScrollNoScrollbar) + expect(this.scrollBoth.get(0).scrollTop).to.eq(this.halfScrollWithScrollbar) + expect(this.scrollBoth.get(0).scrollLeft).to.eq(this.halfScrollWithScrollbar) }) }) @@ -158,8 +157,8 @@ describe('src/cy/commands/actions/scroll', () => { expect(this.scrollBoth.get(0).scrollLeft).to.eq(0) cy.get('#scroll-to-both').scrollTo('right').then(function () { - expect(this.scrollBoth.get(0).scrollTop).to.eq(this.halfScrollNoScrollbar) - expect(this.scrollBoth.get(0).scrollLeft).to.eq((this.fullScrollNoScrollbar)) + expect(this.scrollBoth.get(0).scrollTop).to.eq(this.halfScrollWithScrollbar) + expect(this.scrollBoth.get(0).scrollLeft).to.eq((this.fullScrollWithScrollbar)) }) }) @@ -168,7 +167,7 @@ describe('src/cy/commands/actions/scroll', () => { expect(this.scrollBoth.get(0).scrollLeft).to.eq(0) cy.get('#scroll-to-both').scrollTo('bottomLeft').then(function () { - expect(this.scrollBoth.get(0).scrollTop).to.eq((this.fullScrollNoScrollbar)) + expect(this.scrollBoth.get(0).scrollTop).to.eq((this.fullScrollWithScrollbar)) expect(this.scrollBoth.get(0).scrollLeft).to.eq(0) }) }) @@ -178,8 +177,8 @@ describe('src/cy/commands/actions/scroll', () => { expect(this.scrollBoth.get(0).scrollLeft).to.eq(0) cy.get('#scroll-to-both').scrollTo('bottom').then(function () { - expect(this.scrollBoth.get(0).scrollTop).to.eq((this.fullScrollNoScrollbar)) - expect(this.scrollBoth.get(0).scrollLeft).to.eq(this.halfScrollNoScrollbar) + expect(this.scrollBoth.get(0).scrollTop).to.eq((this.fullScrollWithScrollbar)) + expect(this.scrollBoth.get(0).scrollLeft).to.eq(this.halfScrollWithScrollbar) }) }) @@ -188,8 +187,8 @@ describe('src/cy/commands/actions/scroll', () => { expect(this.scrollBoth.get(0).scrollLeft).to.eq(0) cy.get('#scroll-to-both').scrollTo('bottomRight').then(function () { - expect(this.scrollBoth.get(0).scrollTop).to.eq((this.fullScrollNoScrollbar)) - expect(this.scrollBoth.get(0).scrollLeft).to.eq((this.fullScrollNoScrollbar)) + expect(this.scrollBoth.get(0).scrollTop).to.eq((this.fullScrollWithScrollbar)) + expect(this.scrollBoth.get(0).scrollLeft).to.eq((this.fullScrollWithScrollbar)) }) }) }) @@ -240,8 +239,8 @@ describe('src/cy/commands/actions/scroll', () => { expect(this.scrollBoth.get(0).scrollLeft).to.eq(0) cy.get('#scroll-to-both').scrollTo('50%', '50%').then(function () { - expect(this.scrollBoth.get(0).scrollTop).to.eq(this.halfScrollNoScrollbar) - expect(this.scrollBoth.get(0).scrollLeft).to.eq(this.halfScrollNoScrollbar) + expect(this.scrollBoth.get(0).scrollTop).to.eq(this.halfScrollWithScrollbar) + expect(this.scrollBoth.get(0).scrollLeft).to.eq(this.halfScrollWithScrollbar) }) }) @@ -250,7 +249,7 @@ describe('src/cy/commands/actions/scroll', () => { expect(this.scrollBoth.get(0).scrollLeft).to.eq(0) cy.get('#scroll-to-both').scrollTo('0%', '50%').then(function () { - expect(this.scrollBoth.get(0).scrollTop).to.eq(this.halfScrollNoScrollbar) + expect(this.scrollBoth.get(0).scrollTop).to.eq(this.halfScrollWithScrollbar) expect(this.scrollBoth.get(0).scrollLeft).to.eq(0) }) }) @@ -261,7 +260,7 @@ describe('src/cy/commands/actions/scroll', () => { cy.get('#scroll-to-both').scrollTo('50%', '0%').then(function () { expect(this.scrollBoth.get(0).scrollTop).to.eq(0) - expect(this.scrollBoth.get(0).scrollLeft).to.eq(this.halfScrollNoScrollbar) + expect(this.scrollBoth.get(0).scrollLeft).to.eq(this.halfScrollWithScrollbar) }) }) }) @@ -360,12 +359,8 @@ describe('src/cy/commands/actions/scroll', () => { // https://github.com/cypress-io/cypress/issues/1924 it('skips scrollability check', () => { - const scrollTo = cy.spy($.fn, 'scrollTo') - cy.get('button:first').scrollTo('bottom', { ensureScrollable: false }).then(() => { cy.stub(Cypress.ensure, 'isScrollable') - - expect(scrollTo).to.be.calledWithMatch({}, { ensureScrollable: false }) expect(Cypress.ensure.isScrollable).not.to.be.called }) }) From ddfc43b7135ac37fea75ee4b18797d8d7441adac Mon Sep 17 00:00:00 2001 From: Jennifer Shehane Date: Fri, 4 Oct 2024 14:35:56 -0400 Subject: [PATCH 10/18] bump jquery --- package.json | 2 +- packages/driver/package.json | 2 +- yarn.lock | 8 ++++---- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/package.json b/package.json index 8f6aeb311e83..e8d5846cfde0 100644 --- a/package.json +++ b/package.json @@ -262,7 +262,7 @@ "**/@types/cheerio": "0.22.21", "**/@types/enzyme": "3.10.5", "**/@types/react": "16.9.50", - "**/jquery": "3.4.1", + "**/jquery": "3.7.1", "**/pretty-format": "26.4.0", "**/sharp": "0.29.3", "**/socket.io-parser": "4.0.5", diff --git a/packages/driver/package.json b/packages/driver/package.json index a59fb2d116f4..5eae37cde49d 100644 --- a/packages/driver/package.json +++ b/packages/driver/package.json @@ -55,7 +55,7 @@ "is-valid-domain": "0.0.20", "is-valid-hostname": "1.0.1", "jimp": "0.22.12", - "jquery": "3.4.1", + "jquery": "3.7.1", "js-cookie": "3.0.5", "json-stable-stringify": "1.0.1", "lodash": "^4.17.21", diff --git a/yarn.lock b/yarn.lock index 31ccf4af0895..15bdc62adc35 100644 --- a/yarn.lock +++ b/yarn.lock @@ -19762,10 +19762,10 @@ jpeg-js@^0.4.4: resolved "https://registry.yarnpkg.com/jpeg-js/-/jpeg-js-0.4.4.tgz#a9f1c6f1f9f0fa80cdb3484ed9635054d28936aa" integrity sha512-WZzeDOEtTOBK4Mdsar0IqEU5sMr3vSV2RqkAIzUEV2BHnUfKGyswWFPFwK5EeDo93K3FohSHbLAjj0s1Wzd+dg== -jquery@3.4.1: - version "3.4.1" - resolved "https://registry.yarnpkg.com/jquery/-/jquery-3.4.1.tgz#714f1f8d9dde4bdfa55764ba37ef214630d80ef2" - integrity sha512-36+AdBzCL+y6qjw5Tx7HgzeGCzC81MDDgaUP8ld2zhx58HdqXGoBd+tHdrBMiyjGQs0Hxs/MLZTu/eHNJJuWPw== +jquery@3.7.1: + version "3.7.1" + resolved "https://registry.yarnpkg.com/jquery/-/jquery-3.7.1.tgz#083ef98927c9a6a74d05a6af02806566d16274de" + integrity sha512-m4avr8yL8kmFN8psrbFFFmB/If14iN5o9nw/NgnnM+kybDJpRsAynV2BsfpTYrTRysYUdADVD7CkUUizgkpLfg== js-beautify@1.14.6, js-beautify@^1.6.12: version "1.14.6" From 5d5a846965f0759990afbc57212ec79f65389a07 Mon Sep 17 00:00:00 2001 From: Jennifer Shehane Date: Mon, 7 Oct 2024 13:42:39 -0400 Subject: [PATCH 11/18] switch to client, see what breaks --- .../driver/patches/jquery+3.7.1.dev.patch | 174 ++++++++++++++++++ 1 file changed, 174 insertions(+) create mode 100644 packages/driver/patches/jquery+3.7.1.dev.patch diff --git a/packages/driver/patches/jquery+3.7.1.dev.patch b/packages/driver/patches/jquery+3.7.1.dev.patch new file mode 100644 index 000000000000..244cbe6c4d39 --- /dev/null +++ b/packages/driver/patches/jquery+3.7.1.dev.patch @@ -0,0 +1,174 @@ +diff --git a/node_modules/jquery/README.md b/node_modules/jquery/README.md +deleted file mode 100644 +index fcc11f3..0000000 +--- a/node_modules/jquery/README.md ++++ /dev/null +@@ -1,60 +0,0 @@ +-# jQuery +- +-> jQuery is a fast, small, and feature-rich JavaScript library. +- +-For information on how to get started and how to use jQuery, please see [jQuery's documentation](https://api.jquery.com/). +-For source files and issues, please visit the [jQuery repo](https://github.com/jquery/jquery). +- +-If upgrading, please see the [blog post for 3.7.1](https://blog.jquery.com/2023/08/28/jquery-3-7-1-released-reliable-table-row-dimensions/). This includes notable differences from the previous version and a more readable changelog. +- +-## Including jQuery +- +-Below are some of the most common ways to include jQuery. +- +-### Browser +- +-#### Script tag +- +-```html +- +-``` +- +-#### Webpack / Browserify / Babel +- +-There are several ways to use [Webpack](https://webpack.js.org/), [Browserify](http://browserify.org/) or [Babel](https://babeljs.io/). For more information on using these tools, please refer to the corresponding project's documentation. In the script, including jQuery will usually look like this: +- +-```js +-import $ from "jquery"; +-``` +- +-If you need to use jQuery in a file that's not an ECMAScript module, you can use the CommonJS syntax: +- +-```js +-var $ = require( "jquery" ); +-``` +- +-#### AMD (Asynchronous Module Definition) +- +-AMD is a module format built for the browser. For more information, we recommend [require.js' documentation](https://requirejs.org/docs/whyamd.html). +- +-```js +-define( [ "jquery" ], function( $ ) { +- +-} ); +-``` +- +-### Node +- +-To include jQuery in [Node](https://nodejs.org/), first install with npm. +- +-```sh +-npm install jquery +-``` +- +-For jQuery to work in Node, a window with a document is required. Since no such window exists natively in Node, one can be mocked by tools such as [jsdom](https://github.com/jsdom/jsdom). This can be useful for testing purposes. +- +-```js +-const { JSDOM } = require( "jsdom" ); +-const { window } = new JSDOM( "" ); +-const $ = require( "jquery" )( window ); +-``` +diff --git a/node_modules/jquery/dist/jquery.js b/node_modules/jquery/dist/jquery.js +index 1a86433..c81d521 100644 +--- a/node_modules/jquery/dist/jquery.js ++++ b/node_modules/jquery/dist/jquery.js +@@ -6365,7 +6365,7 @@ var rboxStyle = new RegExp( cssExpand.join( "|" ), "i" ); + + // Support: IE 9 - 11+, Edge 15 - 18+ + // IE/Edge misreport `getComputedStyle` of table rows with width/height +- // set in CSS while `offset*` properties report correct values. ++ // set in CSS while `client*` properties report correct values. + // Behavior in IE 9 is more subtle than in newer versions & it passes + // some versions of this test; make sure not to make it pass there! + // +@@ -6404,7 +6404,7 @@ var rboxStyle = new RegExp( cssExpand.join( "|" ), "i" ); + trStyle = window.getComputedStyle( tr ); + reliableTrDimensionsVal = ( parseInt( trStyle.height, 10 ) + + parseInt( trStyle.borderTopWidth, 10 ) + +- parseInt( trStyle.borderBottomWidth, 10 ) ) === tr.offsetHeight; ++ parseInt( trStyle.borderBottomWidth, 10 ) ) === tr.clientHeight; + + documentElement.removeChild( table ); + } +@@ -6630,16 +6630,16 @@ function boxModelAdjustment( elem, dimension, box, isBorderBox, styles, computed + // Account for positive content-box scroll gutter when requested by providing computedVal + if ( !isBorderBox && computedVal >= 0 ) { + +- // offsetWidth/offsetHeight is a rounded sum of content, padding, scroll gutter, and border ++ // clientWidth/clientHeight is a rounded sum of content, padding, scroll gutter, and border + // Assuming integer scroll gutter, subtract the rest and round down + delta += Math.max( 0, Math.ceil( +- elem[ "offset" + dimension[ 0 ].toUpperCase() + dimension.slice( 1 ) ] - ++ elem[ "client" + dimension[ 0 ].toUpperCase() + dimension.slice( 1 ) ] - + computedVal - + delta - + extra - + 0.5 + +- // If offsetWidth/offsetHeight is unknown, then we can't determine content-box scroll gutter ++ // If clientWidth/clientHeight is unknown, then we can't determine content-box scroll gutter + // Use an explicit zero to avoid NaN (gh-3964) + ) ) || 0; + } +@@ -6660,7 +6660,7 @@ function getWidthOrHeight( elem, dimension, extra ) { + valueIsBorderBox = isBorderBox, + + val = curCSS( elem, dimension, styles ), +- offsetProp = "offset" + dimension[ 0 ].toUpperCase() + dimension.slice( 1 ); ++ clientProp = "client" + dimension[ 0 ].toUpperCase() + dimension.slice( 1 ); + + // Support: Firefox <=54 + // Return a confounding non-pixel value or feign ignorance, as appropriate. +@@ -6673,22 +6673,22 @@ function getWidthOrHeight( elem, dimension, extra ) { + + + // Support: IE 9 - 11 only +- // Use offsetWidth/offsetHeight for when box sizing is unreliable. ++ // Use clientWidth/clientHeight for when box sizing is unreliable. + // In those cases, the computed value can be trusted to be border-box. + if ( ( !support.boxSizingReliable() && isBorderBox || + + // Support: IE 10 - 11+, Edge 15 - 18+ + // IE/Edge misreport `getComputedStyle` of table rows with width/height +- // set in CSS while `offset*` properties report correct values. ++ // set in CSS while `client*` properties report correct values. + // Interestingly, in some cases IE 9 doesn't suffer from this issue. + !support.reliableTrDimensions() && nodeName( elem, "tr" ) || + +- // Fall back to offsetWidth/offsetHeight when value is "auto" ++ // Fall back to clientWidth/clientHeight when value is "auto" + // This happens for inline elements with no explicit setting (gh-3571) + val === "auto" || + + // Support: Android <=4.1 - 4.3 only +- // Also use offsetWidth/offsetHeight for misreported inline dimensions (gh-3602) ++ // Also use clientWidth/clientHeight for misreported inline dimensions (gh-3602) + !parseFloat( val ) && jQuery.css( elem, "display", false, styles ) === "inline" ) && + + // Make sure the element is visible & connected +@@ -6696,12 +6696,12 @@ function getWidthOrHeight( elem, dimension, extra ) { + + isBorderBox = jQuery.css( elem, "boxSizing", false, styles ) === "border-box"; + +- // Where available, offsetWidth/offsetHeight approximate border box dimensions. ++ // Where available, clientWidth/clientHeight approximate border box dimensions. + // Where not available (e.g., SVG), assume unreliable box-sizing and interpret the + // retrieved value as a content box dimension. +- valueIsBorderBox = offsetProp in elem; ++ valueIsBorderBox = clientProp in elem; + if ( valueIsBorderBox ) { +- val = elem[ offsetProp ]; ++ val = elem[ clientProp ]; + } + } + +@@ -6941,11 +6941,11 @@ jQuery.each( [ "height", "width" ], function( _i, dimension ) { + ) : + 0; + +- // Account for unreliable border-box dimensions by comparing offset* to computed and ++ // Account for unreliable border-box dimensions by comparing client* to computed and + // faking a content-box to get border and padding (gh-3699) + if ( isBorderBox && scrollboxSizeBuggy ) { + subtract -= Math.ceil( +- elem[ "offset" + dimension[ 0 ].toUpperCase() + dimension.slice( 1 ) ] - ++ elem[ "client" + dimension[ 0 ].toUpperCase() + dimension.slice( 1 ) ] - + parseFloat( styles[ dimension ] ) - + boxModelAdjustment( elem, dimension, "border", false, styles ) - + 0.5 From ea9d7a267fd61ef3e8fc73ed27d2dab3f969265a Mon Sep 17 00:00:00 2001 From: Jennifer Shehane Date: Tue, 8 Oct 2024 14:43:07 -0400 Subject: [PATCH 12/18] Repatch jquery and update tests back to old logic --- .../cypress/e2e/commands/actions/scroll.cy.js | 39 +-- .../driver/patches/jquery+3.7.1.dev.patch | 227 +++++++++++------- 2 files changed, 157 insertions(+), 109 deletions(-) diff --git a/packages/driver/cypress/e2e/commands/actions/scroll.cy.js b/packages/driver/cypress/e2e/commands/actions/scroll.cy.js index d4a8f8c3fc80..508cb0053490 100644 --- a/packages/driver/cypress/e2e/commands/actions/scroll.cy.js +++ b/packages/driver/cypress/e2e/commands/actions/scroll.cy.js @@ -36,8 +36,7 @@ describe('src/cy/commands/actions/scroll', () => { // divide by 2 to get the center // browsers round up the pixel value so we need to round it this.halfScroll = Math.round((this.scrollableContainerWidthHeight - this.elementWidthHeight) / 2) - this.halfScrollWithScrollbar = Math.round((this.scrollableContainerWidthHeight - (this.elementWidthHeight - this.scrollBarWidthHeight)) / 2) - this.fullScrollWithScrollbar = Math.round((this.scrollableContainerWidthHeight - (this.elementWidthHeight - this.scrollBarWidthHeight))) + this.fullScroll = Math.round(this.scrollableContainerWidthHeight - this.elementWidthHeight) }) describe('subject', () => { @@ -55,7 +54,9 @@ describe('src/cy/commands/actions/scroll', () => { it('can use window', () => { cy.window().scrollTo('10px').then((win) => { - expect(win.scrollX).to.eq(10) + // Firefox doesn't round this number like other browsers + // So we round in the test to get consistent results here + expect(Math.round(win.scrollX)).to.eq(10) }) }) @@ -118,7 +119,7 @@ describe('src/cy/commands/actions/scroll', () => { cy.get('#scroll-to-both').scrollTo('top').then(function () { expect(this.scrollBoth.get(0).scrollTop).to.eq(0) - expect(this.scrollBoth.get(0).scrollLeft).to.eq(this.halfScrollWithScrollbar) + expect(this.scrollBoth.get(0).scrollLeft).to.eq(this.halfScroll) }) }) @@ -128,7 +129,7 @@ describe('src/cy/commands/actions/scroll', () => { cy.get('#scroll-to-both').scrollTo('topRight').then(function () { expect(this.scrollBoth.get(0).scrollTop).to.eq(0) - expect(this.scrollBoth.get(0).scrollLeft).to.eq(this.fullScrollWithScrollbar) + expect(this.scrollBoth.get(0).scrollLeft).to.eq(this.fullScroll) }) }) @@ -137,7 +138,7 @@ describe('src/cy/commands/actions/scroll', () => { expect(this.scrollBoth.get(0).scrollLeft).to.eq(0) cy.get('#scroll-to-both').scrollTo('left').then(function () { - expect(this.scrollBoth.get(0).scrollTop).to.eq(this.halfScrollWithScrollbar) + expect(this.scrollBoth.get(0).scrollTop).to.eq(this.halfScroll) expect(this.scrollBoth.get(0).scrollLeft).to.eq(0) }) }) @@ -147,8 +148,8 @@ describe('src/cy/commands/actions/scroll', () => { expect(this.scrollBoth.get(0).scrollLeft).to.eq(0) cy.get('#scroll-to-both').scrollTo('center').then(function () { - expect(this.scrollBoth.get(0).scrollTop).to.eq(this.halfScrollWithScrollbar) - expect(this.scrollBoth.get(0).scrollLeft).to.eq(this.halfScrollWithScrollbar) + expect(this.scrollBoth.get(0).scrollTop).to.eq(this.halfScroll) + expect(this.scrollBoth.get(0).scrollLeft).to.eq(this.halfScroll) }) }) @@ -157,8 +158,8 @@ describe('src/cy/commands/actions/scroll', () => { expect(this.scrollBoth.get(0).scrollLeft).to.eq(0) cy.get('#scroll-to-both').scrollTo('right').then(function () { - expect(this.scrollBoth.get(0).scrollTop).to.eq(this.halfScrollWithScrollbar) - expect(this.scrollBoth.get(0).scrollLeft).to.eq((this.fullScrollWithScrollbar)) + expect(this.scrollBoth.get(0).scrollTop).to.eq(this.halfScroll) + expect(this.scrollBoth.get(0).scrollLeft).to.eq((this.fullScroll)) }) }) @@ -167,7 +168,7 @@ describe('src/cy/commands/actions/scroll', () => { expect(this.scrollBoth.get(0).scrollLeft).to.eq(0) cy.get('#scroll-to-both').scrollTo('bottomLeft').then(function () { - expect(this.scrollBoth.get(0).scrollTop).to.eq((this.fullScrollWithScrollbar)) + expect(this.scrollBoth.get(0).scrollTop).to.eq((this.fullScroll)) expect(this.scrollBoth.get(0).scrollLeft).to.eq(0) }) }) @@ -177,8 +178,8 @@ describe('src/cy/commands/actions/scroll', () => { expect(this.scrollBoth.get(0).scrollLeft).to.eq(0) cy.get('#scroll-to-both').scrollTo('bottom').then(function () { - expect(this.scrollBoth.get(0).scrollTop).to.eq((this.fullScrollWithScrollbar)) - expect(this.scrollBoth.get(0).scrollLeft).to.eq(this.halfScrollWithScrollbar) + expect(this.scrollBoth.get(0).scrollTop).to.eq((this.fullScroll)) + expect(this.scrollBoth.get(0).scrollLeft).to.eq(this.halfScroll) }) }) @@ -187,8 +188,8 @@ describe('src/cy/commands/actions/scroll', () => { expect(this.scrollBoth.get(0).scrollLeft).to.eq(0) cy.get('#scroll-to-both').scrollTo('bottomRight').then(function () { - expect(this.scrollBoth.get(0).scrollTop).to.eq((this.fullScrollWithScrollbar)) - expect(this.scrollBoth.get(0).scrollLeft).to.eq((this.fullScrollWithScrollbar)) + expect(this.scrollBoth.get(0).scrollTop).to.eq((this.fullScroll)) + expect(this.scrollBoth.get(0).scrollLeft).to.eq((this.fullScroll)) }) }) }) @@ -239,8 +240,8 @@ describe('src/cy/commands/actions/scroll', () => { expect(this.scrollBoth.get(0).scrollLeft).to.eq(0) cy.get('#scroll-to-both').scrollTo('50%', '50%').then(function () { - expect(this.scrollBoth.get(0).scrollTop).to.eq(this.halfScrollWithScrollbar) - expect(this.scrollBoth.get(0).scrollLeft).to.eq(this.halfScrollWithScrollbar) + expect(this.scrollBoth.get(0).scrollTop).to.eq(this.halfScroll) + expect(this.scrollBoth.get(0).scrollLeft).to.eq(this.halfScroll) }) }) @@ -249,7 +250,7 @@ describe('src/cy/commands/actions/scroll', () => { expect(this.scrollBoth.get(0).scrollLeft).to.eq(0) cy.get('#scroll-to-both').scrollTo('0%', '50%').then(function () { - expect(this.scrollBoth.get(0).scrollTop).to.eq(this.halfScrollWithScrollbar) + expect(this.scrollBoth.get(0).scrollTop).to.eq(this.halfScroll) expect(this.scrollBoth.get(0).scrollLeft).to.eq(0) }) }) @@ -260,7 +261,7 @@ describe('src/cy/commands/actions/scroll', () => { cy.get('#scroll-to-both').scrollTo('50%', '0%').then(function () { expect(this.scrollBoth.get(0).scrollTop).to.eq(0) - expect(this.scrollBoth.get(0).scrollLeft).to.eq(this.halfScrollWithScrollbar) + expect(this.scrollBoth.get(0).scrollLeft).to.eq(this.halfScroll) }) }) }) diff --git a/packages/driver/patches/jquery+3.7.1.dev.patch b/packages/driver/patches/jquery+3.7.1.dev.patch index 244cbe6c4d39..75d47694f60b 100644 --- a/packages/driver/patches/jquery+3.7.1.dev.patch +++ b/packages/driver/patches/jquery+3.7.1.dev.patch @@ -65,110 +65,157 @@ index fcc11f3..0000000 -const $ = require( "jquery" )( window ); -``` diff --git a/node_modules/jquery/dist/jquery.js b/node_modules/jquery/dist/jquery.js -index 1a86433..c81d521 100644 +index 1a86433..8215d0c 100644 --- a/node_modules/jquery/dist/jquery.js +++ b/node_modules/jquery/dist/jquery.js -@@ -6365,7 +6365,7 @@ var rboxStyle = new RegExp( cssExpand.join( "|" ), "i" ); - - // Support: IE 9 - 11+, Edge 15 - 18+ - // IE/Edge misreport `getComputedStyle` of table rows with width/height -- // set in CSS while `offset*` properties report correct values. -+ // set in CSS while `client*` properties report correct values. - // Behavior in IE 9 is more subtle than in newer versions & it passes - // some versions of this test; make sure not to make it pass there! - // -@@ -6404,7 +6404,7 @@ var rboxStyle = new RegExp( cssExpand.join( "|" ), "i" ); - trStyle = window.getComputedStyle( tr ); - reliableTrDimensionsVal = ( parseInt( trStyle.height, 10 ) + - parseInt( trStyle.borderTopWidth, 10 ) + -- parseInt( trStyle.borderBottomWidth, 10 ) ) === tr.offsetHeight; -+ parseInt( trStyle.borderBottomWidth, 10 ) ) === tr.clientHeight; - - documentElement.removeChild( table ); - } -@@ -6630,16 +6630,16 @@ function boxModelAdjustment( elem, dimension, box, isBorderBox, styles, computed - // Account for positive content-box scroll gutter when requested by providing computedVal - if ( !isBorderBox && computedVal >= 0 ) { - -- // offsetWidth/offsetHeight is a rounded sum of content, padding, scroll gutter, and border -+ // clientWidth/clientHeight is a rounded sum of content, padding, scroll gutter, and border - // Assuming integer scroll gutter, subtract the rest and round down - delta += Math.max( 0, Math.ceil( -- elem[ "offset" + dimension[ 0 ].toUpperCase() + dimension.slice( 1 ) ] - -+ elem[ "client" + dimension[ 0 ].toUpperCase() + dimension.slice( 1 ) ] - - computedVal - - delta - - extra - - 0.5 - -- // If offsetWidth/offsetHeight is unknown, then we can't determine content-box scroll gutter -+ // If clientWidth/clientHeight is unknown, then we can't determine content-box scroll gutter - // Use an explicit zero to avoid NaN (gh-3964) - ) ) || 0; - } -@@ -6660,7 +6660,7 @@ function getWidthOrHeight( elem, dimension, extra ) { - valueIsBorderBox = isBorderBox, - - val = curCSS( elem, dimension, styles ), +@@ -6647,78 +6647,100 @@ function boxModelAdjustment( elem, dimension, box, isBorderBox, styles, computed + return delta + marginDelta; + } + +-function getWidthOrHeight( elem, dimension, extra ) { ++function augmentWidthOrHeight( elem, dimension, extra, isBorderBox, styles ) { ++ var i, ++ val = 0; + +- // Start with computed style +- var styles = getStyles( elem ), ++ // If we already have the right measurement, avoid augmentation ++ if ( extra === ( isBorderBox ? "border" : "content" ) ) { ++ i = 4; + +- // To avoid forcing a reflow, only fetch boxSizing if we need it (gh-4322). +- // Fake content-box until we know it's needed to know the true value. +- boxSizingNeeded = !support.boxSizingReliable() || extra, +- isBorderBox = boxSizingNeeded && +- jQuery.css( elem, "boxSizing", false, styles ) === "border-box", +- valueIsBorderBox = isBorderBox, ++ // Otherwise initialize for horizontal or vertical properties ++ } else { ++ i = dimension === "width" ? 1 : 0; ++ } + +- val = curCSS( elem, dimension, styles ), - offsetProp = "offset" + dimension[ 0 ].toUpperCase() + dimension.slice( 1 ); -+ clientProp = "client" + dimension[ 0 ].toUpperCase() + dimension.slice( 1 ); - - // Support: Firefox <=54 - // Return a confounding non-pixel value or feign ignorance, as appropriate. -@@ -6673,22 +6673,22 @@ function getWidthOrHeight( elem, dimension, extra ) { ++ for ( ; i < 4; i += 2 ) { + +- // Support: Firefox <=54 +- // Return a confounding non-pixel value or feign ignorance, as appropriate. +- if ( rnumnonpx.test( val ) ) { +- if ( !extra ) { +- return val; ++ // Both box models exclude margin, so add it if we want it ++ if ( extra === "margin" ) { ++ val += jQuery.css( elem, extra + cssExpand[ i ], true, styles ); + } +- val = "auto"; +- } ++ if ( isBorderBox ) { - // Support: IE 9 - 11 only +- // Support: IE 9 - 11 only - // Use offsetWidth/offsetHeight for when box sizing is unreliable. -+ // Use clientWidth/clientHeight for when box sizing is unreliable. - // In those cases, the computed value can be trusted to be border-box. - if ( ( !support.boxSizingReliable() && isBorderBox || - - // Support: IE 10 - 11+, Edge 15 - 18+ - // IE/Edge misreport `getComputedStyle` of table rows with width/height +- // In those cases, the computed value can be trusted to be border-box. +- if ( ( !support.boxSizingReliable() && isBorderBox || ++ // border-box includes padding, so remove it if we want content ++ if ( extra === "content" ) { ++ val -= jQuery.css( elem, "padding" + cssExpand[ i ], true, styles ); ++ } + +- // Support: IE 10 - 11+, Edge 15 - 18+ +- // IE/Edge misreport `getComputedStyle` of table rows with width/height - // set in CSS while `offset*` properties report correct values. -+ // set in CSS while `client*` properties report correct values. - // Interestingly, in some cases IE 9 doesn't suffer from this issue. - !support.reliableTrDimensions() && nodeName( elem, "tr" ) || +- // Interestingly, in some cases IE 9 doesn't suffer from this issue. +- !support.reliableTrDimensions() && nodeName( elem, "tr" ) || ++ // At this point, extra isn't border nor margin, so remove border ++ if ( extra !== "margin" ) { ++ val -= jQuery.css( elem, "border" + cssExpand[ i ] + "Width", true, styles ); ++ } ++ } else { ++ ++ // At this point, extra isn't content, so add padding ++ val += jQuery.css( elem, "padding" + cssExpand[ i ], true, styles ); - // Fall back to offsetWidth/offsetHeight when value is "auto" -+ // Fall back to clientWidth/clientHeight when value is "auto" - // This happens for inline elements with no explicit setting (gh-3571) - val === "auto" || - - // Support: Android <=4.1 - 4.3 only +- // This happens for inline elements with no explicit setting (gh-3571) +- val === "auto" || ++ // At this point, extra isn't content nor padding, so add border ++ if ( extra !== "padding" ) { ++ val += jQuery.css( elem, "border" + cssExpand[ i ] + "Width", true, styles ); ++ } ++ } ++ } + +- // Support: Android <=4.1 - 4.3 only - // Also use offsetWidth/offsetHeight for misreported inline dimensions (gh-3602) -+ // Also use clientWidth/clientHeight for misreported inline dimensions (gh-3602) - !parseFloat( val ) && jQuery.css( elem, "display", false, styles ) === "inline" ) && - - // Make sure the element is visible & connected -@@ -6696,12 +6696,12 @@ function getWidthOrHeight( elem, dimension, extra ) { - +- !parseFloat( val ) && jQuery.css( elem, "display", false, styles ) === "inline" ) && ++ return val; ++} + +- // Make sure the element is visible & connected +- elem.getClientRects().length ) { ++function getWidthOrHeight( elem, dimension, extra ) { + ++ // Start with offset property, which is equivalent to the border-box value ++ var val, ++ valueIsBorderBox = true, ++ styles = getStyles( elem ), isBorderBox = jQuery.css( elem, "boxSizing", false, styles ) === "border-box"; - // Where available, offsetWidth/offsetHeight approximate border box dimensions. -+ // Where available, clientWidth/clientHeight approximate border box dimensions. - // Where not available (e.g., SVG), assume unreliable box-sizing and interpret the - // retrieved value as a content box dimension. +- // Where not available (e.g., SVG), assume unreliable box-sizing and interpret the +- // retrieved value as a content box dimension. - valueIsBorderBox = offsetProp in elem; -+ valueIsBorderBox = clientProp in elem; - if ( valueIsBorderBox ) { +- if ( valueIsBorderBox ) { - val = elem[ offsetProp ]; -+ val = elem[ clientProp ]; - } +- } ++ // Support: IE <=11 only ++ // Running getBoundingClientRect on a disconnected node ++ // in IE throws an error. ++ if ( elem.getClientRects().length ) { ++ val = elem.getBoundingClientRect()[ dimension ]; } -@@ -6941,11 +6941,11 @@ jQuery.each( [ "height", "width" ], function( _i, dimension ) { - ) : - 0; - -- // Account for unreliable border-box dimensions by comparing offset* to computed and -+ // Account for unreliable border-box dimensions by comparing client* to computed and - // faking a content-box to get border and padding (gh-3699) - if ( isBorderBox && scrollboxSizeBuggy ) { - subtract -= Math.ceil( -- elem[ "offset" + dimension[ 0 ].toUpperCase() + dimension.slice( 1 ) ] - -+ elem[ "client" + dimension[ 0 ].toUpperCase() + dimension.slice( 1 ) ] - - parseFloat( styles[ dimension ] ) - - boxModelAdjustment( elem, dimension, "border", false, styles ) - - 0.5 +- // Normalize "" and auto +- val = parseFloat( val ) || 0; ++ // Some non-html elements return undefined for offsetWidth, so check for null/undefined ++ // svg - https://bugzilla.mozilla.org/show_bug.cgi?id=649285 ++ // MathML - https://bugzilla.mozilla.org/show_bug.cgi?id=491668 ++ if ( val <= 0 || val == null ) { ++ ++ // Fall back to computed then uncomputed css if necessary ++ val = curCSS( elem, dimension, styles ); ++ if ( val < 0 || val == null ) { ++ val = elem.style[ dimension ]; ++ } + +- // Adjust for the element's box model ++ // Computed unit is not pixels. Stop here and return. ++ if ( rnumnonpx.test( val ) ) { ++ return val; ++ } ++ ++ // Check for style in case a browser which returns unreliable values ++ // for getComputedStyle silently falls back to the reliable elem.style ++ valueIsBorderBox = isBorderBox && ++ ( support.boxSizingReliable() || val === elem.style[ dimension ] ); ++ ++ // Normalize "", auto, and prepare for extra ++ val = parseFloat( val ) || 0; ++ } ++ ++ // Use the active box-sizing model to add/subtract irrelevant styles + return ( val + +- boxModelAdjustment( ++ augmentWidthOrHeight( + elem, + dimension, + extra || ( isBorderBox ? "border" : "content" ), + valueIsBorderBox, +- styles, +- +- // Provide the current computed size to request scroll gutter calculation (gh-3589) +- val ++ styles + ) + ) + "px"; + } From 5b6378bf27c2609f02834951f50b8a112e9072aa Mon Sep 17 00:00:00 2001 From: Jennifer Shehane Date: Tue, 8 Oct 2024 14:58:16 -0400 Subject: [PATCH 13/18] add dep changelog entry --- cli/CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/cli/CHANGELOG.md b/cli/CHANGELOG.md index b9f8983de36f..f58ebae0ed0e 100644 --- a/cli/CHANGELOG.md +++ b/cli/CHANGELOG.md @@ -10,6 +10,10 @@ _Released 12/3/2024 (PENDING)_ - Cypress's jQuery has been updated to now return the width and height excluding scrollbars. This matches jQuery 3.2.0+ behavior and more closely aligns with the CSS box model. `cy.scrollTo()` will now take these new calculations into account when scrolling and will scroll to a more accurate position. Also calls to`Cypress.$().height()` or `Cypress.$().width()` may return different, more correct values due to this change. Addresses [#29846](https://github.com/cypress-io/cypress/issues/29846). - The undocumented methods `Cypress.backend('firefox:force:gc')` and `Cypress.backend('log:memory:pressure')` were removed. Addresses [#30222](https://github.com/cypress-io/cypress/issues/30222). +**Dependency Updates:** + +- Updated `jQuery` from `3.4.1` to `3.7.1`. Addressed in [#30345](https://github.com/cypress-io/cypress/pull/30345). + ## 13.15.1 _Released 10/1/2024 (PENDING)_ From 6614b8948d6e560a05770620df2afdf7167ebc0e Mon Sep 17 00:00:00 2001 From: Jennifer Shehane Date: Tue, 8 Oct 2024 16:35:13 -0400 Subject: [PATCH 14/18] remove test that's reliant on deprecated jQuery focus --- .../driver/cypress/e2e/commands/assertions.cy.js | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/packages/driver/cypress/e2e/commands/assertions.cy.js b/packages/driver/cypress/e2e/commands/assertions.cy.js index d0f2bc673ffa..3da8fa44a2fe 100644 --- a/packages/driver/cypress/e2e/commands/assertions.cy.js +++ b/packages/driver/cypress/e2e/commands/assertions.cy.js @@ -2650,18 +2650,6 @@ describe('src/cy/commands/assertions', () => { expect({}).to.have.focus }) - - it('calls into custom focus pseudos', () => { - cy.$$('button:first').focus() - const stub = cy.spy($.expr.pseudos, 'focus').as('focus') - - expect(cy.$$('button:first')).to.have.focus - - cy.get('button:first').should('have.focus') - .then(() => { - expect(stub).to.be.calledTwice - }) - }) }) context('match', () => { From 1f0bb68f768ea6a3cf6f9c07a78b359376d6e266 Mon Sep 17 00:00:00 2001 From: Jennifer Shehane Date: Tue, 8 Oct 2024 16:35:37 -0400 Subject: [PATCH 15/18] update test to follow cypress conventions for chaining --- packages/app/cypress/e2e/cypress-in-cypress-component.cy.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/app/cypress/e2e/cypress-in-cypress-component.cy.ts b/packages/app/cypress/e2e/cypress-in-cypress-component.cy.ts index b6ce3b93d8cf..ed9ebc5f3efa 100644 --- a/packages/app/cypress/e2e/cypress-in-cypress-component.cy.ts +++ b/packages/app/cypress/e2e/cypress-in-cypress-component.cy.ts @@ -37,7 +37,8 @@ describe('Cypress In Cypress CT', { viewportWidth: 1500, defaultCommandTimeout: cy.get('body').click() cy.findByTestId('playground-activator').click() - cy.findByTestId('playground-selector').clear().type('[data-cy-root]') + cy.findByTestId('playground-selector').clear() + cy.findByTestId('playground-selector').type('[data-cy-root]') // TODO: restore when Percy CSS is fixed. See https://github.com/cypress-io/cypress/issues/23435 // snapshotAUTPanel('cy.get selector') From 59caf49541016559b62fefa23f9d87b18423c642 Mon Sep 17 00:00:00 2001 From: Jennifer Shehane Date: Tue, 8 Oct 2024 16:35:59 -0400 Subject: [PATCH 16/18] Update regex to include jQuery stack traces as well as sizzle since jQuery is moving away from sizzle --- packages/app/src/runner/aut-iframe.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/packages/app/src/runner/aut-iframe.ts b/packages/app/src/runner/aut-iframe.ts index 65030131559f..c73aff2da0a3 100644 --- a/packages/app/src/runner/aut-iframe.ts +++ b/packages/app/src/runner/aut-iframe.ts @@ -14,6 +14,7 @@ import Highlight from './selector-playground/Highlight.ce.vue' type $CypressJQuery = any const sizzleRe = /sizzle/i +const jQueryRe = /jquery/i export class AutIframe { debouncedToggleSelectorPlayground: DebouncedFunc<(isEnabled: any) => void> @@ -540,8 +541,8 @@ export class AutIframe { $el = $root.find(selector) } } catch (err) { - // if not a sizzle error, ignore it and let $el be null - if (!sizzleRe.test(err.stack)) throw err + // if not a sizzle or jQuery error, ignore it and let $el be null + if (!(sizzleRe.test(err.stack) || jQueryRe.test(err.stack))) throw err } return $el From fce86e0d56ca6d8eee55585b0c6cb026581ae1df Mon Sep 17 00:00:00 2001 From: Jennifer Shehane Date: Thu, 10 Oct 2024 12:00:32 -0400 Subject: [PATCH 17/18] update changelog --- cli/CHANGELOG.md | 1 - 1 file changed, 1 deletion(-) diff --git a/cli/CHANGELOG.md b/cli/CHANGELOG.md index f58ebae0ed0e..3269e27caf96 100644 --- a/cli/CHANGELOG.md +++ b/cli/CHANGELOG.md @@ -7,7 +7,6 @@ _Released 12/3/2024 (PENDING)_ - Removed support for Node.js 16 and Node.js 21. Addresses [#29930](https://github.com/cypress-io/cypress/issues/29930). - Prebuilt binaries for Linux are no longer compatible with Linux distributions based on glibc <2.28, for example: Ubuntu 14-18, RHEL 7, CentOS 7, Amazon Linux 2. Addresses [#29601](https://github.com/cypress-io/cypress/issues/29601). -- Cypress's jQuery has been updated to now return the width and height excluding scrollbars. This matches jQuery 3.2.0+ behavior and more closely aligns with the CSS box model. `cy.scrollTo()` will now take these new calculations into account when scrolling and will scroll to a more accurate position. Also calls to`Cypress.$().height()` or `Cypress.$().width()` may return different, more correct values due to this change. Addresses [#29846](https://github.com/cypress-io/cypress/issues/29846). - The undocumented methods `Cypress.backend('firefox:force:gc')` and `Cypress.backend('log:memory:pressure')` were removed. Addresses [#30222](https://github.com/cypress-io/cypress/issues/30222). **Dependency Updates:** From 73174df19f277d17a82aacfab88fe45ecdd5a696 Mon Sep 17 00:00:00 2001 From: Jennifer Shehane Date: Thu, 10 Oct 2024 12:00:45 -0400 Subject: [PATCH 18/18] update focus link to fix it --- packages/driver/src/cy/commands/actions/focus.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/driver/src/cy/commands/actions/focus.ts b/packages/driver/src/cy/commands/actions/focus.ts index e1b64ef86bfb..996b4964fc0a 100644 --- a/packages/driver/src/cy/commands/actions/focus.ts +++ b/packages/driver/src/cy/commands/actions/focus.ts @@ -60,7 +60,7 @@ export default (Commands, Cypress, cy) => { $elements.isElement(options.$el.get(0)) && $elements.isBody(options.$el.get(0)) - // http://www.w3.org/$R/html5/editing.html#specially-focusable + // https://dev.w3.org/html5/spec-LC/editing.html#specially-focusable // ensure there is only 1 dom element in the subject // make sure its allowed to be focusable if (!(isWin || isBody || $dom.isFocusable(options.$el))) {