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

fix: do not use unload events in Chromium from App Runner #30061

Merged
merged 9 commits into from
Aug 23, 2024

Conversation

cacieprins
Copy link
Contributor

@cacieprins cacieprins commented Aug 19, 2024

Additional details

At the point when the Runner's EventManager adds global event listeners, setup() has yet to be called, so there is not an instance of Cypress to use for the browser family check. To fix, getRunnerConfigFromWindow() is extracted into its own file so it can be imported by both src/runner/index.ts and src/runner/event-manager.ts without causing a circular dependency.

Steps to test

Run a simple test in open mode with the following Cypress config:

module.exports = {
  e2e: {
    setupNodeEvents(on, config) {
      on('before:browser:launch', (_, launchOptions) => {
        launchOptions.args.push('--enable-features=DeprecateUnload')

        return launchOptions
      })
      return config
    },
  },
}

Observe that there are no warnings in the browser console about a disallowed unload event.

This behavior cannot be tested with Cy in Cy tests, as far as I can tell, and there are no unit tests for app, so this fix is currently only manually tested.

How has the user experience changed?

PR Tasks

@cacieprins cacieprins marked this pull request as ready for review August 20, 2024 14:37
@jennifer-shehane jennifer-shehane changed the title Fix: do not use unload events in Chromium from App Runner fix: do not use unload events in Chromium from App Runner Aug 20, 2024
Comment on lines 404 to 405
isBrowserFamily (family) {
return getRunnerConfigFromWindow()?.browser?.family === family
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This function is expecting a string, but it's being passed an object so this won't ever compare correctly.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd waffled too many times between an obj and a string parameter - adding type declaration to parameter will help catch this in the future. addressed in 4af0b99

Copy link

cypress bot commented Aug 21, 2024

cypress    Run #56767

Run Properties:  status check failed Failed #56767  •  git commit 1a4d833797: Merge branch 'develop' into cacie/29880/unload-in-chromium
Project cypress
Branch Review cacie/29880/unload-in-chromium
Run status status check failed Failed #56767
Run duration 36m 13s
Commit git commit 1a4d833797: Merge branch 'develop' into cacie/29880/unload-in-chromium
Committer Jennifer Shehane
View all properties for this run ↗︎

Test results
Tests that failed  Failures 18
Tests that were flaky  Flaky 2
Tests that did not run due to a developer annotating a test with .skip  Pending 10
Tests that did not run due to a failure in a mocha hook  Skipped 0
Tests that passed  Passing 434
View all changes introduced in this branch ↗︎

Warning

Partial Report: The results for the Application Quality reports may be incomplete.

UI Coverage  67.9%
  Untested elements 24  
  Tested elements 55  
Accessibility  96.5%
  Failed rules  0 critical   8 serious   3 moderate   0 minor
  Failed elements 219  

Tests for review

Failed  cypress\e2e\runner\reporter-ct-webpack.errors.cy.ts • 18 failed tests • app-e2e

View Output

Test Artifacts
Webpack - errors ui > assertion failures Test Replay Screenshots
Webpack - errors ui > assertion failures - no preferred IDE Test Replay Screenshots
Webpack - errors ui > exception failures Test Replay Screenshots
Webpack - errors ui > hooks Test Replay Screenshots
Webpack - errors ui > commands Test Replay Screenshots
Webpack - errors ui > cy.then Test Replay Screenshots
Webpack - errors ui > cy.should Test Replay Screenshots
Webpack - errors ui > cy.each Test Replay Screenshots
Webpack - errors ui > cy.spread Test Replay Screenshots
Webpack - errors ui > cy.within Test Replay Screenshots
The first 10 failed tests are shown, see all 18 tests in Cypress Cloud.
Failed  cypress\e2e\runner\runner.ui.cy.ts • 0 failed tests • app-e2e

View Output

Test Artifacts
Failed  cypress\e2e\sidebar_navigation.cy.ts • 0 failed tests • app-e2e

View Output

Test Artifacts
Failed  cypress\e2e\runner\reporter-ct-vite.errors.cy.ts • 0 failed tests • app-e2e

View Output

Test Artifacts
Failed  cypress\e2e\settings.cy.ts • 0 failed tests • app-e2e

View Output

Test Artifacts

The first 5 failed specs are shown, see all 49 specs in Cypress Cloud.

Flakiness  cypress\e2e\runs.cy.ts • 1 flaky test • app-e2e

View Output

Test Artifacts
... > displays a list of recorded runs if a run has been recorded Test Replay Screenshots
Flakiness  cypress\e2e\scaffold-component-testing.cy.ts • 1 flaky test • launchpad-e2e

View Output

Test Artifacts
scaffolding component testing > react-vite-ts-unconfigured > detects react dependency even if `package.json` is not declared in `exports` Test Replay Screenshots

@@ -89,7 +89,7 @@ index 773ad95..84ca2f6 100644
+ // IE/Edge sometimes throw a "Permission denied" error when strict-comparing
+ // two documents; shallow comparisons work.
+ // eslint-disable-next-line eqeqeq
+ if ( preferredDoc != document &&
+ if ( docElem.msMatchesSelector && preferredDoc != document &&
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this still relevant? Mostly curious how you tested this.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is basically a cherry-picked patch from jQuery 3.7.1. when manually testing this in chrome, I was still receiving unload errors coming from jquery without this change

Copy link
Member

@jennifer-shehane jennifer-shehane left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not seeing the unload warning displaying from our own code anymore. I still see one coming from jQuery but will have to test with the built binary I guess since that's patched.

@jennifer-shehane jennifer-shehane removed the request for review from mschile August 22, 2024 16:35
@cacieprins cacieprins merged commit ebbf7b1 into develop Aug 23, 2024
88 of 95 checks passed
@cacieprins cacieprins deleted the cacie/29880/unload-in-chromium branch August 23, 2024 18:39
@cypress-bot
Copy link
Contributor

cypress-bot bot commented Aug 27, 2024

Released in 13.14.0.

This comment thread has been locked. If you are still experiencing this issue after upgrading to
Cypress v13.14.0, please open a new issue.

@cypress-bot cypress-bot bot locked as resolved and limited conversation to collaborators Aug 27, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Cypress 13.13.1, Chrome] - unload is not allowed
3 participants