OLD | NEW |
1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
2 | 2 |
3 <html> | 3 <html> |
4 <head> | 4 <head> |
5 <script src="../resources/js-test.js"></script> | 5 <script src="../resources/js-test.js"></script> |
6 <script src="resources/compatibility.js"></script> | 6 <script src="resources/compatibility.js"></script> |
7 <script src="resources/audio-testing.js"></script> | 7 <script src="resources/audio-testing.js"></script> |
8 </head> | 8 </head> |
9 | 9 |
10 <body> | 10 <body> |
11 <div id="description"></div> | 11 <div id="description"></div> |
12 <div id="console"></div> | 12 <div id="console"></div> |
13 | 13 |
14 <script> | 14 <script> |
15 description("Basic tests for MediaElementAudioSourceNode API."); | 15 description("Basic tests for MediaElementAudioSourceNode API."); |
16 | 16 |
17 var context = 0; | 17 var context = 0; |
| 18 var audioElement = 0; |
| 19 var audioNode = 0; |
18 | 20 |
19 function runTest() { | 21 function runTest() { |
20 if (window.testRunner) { | |
21 testRunner.dumpAsText(); | |
22 testRunner.waitUntilDone(); | |
23 } | |
24 | |
25 window.jsTestIsAsync = true; | 22 window.jsTestIsAsync = true; |
26 | 23 |
27 context = new AudioContext(); | 24 context = new AudioContext(); |
28 | 25 |
29 audioElement = new Audio(); | 26 audioElement = new Audio(); |
30 mediaSource = context.createMediaElementSource(audioElement); | 27 mediaSource = context.createMediaElementSource(audioElement); |
31 window.audioNode = mediaSource; | 28 audioNode = mediaSource; |
32 | 29 |
33 // Check number of inputs and outputs. | 30 // Check number of inputs and outputs. |
34 if (audioNode.numberOfInputs == 0) | 31 shouldBeEqualToNumber("audioNode.numberOfInputs", 0); |
35 testPassed("Source AudioNode has no inputs."); | 32 shouldBeEqualToNumber("audioNode.numberOfOutputs", 1); |
36 else | |
37 testFailed("Source AudioNode should not have inputs."); | |
38 | |
39 if (audioNode.numberOfOutputs == 1) | |
40 testPassed("Source AudioNode has one output."); | |
41 else | |
42 testFailed("Source AudioNode should have one output."); | |
43 | 33 |
44 // Try calling connect() method with illegal values. | 34 // Try calling connect() method with illegal values: illegal destination, il
legal output index, |
45 | 35 // and illegal input index. |
46 try { | 36 shouldThrow("audioNode.connect(0, 0, 0)"); |
47 audioNode.connect(0, 0, 0); | 37 shouldThrow("audioNode.connect(context.destination, 5, 0)"); |
48 testFailed("connect() exception should be thrown for illegal destination
AudioNode."); | 38 shouldThrow("audioNode.connect(context.destination, 0, 5)"); |
49 } catch(e) { | |
50 testPassed("connect() exception thrown for illegal destination AudioNode
."); | |
51 } | |
52 | |
53 try { | |
54 audioNode.connect(context.destination, 5, 0); | |
55 testFailed("connect() exception should be thrown for illegal output inde
x."); | |
56 } catch(e) { | |
57 testPassed("connect() exception thrown for illegal output index."); | |
58 } | |
59 | |
60 try { | |
61 audioNode.connect(context.destination, 0, 5); | |
62 testFailed("connect() exception should be thrown for illegal input index
."); | |
63 } catch(e) { | |
64 testPassed("connect() exception thrown for illegal input index."); | |
65 } | |
66 | 39 |
67 // Try calling connect() with proper values. | 40 // Try calling connect() with proper values. |
68 try { | 41 shouldNotThrow("audioNode.connect(context.destination, 0, 0)"); |
69 audioNode.connect(context.destination, 0, 0); | |
70 testPassed("audioNode.connect(context.destination) succeeded."); | |
71 } catch(e) { | |
72 testFailed("audioNode.connect(context.destination) failed."); | |
73 } | |
74 | 42 |
75 // Try creating another MediaElementAudioSourceNode using the same audio ele
ment. | 43 // Try creating another MediaElementAudioSourceNode using the same audio ele
ment. |
76 try { | 44 shouldThrow("context.createMediaElementSource(audioElement)"); |
77 mediaSource = context.createMediaElementSource(audioElement); | |
78 testFailed("createMediaElementSource() should throw if called twice on s
ame HTMLMediaElement."); | |
79 } catch(e) { | |
80 testPassed("createMediaElementSource() threw error when called twice on
same HTMLMediaElement."); | |
81 } | |
82 | 45 |
83 finishJSTest(); | 46 finishJSTest(); |
84 } | 47 } |
85 | 48 |
86 runTest(); | 49 runTest(); |
87 | 50 |
88 </script> | 51 </script> |
89 | 52 |
90 </body> | 53 </body> |
91 </html> | 54 </html> |
OLD | NEW |