5 <script src="../resources/js-test.js"></script>
6 <script src="resources/compatibility.js"></script>
7 <script src="resources/audio-testing.js"></script>
11 <div id="description"></div>
12 <div id="console"></div>
15 description("Basic tests for MediaElementAudioSourceNode API.");
20 if (window.testRunner) {
21 testRunner.dumpAsText();
22 testRunner.waitUntilDone();
25 window.jsTestIsAsync = true;
27 context = new AudioContext();
29 audioElement = new Audio();
30 mediaSource = context.createMediaElementSource(audioElement);
31 window.audioNode = mediaSource;
33 // Check number of inputs and outputs.
34 if (audioNode.numberOfInputs == 0)
35 testPassed("Source AudioNode has no inputs.");
37 testFailed("Source AudioNode should not have inputs.");
39 if (audioNode.numberOfOutputs == 1)
40 testPassed("Source AudioNode has one output.");
42 testFailed("Source AudioNode should have one output.");
44 // Try calling connect() method with illegal values.
47 audioNode.connect(0, 0, 0);
48 testFailed("connect() exception should be thrown for illegal destination AudioNode.");
50 testPassed("connect() exception thrown for illegal destination AudioNode.");
54 audioNode.connect(context.destination, 5, 0);
55 testFailed("connect() exception should be thrown for illegal output index.");
57 testPassed("connect() exception thrown for illegal output index.");
61 audioNode.connect(context.destination, 0, 5);
62 testFailed("connect() exception should be thrown for illegal input index.");
64 testPassed("connect() exception thrown for illegal input index.");
67 // Try calling connect() with proper values.
69 audioNode.connect(context.destination, 0, 0);
70 testPassed("audioNode.connect(context.destination) succeeded.");
72 testFailed("audioNode.connect(context.destination) failed.");
75 // Try creating another MediaElementAudioSourceNode using the same audio element.
77 mediaSource = context.createMediaElementSource(audioElement);
78 testFailed("createMediaElementSource() should throw if called twice on same HTMLMediaElement.");
80 testPassed("createMediaElementSource() threw error when called twice on same HTMLMediaElement.");