我是 Chrome Web Apps 的初学者,正在尝试将 Bump'n'Jump 的 JavaScript/HTML5 克隆打包为打包应用程序。我遇到了 Chrome 的安全策略:
function pump() {
while (1) {
game_loop();
var now = timeGetTime();
var time_diff = next_time - now;
next_time += (1000 / 60);
if (time_diff>0) {
// we have time left
setTimeout("pump()", time_diff);
break;
}
// debug("frametime exceeded: " + (-time_diff));
}
}
它拒绝运行setTimeout("pump()", time_diff);
,说
Refused to evaluate script because it violates the following Content Security Policy directive: "default-src 'self' chrome-extension-resource:". Note that 'script-src' was not explicitly set, so 'default-src' is used as a fallback.
该错误与代码无关,因为它在浏览器中的 Chrome 之外运行,Chrome 的安全性似乎不喜欢它。谁能告诉我为什么它不想运行pump()
?