【发布时间】:2020-11-05 13:29:42
【问题描述】:
我正在尝试在我的 Chrome 插件中加载一个 wasm 模块。 Chrome 抱怨 emscripten 生成的 wasm 模块中有以下功能。它在以下 js 上跳闸
Uncaught 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' blob: filesystem:".
function createNamedFunction(name, body) {
name = makeLegalFunctionName(name);
/*jshint evil:true*/
return new Function(
"body",
"return function " + name + "() {\n" +
" \"use strict\";" +
" return body.apply(this, arguments);\n" +
"};\n"
)(body);
}
我正在将脚本加载到background.html 文件中,以便它可以作为模块运行。 .
<script type="module" src="../js/background.js"></script>
<script type="module" src="../js/AudioWorkletProcessor.js"></script>
<script type="module" src="../js/kernel.wasmmodule.js"></script>
人们如何在他们的插件中使用 Web 组装来解决这个问题?
【问题讨论】:
-
-s NO_DYNAMIC_EXECUTION=1工作吗? -
@zakki 是的!把它作为我接受的答案!
标签: javascript web google-chrome-extension webassembly emscripten