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

modifyObstructiveCode incorrectly matches the word 'stop' #5330

Closed
mikey0000 opened this issue Oct 10, 2019 · 6 comments
Closed

modifyObstructiveCode incorrectly matches the word 'stop' #5330

mikey0000 opened this issue Oct 10, 2019 · 6 comments

Comments

@mikey0000
Copy link

Current behavior:

During test run, code fails with sself not defined.

Desired behavior:

functionality of code should not be replaced
isChildTrainPlatform = stop => stop.route_type === STOP_TYPE.TRAINSTOP && stop.location_type === 0;
should not turn into
isChildTrainPlatform = stop => stop.route_type === STOP_TYPE.TRAINSTOP && sself.location_type === 0;

Steps to reproduce: (app code and test code)

code specifically with this line

return stop.route_type===WEBPACK_IMPORTED_MODULE_10__types_stop_types["a" /* default */].TRAINSTOP&&stop.location_type===0;

Versions

Cypress 3.4.1, Chrome 77

@kuceb
Copy link
Contributor

kuceb commented Oct 10, 2019

paging @flotwig, he's working with our app isolation logic

@cypress-bot cypress-bot bot added the stage: investigating Someone from Cypress is looking into this label Oct 10, 2019
@flotwig
Copy link
Contributor

flotwig commented Oct 11, 2019

Your code is getting mangled by these regexes in the proxy which blindly replace top with self:

const topOrParentEqualityBeforeRe = /((?:window|self)(?:\.|\[['"](?:top|self)['"]\])?\s*[!=]==?\s*(?:(?:window|self)(?:\.|\[['"]))?)(top|parent)(?![\w])/g
const topOrParentEqualityAfterRe = /(top|parent)((?:["']\])?\s*[!=]==?\s*(?:window|self))/g
const topOrParentLocationOrFramesRe = /([^\da-zA-Z\(\)])?(top|parent)([.])(location|frames)/g
const jiraTopWindowGetterRe = /(!function\s*\((\w{1})\)\s*{\s*return\s*\w{1}\s*(?:={2,})\s*\w{1}\.parent)(\s*}\(\w{1}\))/g

I am working on a PR that parses and rewrites the Javascript instead of using regexes, which I'll make sure fixes this problem: #5273

@mikey0000
Copy link
Author

Yeah, I managed to work that out, awesome! Look forward to the fix!

@brian-mann
Copy link
Member

s + top === stop ;-P

@kjellski
Copy link

kjellski commented Oct 24, 2019

This is exactly what happened to us as well and we would have reported another bug here as well. We were just accessing a variable like this:

... purchasedStop.location ... which ended up breaking our application code like this: ... purchasedSself.location .... Isn't thisa bug and unintended behaviour?
I think it would be a good first step to make sure that the string is not part of other symbols, like checking that it only occures without valid characters before or after that :)

@cypress-bot cypress-bot bot added stage: work in progress and removed stage: investigating Someone from Cypress is looking into this labels Oct 24, 2019
@jennifer-shehane
Copy link
Member

Closing as resolved.

If you're experiencing a bug similar to this in Cypress, please open a new issue with a fully reproducible example that we can run. There may be a specific edge case with the issue that we need more detail to fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants