| <!DOCTYPE html> |
| <html> |
| <head> |
| <title> |
| mediaelementaudiosourcenode.html |
| </title> |
| <script src="../../imported/w3c/web-platform-tests/resources/testharness.js"></script> |
| <script src="../../resources/testharnessreport.js"></script> |
| <script src="../resources/audit-util.js"></script> |
| <script src="../resources/audit.js"></script> |
| </head> |
| <body> |
| <script id="layout-test-code"> |
| let audit = Audit.createTaskRunner(); |
| |
| audit.define( |
| { |
| label: 'test', |
| description: 'Basic tests for MediaElementAudioSourceNode API' |
| }, |
| (task, should) => { |
| |
| let context = new AudioContext(); |
| |
| let audioElement = new Audio(); |
| let mediaSource = context.createMediaElementSource(audioElement); |
| let audioNode = mediaSource; |
| |
| // Check number of inputs and outputs. |
| should(audioNode.numberOfInputs, 'audioNode.numberOfInputs') |
| .beEqualTo(0); |
| should(audioNode.numberOfOutputs, 'audioNode.numberOfOutputs') |
| .beEqualTo(1); |
| |
| // Try calling connect() method with illegal values: illegal |
| // destination, illegal output index, and illegal input index. |
| should( |
| () => audioNode.connect(0, 0, 0), 'audioNode.connect(0, 0, 0)') |
| .throw(TypeError); |
| should( |
| () => audioNode.connect(context.destination, 5, 0), |
| 'audioNode.connect(context.destination, 5, 0)') |
| .throw(DOMException, 'IndexSizeError'); |
| should( |
| () => audioNode.connect(context.destination, 0, 5), |
| 'audioNode.connect(context.destination, 0, 5)') |
| .throw(DOMException, 'IndexSizeError'); |
| |
| // Verify same object is returned. |
| let element = mediaSource.mediaElement; |
| should( |
| element instanceof HTMLMediaElement, |
| 'mediaSource.mediaElement instanceof HTMLMediaElement') |
| .beTrue(); |
| should( |
| mediaSource.mediaElement === element, |
| 'mediaSource.mediaElement is same object') |
| .beTrue(); |
| |
| // Try calling connect() with proper values. |
| should( |
| () => audioNode.connect(context.destination, 0, 0), |
| 'audioNode.connect(context.destination, 0, 0)') |
| .notThrow(); |
| |
| // Try creating another MediaElementAudioSourceNode using the same |
| // audio element. |
| should( |
| () => context.createMediaElementSource(audioElement), |
| 'context.createMediaElementSource(audioElement)') |
| .throw(); |
| |
| task.done(); |
| }); |
| |
| audit.run(); |
| </script> |
| </body> |
| </html> |