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