【问题标题】:Web workers fires exception on mac safari网络工作者在 mac safari 上引发异常
【发布时间】:2016-06-10 12:20:07
【问题描述】:
我在创建网络工作者时遇到以下异常。检查我的代码 sn-p
var temp = new Worker('/file.js')
try{
temp.postMessage('msg')
}
catch(e){
console.error(e)
}
例外是“TypeError: Value is not a sequence”
【问题讨论】:
标签:
javascript
safari
web-worker
【解决方案1】:
我不确定这有多相关,但是我们在任何启用了 WebDriver 扩展的 Safari 实例上都遇到了 console.* 调用问题。我怀疑这与 WebDriver 收集控制台日志的方式有关,它以某种方式覆盖了默认实现,从而引发了TypeError。
对于单元测试,我们的解决方案是使用我们自己的 jasmine 模拟。类似的解决方案可能会对您有所帮助。
beforeEach(() => {
if (window.navigator.userAgent.indexOf('Safari') > -1) {
spyOn(console, 'log').and.stub();
spyOn(console, 'info').and.stub();
spyOn(console, 'warn').and.stub();
spyOn(console, 'debug').and.stub();
spyOn(console, 'error').and.stub();
}
});