-
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
Rewrite JS/HTML using AST-based approach #5273
Conversation
Test summaryRun details
View run in Cypress Dashboard ➡️ 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 |
@flotwig another important note - if we apply these rules to the entire proxy then we will be rewriting virtually all JS files - which will break We'll need to strip those too. https://developer.mozilla.org/en-US/docs/Web/Security/Subresource_Integrity |
@flotwig another note - we should capture when |
This uses hyntax to do streaming parsing of HTML, so this should be easy to add. It will be the first transform that we do directly to the HTML. |
Will this also address this issue? #3994 |
@jennifer-shehane it will enable us to build a workaround for that issue, I believe, by making it so we can rewrite the use of |
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.
made suggested changes as commit
* Document experimentalSourceRewriting For cypress-io/cypress#5273 * Update history table
Early testing looking very promising on #4576. |
@drumbeg This fix is available starting in {
"experimentalSourceRewriting": true
} The fix is experimental, so there may be some situations where the this is not fixed. If you're still this issue while setting the |
_/
in url #3975 - relative location.href setter does not work as expected__
into url #3994 - relative location.replace does not work as expectedUser facing changelog
Experimental fixes
To access these fixes, enable experimental source rewriting with the config value
experimentalSourceRewriting: true
:window.top
andwindow.parent
could cause the AUT to break out of the Cypress iframe. Fixes Replace x.top, x.parent accessors with correct reference (at runtime) #5271 and Rewrite 3rd party JS code to enforce that parent + top references are always correct #1467.window.frames
,window.parent.frames
, and otherframes
accesses could point to the wrong reference after being proxied through Cypress. Fixes Can't use window.parent.frames in my iframes #2664.integrity
attribute for sub-resource integrity (SRI) would not load after being proxied through Cypress. Fixes Cypress cannot test sites that implement SRI #2393.location
orlocation.href
to a relative href, or usinglocation.replace
orlocation.assign
with a relative href, could result in the wrong URL being navigated to. Fixes Incorrect redirect to malformed url within AUT - adding_/
in url #3975 and window.location.replace not working - inserts__
into url #3994.Additional details
experimentalSourceRewriting
:may possibly conflict with Error Improvements #6724 go-to-line functionalityerror improvements only consume sourcemaps for specfiles, not AUT JS (yet) -so we can get away with simply inlining sourcemaps for nowintegrity
attributes in<script type="text/javascript">
tags will be rewritten tocypress:stripped-integrity
attributes -<script type="text/javascript" integrity="foo">
becomes<script type="text/javascript" cypress:stripped-integrity="foo">
process.exit
withworker_threads
active electron/electron#23366Note: This PR is huge because it does not replace the regex-based rewriting (yet), so there are some duplicate code paths and tests.
Checklist before removing "experimental" status: #7297
How has the user experience changed?
More user sites will work OOTB with Cypress 🎉
PR Tasks
cypress-documentation
? Document experimentalSourceRewriting cypress-documentation#2787type definitions
?cypress.schema.json
?