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

Emit window:pageshow and window:pagehide events #29523

Open
cacieprins opened this issue May 15, 2024 · 0 comments
Open

Emit window:pageshow and window:pagehide events #29523

cacieprins opened this issue May 15, 2024 · 0 comments

Comments

@cacieprins
Copy link
Contributor

cacieprins commented May 15, 2024

What would you like?

Cypress should emit window:pageshow and window:pagehide lifecycle events for the AUT.

Why is this needed?

Chrome is progressively deprecating / preventing window 'unload' events and event listeners (see: https://developer.chrome.com/docs/web-platform/deprecating-unload ). `

In preparation for unload being deprecated, Cypress is migrating to pagehide as a proxy for the unload event. With #29525, the window:unload event will be emitted when pagehide is triggered rather than when unload is triggered. As a next step in deprecating Cypress' window:unload, and to keep our API aligned with standards, we need to emit window:pagehide.

There are potential issues with how Cypress determines pageload with the load event. If a page is loaded from the back/forward cache, the load event may not fire (definitively for the top frame; unknown if this is applied to child frames). We should emit window:pageshow in addition to window:load, to provide the additional option to users and keep the load/unload path balanced.

See flowchart: https://developer.chrome.com/docs/web-platform/page-lifecycle-api/image/page-lifecycle-api-state.svg

Other

No response

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

1 participant