-
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
fix: XHR event listener AUT redirect bug #15995
Conversation
Thanks for taking the time to open a PR!
|
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.
awesome, some minor nits
…io/cypress into tgriesser/fix/3975-redirect-bug * 'tgriesser/fix/3975-redirect-bug' of github.com:cypress-io/cypress: fix(@cypress/webpack-batteries-included-preprocessor): Ensure typescript options are set if typescript path is provided (#15991) chore: release @cypress/vite-dev-server-v1.2.2 fix: conditionally require vue and update alias if installed (#16000) docs: remove cssFiles from the vue documentation (#15971) chore: release @cypress/webpack-dev-server-v1.1.3 chore: release @cypress/vite-dev-server-v1.2.1 chore: release @cypress/react-v5.3.3 fix: remove lazy-compile-webpack-plugin (#15964)
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 |
@tgriesser I know this seems unrelated, but I'm wondering if this would also fix #1244 as a number of the users in that thread had a situation of redirecting to a __/ url, but were shown this illegal operation error as a result. There's a repro example here: #1244 (comment) |
@jennifer-shehane yeah, looks very likely that's related (added it to the list of issues in the PR description). I'm guessing that the behavior when the incorrect redirect takes place could manifest in different ways depending on the situation. Basically any issue that involves a location change within the same call stack as an event listener that's also observed by Cypress is a likely candidate. I'd guess the |
@@ -421,6 +422,8 @@ const create = (options = {}) => { | |||
const { send, open, abort } = XHR.prototype | |||
const srh = XHR.prototype.setRequestHeader | |||
|
|||
const bridgeContentWindowListener = makeContentWindowListener('cypressXhrBridge', contentWindow) |
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.
@brian-mann This is now only creating once per window load, since it's outside the XHR patching
* develop: chore: Remove extra renovate.json file (#16385) Do not print 'uploading' stdout when --quiet mode is passed (#16271) fix(deps): update dependency color-string to version 1.5.5 🌟 (#16362) fix(deps): update dependency cypress-real-events to version 1.4.0 🌟 (#16363) tests: use the proper keys for selecting framework fix: Prevent Firefox from opening custom search when pressing / (#16372) fix: vueCli and webpack key vue@2 fix when guessing tests: update snapshots fix: add return config for vueCli and vueWebpack fix: add return config for vitejs templates chore: release @cypress/vue-v2.2.2 chore: release @cypress/react-v5.5.0 fix: remove all of rollup, not supported anymore fix: typo in the final message (run vs run-ct)
* develop: (28 commits) fix: XHR event listener AUT redirect bug (#15995) chore: fix typo (#16345) chore(design-system): Added missing exports and index.ts (#16351) chore: Remove extra renovate.json file (#16385) Do not print 'uploading' stdout when --quiet mode is passed (#16271) fix(deps): update dependency color-string to version 1.5.5 🌟 (#16362) fix(deps): update dependency cypress-real-events to version 1.4.0 🌟 (#16363) tests: use the proper keys for selecting framework fix: Prevent Firefox from opening custom search when pressing / (#16372) fix(socket): update serialization for circular binary socket messages (#16311) fix: vueCli and webpack key vue@2 fix when guessing tests: update snapshots fix: add return config for vueCli and vueWebpack chore(deps): update dependency classnames to version 2.3.1 🌟 (#8337) fix: add return config for vitejs templates chore: release @cypress/vue-v2.2.2 chore: release @cypress/react-v5.5.0 fix: remove all of rollup, not supported anymore fix: typo in the final message (run vs run-ct) fix: use close event when asking the browser for its version (#16312) ...
fix(deps): update dependency cypress-real-events to version 1.4.0 🌟 (#16363) Co-authored-by: Renovate Bot <[email protected]> fix: typo in the final message (run vs run-ct) fix: remove all of rollup, not supported anymore fix: add return config for vitejs templates fix: add return config for vueCli and vueWebpack tests: update snapshots fix: vueCli and webpack key vue@2 fix when guessing tests: use the proper keys for selecting framework chore: release @cypress/react-v5.5.0 [skip ci] chore: release @cypress/vue-v2.2.2 [skip ci] fix(deps): update dependency color-string to version 1.5.5 🌟 (#16362) Co-authored-by: Renovate Bot <[email protected]> Co-authored-by: Jennifer Shehane <[email protected]> Do not print 'uploading' stdout when --quiet mode is passed (#16271) chore: Remove extra renovate.json file (#16385) chore(design-system): Added missing exports and index.ts (#16351) chore: fix typo (#16345) Co-authored-by: Jennifer Shehane <[email protected]> fix: XHR event listener AUT redirect bug (#15995) Fixes incorrect redirect when location.href is set to a relative path within the call stack of an XHR event handler, which set the user's AUT to /__/ rather than the correct path Linting after merge
Great work guys. Thanks. Works in my limited testing so far. |
Released in This comment thread has been locked. If you are still experiencing this issue after upgrading to |
_/
in url #3975__
within directory path whenexperimentalSourceRewriting
is on #7439May also address #15490, #9261, #7871
User facing changelog
Fix for incorrect redirect when
location.href
is set to a relative path within the call stack of an XHR event handler, which incorrectly sets the user's AUT to/__/
rather than the correct path.Additionally, adds code to detect when a form submit target is set toEdit: Split out to #16394_top
and sets to''
to avoid redirecting the parent frame.Additional details
This was caused by the changes in this Chromium commit: https://bugs.chromium.org/p/chromium/issues/detail?id=849236 (big thanks to @jennifer-shehane doing the initial range narrowing on that one) which changed the mechanics of how the window is bound around events, which I believe had an inadvertent side affect that affects
location.href
assignment.This ticket: https://bugs.chromium.org/p/chromium/issues/detail?id=1195471 seems like it will possibly address the issue, but this behavior is consistent in both Firefox & Chrome, so it's likely worth fixing on our end for now.
By wrapping the handlers in a function defined in the AUT window (@brian-mann had the idea for that one), the event handler is correctly associated with the AUT, and it doesn't impact the
location.href
assignment.How has the user experience changed?
User's AUT is no-longer redirected incorrectly to
/__/path
but instead to the correct relative window location path.PR Tasks
cypress-documentation
?type definitions
?cypress.schema.json
?