Upstream version 6.35.121.0
[platform/framework/web/crosswalk.git] / src / third_party / WebKit / LayoutTests / webaudio / mediaelementaudiosourcenode.html
1 <!DOCTYPE html>
2
3 <html>
4 <head>
5 <script src="../resources/js-test.js"></script>
6 <script src="resources/compatibility.js"></script>
7 <script src="resources/audio-testing.js"></script>
8 </head>
9
10 <body>
11 <div id="description"></div>
12 <div id="console"></div>
13
14 <script>
15 description("Basic tests for MediaElementAudioSourceNode API.");
16
17 var context = 0;
18
19 function runTest() {
20     if (window.testRunner) {
21         testRunner.dumpAsText();
22         testRunner.waitUntilDone();
23     }
24     
25     window.jsTestIsAsync = true;
26
27     context = new AudioContext();
28
29     audioElement = new Audio();
30     mediaSource = context.createMediaElementSource(audioElement);
31     window.audioNode = mediaSource;
32
33     // Check number of inputs and outputs.
34     if (audioNode.numberOfInputs == 0)
35         testPassed("Source AudioNode has no inputs.");
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
44     // Try calling connect() method with illegal values.
45
46     try {
47         audioNode.connect(0, 0, 0);
48         testFailed("connect() exception should be thrown for illegal destination AudioNode.");
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 index.");
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
67     // Try calling connect() with proper values.
68     try {
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     
75     // Try creating another MediaElementAudioSourceNode using the same audio element.
76     try {
77         mediaSource = context.createMediaElementSource(audioElement);
78         testFailed("createMediaElementSource() should throw if called twice on same HTMLMediaElement.");
79     } catch(e) {
80         testPassed("createMediaElementSource() threw error when called twice on same HTMLMediaElement.");
81     }
82
83     finishJSTest();
84 }
85
86 runTest();
87
88 </script>
89
90 </body>
91 </html>