summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/wasm/serialization/module/resources/sharedworker-failure.js
blob: 854c70b9e84e6e6fb1c59f64a06a79646a122576 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
importScripts("./test-incrementer.js");
importScripts("./create-empty-wasm-module.js");

let state = "send-sw-failure"
onconnect = initialE => {
  let port = initialE.source;
  port.postMessage(state)
  port.onmessage = e => {
    if(state === "" && e.data === "send-window-failure") {
      port.postMessage(createEmptyWasmModule())
    } else {
      port.postMessage("failure")
    }
  }
  port.onmessageerror = e => {
    if(state === "send-sw-failure") {
      port.postMessage("send-sw-failure-success")
      state = ""
    }
  }
}