code-coverage icon indicating copy to clipboard operation
code-coverage copied to clipboard

fix: Fix error when testing cross-origin code

Open Nojay-Games opened this issue 1 year ago • 17 comments

  • Closes https://github.com/cypress-io/code-coverage/issues/782

When testing cross-origin websites with cy.origin(), the following error gets thrown: DOMException: Blocked a frame with origin "http://localhost:3000" from accessing a cross-origin frame. This occurs when accessing win.__coverage__ in the code. Since you don't control cross-origin code and it therefore doesn't need code coverage, you can simply ignore the code coverage if accessing win.__coverage__ throws an error.

Nojay-Games avatar Aug 19 '23 10:08 Nojay-Games

CLA assistant check
All committers have signed the CLA.

CLAassistant avatar Aug 19 '23 10:08 CLAassistant

cypress-app-bot avatar Aug 19 '23 10:08 cypress-app-bot

@Nojay-Games Thanks for the contribution! Can you write a test to cover the logic for the fix you wrote?

jennifer-shehane avatar Aug 22 '23 19:08 jennifer-shehane

That fix is what I need, there is no way to merge it into production so I can update the dependency solve the conflict I have with the library when doing my tests? thanks!

JRSalica avatar Mar 04 '24 23:03 JRSalica

@Nojay-Games Will you have time to write a test for this? If the PR is incomplete, we'll have to close this.

jennifer-shehane avatar Mar 07 '24 14:03 jennifer-shehane

@jennifer-shehane logs are expired and i cannot understand whats wrong in tests, is ok for u to rerun the merge so we can see whats going wrong?

alecmestroni avatar May 06 '24 09:05 alecmestroni

@alecmestroni I pushed an empty commit. I believe the original ask was to write a test case that tests the added behavior here. Since there's nothing confirming this fixes the behavior or prevents regressions from being introduced.

jennifer-shehane avatar May 06 '24 14:05 jennifer-shehane

@alecmestroni I pushed an empty commit. I believe the original ask was to write a test case that tests the added behavior here. Since there's nothing confirming this fixes the behavior or prevents regressions from being introduced.

@jennifer-shehane Sadly its not an error during the test but its a permission bug related to the account used

Run snyk test --all-projects --detection-depth=4 --exclude=docker,Dockerfile,test-apps --severity-threshold=critical
`snyk` requires an authenticated account. Please run `snyk auth` and try again.
Error: Process completed with exit code 2.

alecmestroni avatar May 08 '24 12:05 alecmestroni

@alecmestroni Yah, the snyk failure can be ignored. It doesn't run properly for contributors.

jennifer-shehane avatar May 08 '24 14:05 jennifer-shehane

@alecmestroni Yah, the snyk failure can be ignored. It doesn't run properly for contributors.

@jennifer-shehane so tests are passing and merge can be applied

alecmestroni avatar May 13 '24 10:05 alecmestroni

@alecmestroni There is no test for the change in behavior here verifying the behavior at all.

jennifer-shehane avatar May 20 '24 13:05 jennifer-shehane

@jennifer-shehane test added https://github.com/Nojay-Games/code-coverage/pull/1

alecmestroni avatar May 27 '24 07:05 alecmestroni

@jennifer-shehane any news?

alecmestroni avatar Jun 18 '24 15:06 alecmestroni

@alecmestroni - @mschile is assigned to review this is he finds some extra time. Thanks for your patience.

jennifer-shehane avatar Jun 19 '24 17:06 jennifer-shehane

@jennifer-shehane he has done the changing. please approve them

alecmestroni avatar Jun 24 '24 07:06 alecmestroni

@Nojay-Games thank you for this one, I just found this problem and it's super annyoing! @alecmestroni and thank you for the tests!

@jennifer-shehane could you push this?

lhimstedt avatar Jul 02 '24 15:07 lhimstedt

@alecmestroni and @lhimstedt, the tests are failing, so I still need to investigate that before this PR can be merged.

mschile avatar Jul 02 '24 16:07 mschile

:tada: This PR is included in version 3.12.40 :tada:

The release is available on:

Your semantic-release bot :package::rocket:

cypress-app-bot avatar Jul 03 '24 19:07 cypress-app-bot