tizen beta release
[profile/ivi/webkit-efl.git] / LayoutTests / webaudio / audionode.html
1 <!DOCTYPE html>
2
3 <html>
4 <head>
5 <script src="../fast/js/resources/js-test-pre.js"></script>
6 <script type="text/javascript" src="resources/audio-testing.js"></script>
7 </head>
8
9 <body>
10 <div id="description"></div>
11 <div id="console"></div>
12
13 <script>
14 description("Basic tests for AudioNode API.");
15
16 var context = 0;
17 var context2 = 0;
18
19 function runTest() {
20     if (window.layoutTestController) {
21         layoutTestController.dumpAsText();
22         layoutTestController.waitUntilDone();
23     }
24     
25     window.jsTestIsAsync = true;
26
27     context = new webkitAudioContext();
28     window.audioNode = context.createBufferSource();
29
30     shouldThrow("audioNode.noteOn()");
31     shouldThrow("audioNode.noteGrainOn()");
32     shouldThrow("audioNode.noteOff()");
33
34     // Check number of inputs and outputs.
35     if (audioNode.numberOfInputs == 0)
36         testPassed("Source AudioNode has no inputs.");
37     else
38         testFailed("Source AudioNode should not have inputs.");
39     
40     if (audioNode.numberOfOutputs == 1)
41         testPassed("Source AudioNode has one output.");
42     else
43         testFailed("Source AudioNode should have one output.");
44
45     // Try calling connect() method with illegal values.
46
47     try {
48         audioNode.connect(0, 0, 0);
49         testFailed("connect() exception should be thrown for illegal destination AudioNode.");
50     } catch(e) {
51         testPassed("connect() exception thrown for illegal destination AudioNode.");
52     }
53
54     try {
55         audioNode.connect(context.destination, 5, 0);
56         testFailed("connect() exception should be thrown for illegal output index.");
57     } catch(e) {
58         testPassed("connect() exception thrown for illegal output index.");
59     }
60
61     try {
62         audioNode.connect(context.destination, 0, 5);
63         testFailed("connect() exception should be thrown for illegal input index.");
64     } catch(e) {
65         testPassed("connect() exception thrown for illegal input index.");
66     }
67
68     // Try calling connect() with proper values.
69     try {
70         audioNode.connect(context.destination, 0, 0);
71         testPassed("audioNode.connect(context.destination) succeeded.");
72     } catch(e) {
73         testFailed("audioNode.connect(context.destination) failed.");
74     }
75     
76     // Create a new context and try to connect the other context's node to this one.
77     try {
78         context2 = new webkitAudioContext();
79         window.audioNode.connect(context2.destination);
80         testFailed("exception should be thrown when connecting to other context's node.");
81     } catch(e) {
82         testPassed("exception thrown when connecting to other context's node.");
83     }
84
85     finishJSTest();
86 }
87
88 runTest();
89
90 </script>
91
92 <script src="../fast/js/resources/js-test-post.js"></script>
93 </body>
94 </html>