Subtle Crypto not available in Firefox
See original GitHub issueCurrent behavior
Subtle Crypto (window.crypto.subtle
) is undefined in Firefox 84.
First noticed my CI tests in Firefox were failing, then reproduced locally by updating my local Firefox (and Cypress) to the latest.
Desired behavior
Subtle crypto to be available in Firefox Cypress tests.
Test code to reproduce
it('Subtle crypto unavailable', function () {
cy.visit('./cypress/integration/index.html').then(function (win) {
expect(win.crypto).to.have.property('subtle')
})
})
Versions
Failing CI Versions
Firefox 84 Linux Ubuntu - 18.04 Cypress - 4.12.1
Last known working CI Versions
Firefox 83 Linux Ubuntu - 18.04 Cypress - 4.12.1
Failing Local Versions
Firefox 84 Mac OS X - 10.14.6 Cypress - 6.2.1
Last known working local version
Firefox 78 Mac OS X - 10.14.6 Cypress - 6.2.1
Note
Subtle crypto is supposed to be available at localhost, as it’s considered a secure context.
From MDN’s docs on secure contexts:
Locally-delivered resources such as those with http://127.0.0.1 URLs, http://localhost and http://*.localhost URLs (e.g. http://dev.whatever.localhost/), and file:// URLs are also considered to have been delivered securely.
But it also has this note, which seems to be the culprit for the breaking change in Firefox 84, but I’m not really sure why:
Note: Firefox 84 and later support http://localhost and http://*.localhost URLs as trustworthy origins (earlier versions did not, because localhost was not guaranteed to map to a local/loopback address).
I have access to subtle crypto in Firefox 84 when serving my site from a webpack dev server at localhost, just not within Cypress for some reason.
I figure it has something to do with Cypress’ browser environment being incompatible with Firefox 84:
Cypress launches the browser in a way that’s different from a regular browser environment. But it launches in a way that we believe makes testing more reliable and accessible.
Issue Analytics
- State:
- Created 3 years ago
- Reactions:2
- Comments:8 (1 by maintainers)
I’m also having this issue with Firefox 100, Ubuntu 20.04, Cypress 10.0.2 on localhost.
Both Electron and Chrome work normally. I can access subtle on Firefox from localhost outside of Cypress.
I tried to polyfill using @peculiar/webcrypto but wasn’t able to get it working.
@j-berman We have docker images where some different browser versions are provided, but we don’t have a ‘matrix’ of browser versions to run against. https://github.com/cypress-io/cypress-docker-images
We proxy a lot of requests through Cypress, so yeah, I imagine there’s something we’re not taking into account in this situation.
Reproducible example
index.html
spec.js
Firefox 81
Firefox 84