summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/webaudio/the-audio-api/the-audioworklet-interface/audioworklet-registerprocessor-dynamic.https.html
diff options
context:
space:
mode:
Diffstat (limited to 'testing/web-platform/tests/webaudio/the-audio-api/the-audioworklet-interface/audioworklet-registerprocessor-dynamic.https.html')
-rw-r--r--testing/web-platform/tests/webaudio/the-audio-api/the-audioworklet-interface/audioworklet-registerprocessor-dynamic.https.html36
1 files changed, 36 insertions, 0 deletions
diff --git a/testing/web-platform/tests/webaudio/the-audio-api/the-audioworklet-interface/audioworklet-registerprocessor-dynamic.https.html b/testing/web-platform/tests/webaudio/the-audio-api/the-audioworklet-interface/audioworklet-registerprocessor-dynamic.https.html
new file mode 100644
index 0000000000..de31f71427
--- /dev/null
+++ b/testing/web-platform/tests/webaudio/the-audio-api/the-audioworklet-interface/audioworklet-registerprocessor-dynamic.https.html
@@ -0,0 +1,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>