cypress-io / cypress

Fast, easy and reliable testing for anything that runs in a browser.

Home Page:https://cypress.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Opt out of 'unload' event deprecation

cacieprins opened this issue · comments

What would you like?

Chrome is deprecating the unload event. (see also: #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, where AUT_URL is the url that will be loaded in the AUT iframe
  • The AUT iframe has an allow="unload" property
  • Cypress' proxy sets Permissions-Policy: unload=self on AUT responses
  • Cypress' proxy modifies iframes in the AUT to include the allow="unload" property