-
Notifications
You must be signed in to change notification settings - Fork 3.2k
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
chore: Implement cross-domain sibling iframe #16708
chore: Implement cross-domain sibling iframe #16708
Conversation
Thanks for taking the time to open a PR!
|
Test summaryRun details
View run in Cypress Dashboard ➡️ Flakiness
This comment has been generated by cypress-bot as a result of this project's GitHub integration settings. You can manage this integration in this project's settings in the Cypress Dashboard |
end: true, | ||
}) | ||
|
||
Cypress.action('cy:cross:domain:message', 'run:in:domain', fn.toString()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fn
here will have the caveat that it doesn't have access to variables of parent lexical scopes, is this something that will be addressed or is it the plan to keep it that way?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, it will be addressed in future work. This is a bare-minimum version of this command just to get things rolling.
@@ -5498,6 +5498,8 @@ declare namespace Cypress { | |||
message: any | |||
/** Set to false if you want to control the finishing of the command in the log yourself */ | |||
autoEnd: boolean | |||
/** Set to false if you want to control the finishing of the command in the log yourself */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what's the difference b/t this and autoEnd? same comment
i think you can also update this in packages/driver/types/internal-types.d.ts
if you don't want it to be public
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From what I can tell, autoEnd
is redundant and we don't actually use it at all. The only instance of it is here:
cypress/packages/driver/src/cy/commands/debugging.js
Lines 58 to 61 in e0c385e
options._log = Cypress.log({ | |
snapshot: true, | |
autoEnd: false, | |
timeout: 0, |
However, using autoEnd
requires calling log.finish()
:
cypress/packages/driver/src/cypress/log.js
Lines 443 to 451 in e0c385e
finish () { | |
// end our command since our subject | |
// has been resolved at this point | |
// unless its already been 'ended' | |
// or has been specifically told not to auto resolve | |
if (this._shouldAutoEnd()) { | |
return this.snapshot().end() | |
} | |
}, |
But I can't find any instances of calling log.finish()
and the instance from above that uses autoEnd: true
calls log.end()
, which is the imperative way to end the snapshot, indicating it was never the intention to "auto-end" the log for cy.pause()
:
cypress/packages/driver/src/cy/commands/debugging.js
Lines 74 to 76 in e0c385e
if (options.log) { | |
options._log.end() | |
} |
The autoEnd
option can probably be removed entirely, but that's outside the scope of this PR. I added the end
option to the types since it's the one we actually use around the codebase for auto-ending a log. I guess this was the first time it was used in TypeScript though, so we hadn't noticed the omission before.
// eslint-disable-next-line no-console | ||
console.log('Unknown postMessage:', event.data) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the reason to not throw
here is because the AUT could emit a postMessage to top, and we shouldn't fail the test in that case?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is another bare-minimum implementation to get the ball rolling. We're planning more work on this in the future to put more thought into it and flesh it out more.
User facing changelog
N/A - only a partial feature of multidomain
Additional details
Adds a sibling iframe in which to run the cross-domain driver bundle. It's added dynamically when the AUT navigates to a second domain. Much is still hard-coded (domain needs to be localhost:3501), but further work will make it more dynamic.
Also includes a very rudimentary implementation of
cy.switchToDomain
.PR Tasks
cypress-documentation
?type definitions
?cypress.schema.json
?