Skip to content

Feat: certain Cypress commands should not be bound to window in order to avoid cross origin issues #31196

Closed
@AtofStryker

Description

@AtofStryker

What would you like?

I would like the following commands to not have a dependency on the window object to circumvent cross origin issues

No reason to need window as these can be returned through the automation client (either BiDi or CDP)

Not possible ( or at least not trivial) This likely can be accomplished with Runtime.evaluate in CDP and script.evaluate in BiDi

Why is this needed?

With the introduction of #30858, the goal was to prevent Cypress from getting into weird states where a command would silently fail and hang the Cypress application when invoked in a cross-origin context when it wasn't expected to be. The goal here was to avoid issues like seen in #30848 where the errors were either non-existent or cryptic. This meant enforcing origin checks additionally on the following commands:

However, since the release of Cypress 14, there have been some reported issues, in particular #31100 where users need to conditionally check the url the AUT (Application Under Test) is on in order to see if two factor authentication is needed. We typically do not recommend conditional testing, but this is an incredibly valid use case. We think the best way to solve this is to make certain commands not reference the window where possible, so we can provide users with the best error context possible while providing consistent commands suite user needs.

Other

No response

Metadata

Metadata

Assignees

Labels

Cypress 15topic: cy.originProblems or enhancements related to cy.origin command

Type

No type

Projects

Status

Generally Available

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions