【发布时间】:2017-11-26 11:29:29
【问题描述】:
我想创建将我重定向到处理程序的扩展:查询, 这是我的代码:
manifest.json
…
"content_security_policy": "default-src * ;script-src 'self' 'unsafe-eval' ;object-src 'self' 'unsafe-eval'"
…
background.html
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<script type="text/javascript" src="background.js"></script>
</head>
<body>
<button id="bttn1" onclick="search()">Search!</button>
</body>
</html>
但是在调试扩展时,我得到了错误:
Content Security Policy: The page’s settings blocked the loading of a
resource at self (“script-src moz-extension://0ab93926-b987-451b-ad1d-
c183360acd8a 'unsafe-eval'”). Source: onclick attribute on BUTTON element.
我该怎么做才能解决这个问题? 我的浏览器是 Firefox Developer Edition 58.0b6 (64-bit)
【问题讨论】:
-
您是否尝试过设置同源标题:developer.mozilla.org/en-US/docs/Web/Security/…。这已经为我解决了类似的问题。