Set input method state when webpage move by history
[framework/web/webkit-efl.git] / LayoutTests / webaudio / test-basic.html
1 <!DOCTYPE html>
2
3 <!--
4 This is a very basic test to make sure testRunner.setAudioData() works correctly.
5 It generates a 2 seconds long stereo result @44.1KHz
6 The left channel will be a 880Hz tone, while the right will be 440Hz.
7 -->
8
9 <html>
10 <head>
11 <script src="../fast/js/resources/js-test-pre.js"></script>
12 <script type="text/javascript" src="resources/audio-testing.js"></script>
13
14 </head>
15 <body>
16
17 <div id="description"></div>
18 <div id="console"></div>
19
20 <script>
21 description("Tests basic audio test infrastructure: specifically testRunner.setAudioData()");
22
23 var sampleRate = 44100.0;
24 var lengthInSeconds = 2;
25
26 function generateSinWave(audioBuffer) {
27     var n = audioBuffer.length;
28     var channelL = audioBuffer.getChannelData(0);
29     var channelR = audioBuffer.getChannelData(1);
30     var sampleRate = audioBuffer.sampleRate;
31     
32     for (var i = 0; i < n; ++i) {
33         channelL[i] = Math.sin(880.0 * 2.0*Math.PI * i / sampleRate);
34         channelR[i] = Math.sin(440.0 * 2.0*Math.PI * i / sampleRate);
35     }
36 }
37
38 function runTest() {
39     if (!window.testRunner)
40         return;
41     
42     var context = new webkitAudioContext();
43     var audioBuffer = context.createBuffer(2, lengthInSeconds * sampleRate, sampleRate);
44     
45     generateSinWave(audioBuffer);
46
47     var audioData = createAudioData(audioBuffer);
48     testRunner.setAudioData(audioData);
49
50     testRunner.notifyDone();
51 }
52
53 runTest();
54
55 </script>
56
57 <script src="../fast/js/resources/js-test-post.js"></script>
58
59 <body>
60 </body>
61 </html>