CSP rules applied differently to SVG in Firefox

陌路散爱 提交于 2019-12-08 07:36:47

问题


I have HTML document with Content Security Policy.

<meta http-equiv="Content-Security-Policy" content="style-src 'self'">

I create SVG element, set style property and append the element to the document.

const el = document.createElementNS('http://www.w3.org/2000/svg', 'svg');

el.style.background = 'green';
document.body.appendChild(el);

In Firefox I get a Content Security Policy error, and the styles are not applied. There is no error in Chrome. There is no error for DIV element in Firefox.

Is this behavior expected or is it an implementation bug?


The demo below should display two green boxes in Chrome. In Firefox the right box would be red.

https://pste.eu/p/gKqO.html

来源:https://stackoverflow.com/questions/51939184/csp-rules-applied-differently-to-svg-in-firefox

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!