summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/webaudio/the-audio-api/the-audioworklet-interface/processors/dynamic-register-processor.js
blob: 5e825aebb42b367bdffc473ddd9d9068dbd1a358 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
class ProcessorA extends AudioWorkletProcessor {
  process() {
    return true;
  }
}

// ProcessorB registers ProcessorA upon the construction.
class ProcessorB extends AudioWorkletProcessor {
  constructor() {
    super();
    this.port.onmessage = () => {
      registerProcessor('ProcessorA', ProcessorA);
      this.port.postMessage({});
    };
  }

  process() {
    return true;
  }
}

registerProcessor('ProcessorB', ProcessorB);