blob: de31f71427d5cd29e61935e8f82217e1c8bc0341 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
<!DOCTYPE html>
<html>
<head>
<title>
Test dynamic registerProcessor() calls in AudioWorkletGlobalScope
</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
</head>
<body>
<script>
const t = async_test('Dynamic registration in AudioWorkletGlobalScope');
const realtimeContext = new AudioContext();
const filePath = 'processors/dynamic-register-processor.js';
// Test if registering an AudioWorkletProcessor dynamically (after the
// initial module script loading) works correctly. In the construction of
// nodeB (along with ProcessorB), it registers ProcessorA's definition.
realtimeContext.audioWorklet.addModule(filePath).then(() => {
const nodeB = new AudioWorkletNode(realtimeContext, 'ProcessorB');
assert_true(nodeB instanceof AudioWorkletNode,
'nodeB should be instance of AudioWorkletNode');
nodeB.port.postMessage({});
nodeB.port.onmessage = () => {
const nodeA = new AudioWorkletNode(realtimeContext, 'ProcessorA');
t.step(() => {
assert_true(nodeA instanceof AudioWorkletNode,
'nodeA should be instance of AudioWorkletNode');
});
t.done();
};
});
</script>
</body>
</html>
|