sharedworker-failure.js (539B)
1 importScripts("./test-incrementer.js"); 2 importScripts("./create-empty-wasm-module.js"); 3 4 let state = "send-sw-failure" 5 onconnect = initialE => { 6 let port = initialE.source; 7 port.postMessage(state) 8 port.onmessage = e => { 9 if(state === "" && e.data === "send-window-failure") { 10 port.postMessage(createEmptyWasmModule()) 11 } else { 12 port.postMessage("failure") 13 } 14 } 15 port.onmessageerror = e => { 16 if(state === "send-sw-failure") { 17 port.postMessage("send-sw-failure-success") 18 state = "" 19 } 20 } 21 }