| <!DOCTYPE html> |
| <html> |
| <head> |
| <title> |
| Test onprocessorerror handler in AudioWorkletNode |
| </title> |
| <script src="/resources/testharness.js"></script> |
| <script src="/resources/testharnessreport.js"></script> |
| <script src="/webaudio/resources/audit.js"></script> |
| </head> |
| <body> |
| <script id="layout-test-code"> |
| let audit = Audit.createTaskRunner(); |
| |
| const sampleRate = 48000; |
| const renderLength = sampleRate * 0.1; |
| let context = new OfflineAudioContext(1, renderLength, sampleRate); |
| |
| let filePath = 'processors/error-processor.js'; |
| |
| // Test |onprocessorerror| called upon failure of processor constructor. |
| audit.define('constructor-error', |
| (task, should) => { |
| let constructorErrorWorkletNode = |
| new AudioWorkletNode(context, 'constructor-error'); |
| constructorErrorWorkletNode.onprocessorerror = () => { |
| // Without 'processorerror' event callback, this test will be |
| // timed out. |
| task.done(); |
| }; |
| }); |
| |
| // Test |onprocessorerror| called upon failure of process() method. |
| audit.define('process-error', |
| (task, should) => { |
| let processErrorWorkletNode = |
| new AudioWorkletNode(context, 'process-error'); |
| processErrorWorkletNode.connect(context.destination); |
| processErrorWorkletNode.onprocessorerror = () => { |
| // Without 'processorerror' event callback, this test will be |
| // timed out. |
| task.done(); |
| }; |
| |
| context.startRendering(); |
| }); |
| |
| // 'error-processor.js' contains 2 class definitions represents an error |
| // in the constructor and an error in the process method respectively. |
| context.audioWorklet.addModule(filePath).then(() => { |
| audit.run(); |
| }); |
| </script> |
| </body> |
| </html> |