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
5.5.0 Regression: Cannot load script with integrity attribute #8983
Comments
Same problem after upgrading from |
Yes, I can recreate this from the provided repo https://github.com/Tanuel/cypress-test-tiny. This was introduced in 5.5.0. This was introduced in this PR: #8827. I git bisected to this commit where it started failing: 19fdf43 5.4.05.5.0 |
I faced a similar problem. We add the following line to cypress.json: {
"experimentalNetworkStubbing": true,
} We add the following code to cypress/support/index.js: before(() => {
cy.server();
cy.route2('**/recaptcha/api.js', {fixture: 'google/recaptcha/api.js'});
}); Add the following code to cypress/fixtures/google/recaptcha/api.js.txt: /* PLEASE DO NOT COPY OR PASTE THIS CODE. */
(function () {
var w = window, C = '___grecaptcha_cfg', cfg = w[C] = w[C] || {}, N = 'grecaptcha';
var gr = w[N] = w[N] || {};
gr.ready = gr.ready || function (f) {
(cfg['fns'] = cfg['fns'] || []);
};
w['__recaptcha_api'] = 'https://www.google.com/recaptcha/api2/';
(cfg['render'] = cfg['render'] || []).push('onload');
w['__google_recaptcha_client'] = true;
var d = document, po = d.createElement('script');
po.type = 'text/javascript';
po.async = true;
po.src = 'https://www.gstatic.com/recaptcha/releases/T9w1ROdplctW2nVKvNJYXH8o/recaptcha__en.js';
po.crossOrigin = 'anonymous';
// po.integrity = 'sha384-3QFmGa9WBVUnmTTGehi+1Uin1pmBuS/I5R1Ce52Aiiuviet65v+bH12eR4+kUUcx';
var e = d.querySelector('script[nonce]'), n = e && (e['nonce'] || e.getAttribute('nonce'));
if(n) {
po.setAttribute('nonce', n);
}
var s = d.getElementsByTagName('script')[0];
s.parentNode.insertBefore(po, s);
})(); Note that in You can now work with `integrity' in Cypress 5.5.0. |
The code for this is done in cypress-io/cypress#9018, but has yet to be released. |
Released in This comment thread has been locked. If you are still experiencing this issue after upgrading to |
1 similar comment
Released in This comment thread has been locked. If you are still experiencing this issue after upgrading to |
Current behavior
When trying to load google recaptcha, it will load another script, but the integrity check will fail. This error happens since upgrading to 5.5.0

Desired behavior
captcha can be loaded correctly
Test code to reproduce
https://github.com/Tanuel/cypress-test-tiny
npm install
npm run test
Versions
Error occured on: 5.5.0
Last working Version: 5.4.0
Let me know if you need more information
The text was updated successfully, but these errors were encountered: