赛普拉斯和Axe似乎忽略了内容安全政策

时间:2020-10-11 16:13:56

标签: accessibility cypress content-security-policy axe

我正在使用Cypress和Ax来测试我的网站的可访问性,但它似乎忽略了我使用meta标记设置的内容安全政策(CSP)。

运行测试时,我在cy.checkA11y()上得到以下信息:

EvalError: Refused to evaluate a string as JavaScript because 'unsafe-eval' is not an allowed source of script in the following Content Security Policy directive: "script-src 'self' 'unsafe-inline'"

但是目标网页(andrewhick.com)的源代码包含以下内容:

<meta http-equiv="Content-Security-Policy" content="default-src 'none'; img-src 'self'; script-src 'self' 'unsafe-inline' 'unsafe-eval'; style-src 'self' 'unsafe-inline'; ">

我尝试搜索该错误,但找不到其他人遇到类似问题。

我还考虑了问题是否在缓存中,但是重新打开赛普拉斯(我认为应该清除缓存)并没有帮助,此外,Cypress clears the cache automatically

这可能是因为CSP是在元标记中定义的,而不是在服务器上定义的,但是我不相信我的托管公司允许访问服务器。

The failing test is stored here

该问题是断断续续的,并且套件确实可以工作一次,这也无济于事。我尝试添加,删除和重新添加“不安全评估”,但是测试结果与CSP是否已更新不符。而且,尽管我对Javascript不确定,但该测试似乎没有任何明显的语法错误。有人可以帮忙吗?

0 个答案:

没有答案