2016-02-27 32 views
8

我在創建web工作人員時遇到以下異常。檢查我的代碼片段Web工作人員在mac safari上觸發異常

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

的例外是「類型錯誤:值不是序列」

+0

你解決了嗎? ...我面臨同樣的問題。 –

回答

0

我不能確定如何與這個,但是我們遇到的問題與任何Safari瀏覽器實例console.*調用該啓用WebDriver擴展。我懷疑它與WebDriver如何收集控制檯日誌有關,它以某種方式覆蓋默認實現,並引發TypeError

我們的解決方案,單元測試,是應用我們自己的嘲笑茉莉花。類似的解決方案可能會幫助你。

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(); 
    } 
}); 
相關問題