Many WebAudio js-tests use waitUntilDone
[WebKit-https.git] / LayoutTests / webaudio / audiobuffersource-negative-playbackrate-loop.html
1 <!DOCTYPE html>
2 <html>
3 <head>
4     <title>audiobuffersource-negative-playbackrate-loop</title>
5     <script src="../resources/js-test.js"></script>
6     <script src="resources/audio-testing.js"></script>
7     <script src="resources/audiobuffersource-testing.js"></script>
8
9     <script>
10
11     var sampleRate = 44100.0;
12     var sourceFrames = 128;
13     var renderFrames = 10;
14     var testSpacingFrames = 0;
15     var startLoop = 100 / sampleRate;
16     var loopDuration = (renderFrames / 2) / sampleRate;
17     var endLoop = startLoop + loopDuration;
18
19     var tests = [{ 
20         description:"Test looping playback at -1 playbackRate",
21         offsetFrame:0,
22         renderFrames:renderFrames,
23         expected:[104, 103, 102, 101, 100, 104, 103, 102, 101, 100],
24     }];
25
26     function go() {
27         jsTestIsAsync = true;
28
29         context = new webkitOfflineAudioContext(1, renderFrames, sampleRate);
30
31         var bufferSource = context.createBufferSource();
32         bufferSource.buffer = createRamp(context, 0, 127, sourceFrames);
33
34         bufferSource.connect(context.destination);
35         bufferSource.playbackRate.value = -1;
36         bufferSource.loop = true;
37         bufferSource.loopStart = startLoop;
38         bufferSource.loopEnd = endLoop;
39         bufferSource.start(0, startLoop, loopDuration);
40         bufferSource.stop(loopDuration * 2);
41
42         context.oncomplete = checkAllTests;
43         context.startRendering();
44     }
45
46     </script>
47 </head>
48 <body onload="go()">
49 </body>
50 </html>