Web Workers在Mac Safari上引发异常

13

我在创建Web Workers时遇到了以下异常。请检查我的代码片段。

    var temp = new Worker('/file.js')
    try{
    temp.postMessage('msg')
    }
    catch(e){
     console.error(e)
     }

异常为"TypeError: Value is not a sequence"


1
你解决了吗?...我也遇到了同样的问题。 - Ole Sauffaus
有没有解决这个问题的方法? - Druvis Cukurs
1个回答

0

我不确定这与编程有多大关系,但我们在启用了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();
  }
});

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接