cypress
cypress copied to clipboard
Opt out of 'unload' event deprecation
What would you like?
Chrome is deprecating the unload event. (see also: https://github.com/cypress-io/cypress/issues/29241)
Why is this needed?
Cypress uses the unload
event during AUT navigation, and emits a window:unload
event that can be hooked into from tests. With unload
forcibly deprecated, Cypress no longer works as expected, and the window:unload
event will not fire.
Other
Background
To prevent Cypress runs from failing while we work to remove or find alternatives to using unload
, we can leverage a permissions policy option added to Chrome 117 to preserve usage. This is not a permanent fix, and this permissions policy option will be removed in a future version of Chrome. This just gives us breathing room.
Potential complication: Documentation only provides a solution for single-layer cross-domain iframes. We will probably be able to make this work when the AUT is a cross-domain iframe with the App, but it is unlikely that we will be able to force unload events to be enabled when the AUT iframe includes a sub-iframe that is cross-domain with the AUT iframe.
Acceptance Criteria
- Top level Cypress URL returns with a
Permissions-Policy: unload=(self,"${AUT_URL}")
header, whereAUT_URL
is the url that will be loaded in the AUTiframe
- The AUT
iframe
has anallow="unload"
property - Cypress' proxy sets
Permissions-Policy: unload=self
on AUT responses - Cypress' proxy modifies
iframe
s in the AUT to include theallow="unload"
property