5 <script src="../fast/js/resources/js-test-pre.js"></script>
6 <script type="text/javascript" src="resources/audio-testing.js"></script>
10 <div id="description"></div>
11 <div id="console"></div>
14 description("Basic tests for AudioNode API.");
20 if (window.testRunner) {
21 testRunner.dumpAsText();
22 testRunner.waitUntilDone();
25 window.jsTestIsAsync = true;
27 context = new webkitAudioContext();
28 window.audioNode = context.createBufferSource();
30 shouldThrow("audioNode.noteOn()");
31 shouldThrow("audioNode.noteGrainOn()");
32 shouldThrow("audioNode.noteOff()");
34 // Check input and output numbers of AudioSourceNode.
35 if (audioNode.numberOfInputs === 0)
36 testPassed("Source AudioNode has no inputs.");
38 testFailed("Source AudioNode should not have inputs.");
40 if (audioNode.numberOfOutputs === 1)
41 testPassed("Source AudioNode has one output.");
43 testFailed("Source AudioNode should have one output.");
45 // Check input and output numbers of AudioDestinationNode
46 if (context.destination.numberOfInputs === 1)
47 testPassed("Destination AudioNode has one input.");
49 testFailed("Destination AudioNode should have one input.");
51 if (context.destination.numberOfOutputs === 0)
52 testPassed("Destination AudioNode has no outputs.");
54 testFailed("Destination AudioNode should have no outputs.");
56 // Try calling connect() method with illegal values.
59 audioNode.connect(0, 0, 0);
60 testFailed("connect() exception should be thrown for illegal destination AudioNode.");
62 testPassed("connect() exception thrown for illegal destination AudioNode.");
66 audioNode.connect(context.destination, 5, 0);
67 testFailed("connect() exception should be thrown for illegal output index.");
69 testPassed("connect() exception thrown for illegal output index.");
73 audioNode.connect(context.destination, 0, 5);
74 testFailed("connect() exception should be thrown for illegal input index.");
76 testPassed("connect() exception thrown for illegal input index.");
79 // Try calling connect() with proper values.
81 audioNode.connect(context.destination, 0, 0);
82 testPassed("audioNode.connect(context.destination) succeeded.");
84 testFailed("audioNode.connect(context.destination) failed.");
87 // Create a new context and try to connect the other context's node to this one.
89 context2 = new webkitAudioContext();
90 window.audioNode.connect(context2.destination);
91 testFailed("exception should be thrown when connecting to other context's node.");
93 testPassed("exception thrown when connecting to other context's node.");
96 // Create a new context with not enough arguments
98 context2 = new webkitAudioContext(0, 0);
99 testFailed("exception should be thrown when creating audio context with not enough arguments.");
101 testPassed("exception thrown when creating audio context with not enough arguments.");
111 <script src="../fast/js/resources/js-test-post.js"></script>