Implement OfflineAudioContext constructor
[WebKit-https.git] / LayoutTests / webaudio / javascriptaudionode-zero-input-channels.html
1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
2 <html>
3 <head>
4 <link rel="stylesheet" href="../fast/js/resources/js-test-style.css"/>
5 <script src="resources/audio-testing.js"></script>
6 <script src="../fast/js/resources/js-test-pre.js"></script>
7 </head>
8
9 <body>
10 <div id="description"></div>
11 <div id="console"></div>
12
13 <script>
14 description("Tests that JavaScriptAudioNode accepts 0 input channels.");
15
16 var sampleRate = 44100.0;
17 var renderLengthInFrames = 512;
18 var bufferSize = 512;
19
20 function checkResult(e)
21 {
22     testPassed("JavaScriptAudioNode accepts 0 input channels.");
23
24     finishJSTest();
25 }
26
27 function runTest()
28 {
29     if (window.testRunner) {
30         testRunner.dumpAsText();
31         testRunner.waitUntilDone();
32     }
33
34     window.jsTestIsAsync = true;
35
36     var context = new webkitOfflineAudioContext(1, renderLengthInFrames, sampleRate);
37
38     var node;
39
40     try {  
41         node = context.createJavaScriptNode(bufferSize, 0, 1);
42         testPassed("Successfully created JavaScriptAudioNode.");
43     } catch (e) {
44         testFailed("Failed to create JavaScriptAudioNode.");
45     }
46
47     var source = context.createBufferSource();
48     source.buffer = createImpulseBuffer(context, bufferSize);
49
50     // The onaudioprocess function doesn't need to do anything.  We just need the process to start
51     // to test that implementation accepts 0 input channels.
52     //
53     // FIXME: check the .inputBuffer attribute of the AudioProcessingEvent.
54     node.onaudioprocess = function(e) { };
55     source.connect(node);
56     node.connect(context.destination);
57     source.noteOn(0);
58
59     context.oncomplete = checkResult;
60     context.startRendering();
61 }
62
63 runTest();
64 successfullyParsed = true;
65 </script>
66     
67 <script src="../fast/js/resources/js-test-post.js"></script>
68 </body>
69 </html>