summaryrefslogtreecommitdiffstats
path: root/dom/worklet/tests/worklet_promise.js
blob: 8c593fd001eb722659607d6feeb574ac8c3bdde9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
class WasmProcessWorkletProcessor extends AudioWorkletProcessor {
  constructor(...args) {
    super(...args);
    this.port.onmessage = e => {
      WebAssembly.compile(e.data).then(
        m => {
          this.port.postMessage(m);
        },
        () => {
          this.port.postMessage("error");
        }
      );
    };
  }

  process(inputs, outputs, parameters) {
    // Do nothing, output silence
    return true;
  }
}

registerProcessor("promise", WasmProcessWorkletProcessor);