Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

iFrame elements that focus, when calling .type() are actually blurred (when Test Runner is not focused) #8111

Closed
martynchamberlin opened this issue Jul 28, 2020 · 3 comments · Fixed by #8112 · May be fixed by Omrisnyk/npm-lockfiles#145 or Omrisnyk/npm-lockfiles#164
Assignees
Labels
pkg/driver This is due to an issue in the packages/driver directory topic: cy.type ⌨️ type: bug

Comments

@martynchamberlin
Copy link

martynchamberlin commented Jul 28, 2020

Current behavior:

Currently if you load a page that has an iFrame, and that iFrame has an input that you programmatically focus, attempting to focus via Cypress testing causes the input to blur instead.

Desired behavior:

When focusing on an input that is already focused, a blur should not occur; it should remain focused.

Test code to reproduce

cypress-io/cypress-test-tiny#61

Versions

macOS Catalina, version 10.15.5
Chrome version 84.0.4147.89
Cypress package version: 4.10.0
Cypress binary version: 4.10.0

@jennifer-shehane
Copy link
Member

I can recreate this with the following code - have to defocus the window in order for the test to fail.

spec.js

it('fails if you focus off the Cypress window', () => {
  cy.visit('index.html')
  cy.get('iframe')
    .its('0.contentDocument.body').should('not.be.empty')
    .then(cy.wrap)
    .find('#input')
    .type(42)
    .should('have.value', 42);
});

index.html

<html>
<body>
  <iframe src="iframe.html">
</body>
</html>

iframe.html

<html>
<body>
  <input id="input" />
  <script>
    document.querySelector('#input').focus();
  </script>
</body>
</html>

Screen Shot 2020-07-29 at 2 38 27 PM

@cypress-bot cypress-bot bot added the stage: needs review The PR code is done & tested, needs review label Jul 29, 2020
@jennifer-shehane jennifer-shehane changed the title iFrame focus is buggy iFrame elements that focus, when calling .type() are actually blurred (when Test Runner is not focused) Jul 29, 2020
@jennifer-shehane jennifer-shehane added pkg/driver This is due to an issue in the packages/driver directory internal-priority labels Jul 29, 2020
@jennifer-shehane
Copy link
Member

The code for this is done in cypress-io/cypress#8112, but has yet to be released.
We'll update this issue and reference the changelog when it's released.

@jennifer-shehane jennifer-shehane added stage: pending release and removed stage: needs review The PR code is done & tested, needs review labels Aug 3, 2020
@cypress-bot
Copy link
Contributor

cypress-bot bot commented Aug 3, 2020

Released in 4.12.0.

This comment thread has been locked. If you are still experiencing this issue after upgrading to
Cypress v4.12.0, please open a new issue.

@cypress-bot cypress-bot bot locked as resolved and limited conversation to collaborators Aug 3, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
pkg/driver This is due to an issue in the packages/driver directory topic: cy.type ⌨️ type: bug
Projects
None yet
2 participants