0
SECURITY_ERR: DOM Exception 18: An attempt was made to break through the security policy of the user agent.
這是否意味着PhantomJS無法與WebWorkers工作或我需要設置一些配置,使其工作?
E.g.我需要測試的腳本與WebWorker交互(在我的情況worker.js文件):
var worker = new Worker('doWork.js');
worker.addEventListener('message', function(e) {
console.log('Worker said: ', e.data);
}, false);
worker.postMessage('Hello World');
phantom.exit();
這是工人的代碼(doWork.js中):
self.addEventListener('message', function(e) {
self.postMessage(e.data);
}, false);
phantom.exit();
當我嘗試運行它,我得到了:
[email protected]:~/phantom_test$ phantomjs worker.js
SECURITY_ERR: DOM Exception 18: An attempt was made to break through the security policy of the user agent.
worker.js:1
您是否嘗試使用'--web-security = false'命令行選項運行它? –
它不起作用,同樣的錯誤。 –