From 375af46497f0c961dcf575a0476e1a37cd25ae53 Mon Sep 17 00:00:00 2001 From: Ryan Manuel Date: Wed, 20 Sep 2023 12:25:54 -0500 Subject: [PATCH 1/4] fix: issue with font flooding --- .../driver/cypress/e2e/dom/visibility.cy.ts | 25 +++++++++++- packages/driver/src/cy/actionability.ts | 40 ++++++++++++++----- .../src/dom/elements/complexElements.ts | 6 +++ 3 files changed, 59 insertions(+), 12 deletions(-) diff --git a/packages/driver/cypress/e2e/dom/visibility.cy.ts b/packages/driver/cypress/e2e/dom/visibility.cy.ts index 903be554218a..adaa51f99b81 100644 --- a/packages/driver/cypress/e2e/dom/visibility.cy.ts +++ b/packages/driver/cypress/e2e/dom/visibility.cy.ts @@ -53,7 +53,7 @@ describe('src/cypress/dom/visibility', () => { expect(fn()).to.be.true }) - it('returns false window and body > window height', () => { + it('returns false if window and body < window height', () => { cy.$$('body').html('
foo
') const win = cy.state('window') @@ -65,6 +65,29 @@ describe('src/cypress/dom/visibility', () => { expect(fn()).to.be.false }) + it('returns true if document element and body > window height', function () { + this.add('
') + const documentElement = Cypress.dom.wrap(cy.state('document').documentElement) + + const fn = () => { + return dom.isScrollable(documentElement) + } + + expect(fn()).to.be.true + }) + + it('returns false if document element and body < window height', () => { + cy.$$('body').html('
foo
') + + const documentElement = Cypress.dom.wrap(cy.state('document').documentElement) + + const fn = () => { + return dom.isScrollable(documentElement) + } + + expect(fn()).to.be.false + }) + it('returns false el is not scrollable', function () { const noScroll = this.add(`\
diff --git a/packages/driver/src/cy/actionability.ts b/packages/driver/src/cy/actionability.ts index fa98fcf00f47..258833f68c3b 100644 --- a/packages/driver/src/cy/actionability.ts +++ b/packages/driver/src/cy/actionability.ts @@ -460,24 +460,43 @@ const verify = function (cy, $el, config, options, callbacks: VerifyCallbacks) { // make scrolling occur instantly. we do this by adding a style tag // and then removing it after we finish scrolling // https://github.com/cypress-io/cypress/issues/3200 - const addScrollBehaviorFix = () => { - let style + const addScrollBehaviorFix = (element: JQuery) => { + const affectedParents: Map = new Map() try { - const doc = $el.get(0).ownerDocument + let parent: JQuery | null = element - style = doc.createElement('style') - style.innerHTML = '* { scroll-behavior: inherit !important; }' - // there's guaranteed to be a