Refactoring: Pull all fullscreen code out of Document and into its own helper class
[WebKit-https.git] / LayoutTests / webaudio / audiobuffer.html
1 <!DOCTYPE html>
2 <html>
3 <head>
4 <script src="../resources/js-test-pre.js"></script>
5 <script src="resources/audio-testing.js"></script>
6 </head>
7 <body>
8 <script>
9 description("Basic tests for AudioBuffer.");
10
11 var sampleRate = 44100.0
12 var lengthInSeconds = 2;
13 var numberOfChannels = 4;
14
15 var context = new webkitAudioContext();
16 var buffer = context.createBuffer(numberOfChannels, sampleRate * lengthInSeconds, sampleRate);
17
18 if (buffer.sampleRate === sampleRate)
19     testPassed("sampleRate has been set correctly.");
20 else
21     testFailed("sampleRate should be set correctly.");
22
23 if (buffer.length === sampleRate * lengthInSeconds)
24     testPassed("length has been set correctly.");
25 else
26     testFailed("length should be set correctly");
27
28 if (buffer.duration === lengthInSeconds)
29     testPassed("duration has been set correctly.");
30 else
31     testFailed("duration should be set correctly.");
32
33 if (buffer.numberOfChannels === numberOfChannels)
34     testPassed("numberOfChannels has been set correctly.");
35 else
36     testFailed("numberOfChannels should be set correctly.");
37
38 for (var index = 0; index < buffer.numberOfChannels; ++index) {
39     if (buffer.getChannelData(index) instanceof window.Float32Array)
40         testPassed("getChannelData(" + index + ") returns a Float32Array object.");
41     else
42         testFailed("getChannelData(" + index + ") should return a Float32Array object.");
43 }
44
45 try {
46     buffer.getChannelData(buffer.numberOfChannels);
47     testFailed("Exception should be thrown when index is not less than numberOfChannels.");
48 } catch(e) {
49     testPassed("Exception has been thrown correctly when index is not less than numberOfChannels.");
50 }
51
52 shouldThrowErrorName("context.createBuffer(null, false)", "TypeError");
53
54 </script>
55
56 <script src="../resources/js-test-post.js"></script>
57 </body>
58 </html>