由于 Content-Security-Policy 问题,Safari 无法从 blob 创建 Worker

Safari unable to create Worker from blob due to Content-Security-Policy issue

我正在尝试在我的网页上创建 Worker:

const url = URL.createObjectURL(blob);
const worker = new Worker(url);

并且 Safari 在控制台中显示以下错误:

Refused to load blob:https://my.address.com/5fa7b5e6-cb10-4b7c-967b-e95cae58cd71 because it appears in neither the child-src directive nor the default-src directive of the Content Security Policy.

我在页面上有以下 Content-Security-Policy 标记:

<meta http-equiv="Content-Security-Policy" content="worker-src 'self' blob:">

但 Safari 似乎忽略了它。我打赌我尝试了所有可能的 SCP 指令组合(例如 worker-src、object-src、script-src、child-src 等)和来源(*、blob:、'unsafe-eval', 'unsafe-inline', 等等)

感谢任何想法!

备注:

  1. 当我通过 http 在 Safari 中打开我的网页时,创建的 Worker 没有任何错误。问题是通过 https 打开时。
  2. Worker 在 Chrome、Firefox、Edge
  3. 中工作正常
  4. 我在页面上只有一个 Content-Security-Policy 标签
  5. 在 Safari 中检查 Http 响应 Headers 时它们看起来不错

Safari does not support worker-src 指令(已测试 v 12)并忽略它,检查控制台是否有 Unrecognized Content Security Policy directive 'worker-src' 消息。

worker-src 的后备链是:child-src -> script-src -> default-src,因此要支持 Safari,你必须使用 child-srcworker-src 相同的规则。 child-src blob: works in Safari(按'blob:'按钮查看)。

消息because it appears in neither the child-src directive nor the default-src directive of the Content Security Policy不清楚。您是否已经 child-src / default-src 政策中包含一些规则?
因为 <meta http-equiv="Content-Security-Policy" content="worker-src 'self' blob:"> 只是被 Safari 忽略,不应该阻止工作人员。