Move parseFontFaceDescriptor to CSSPropertyParser.cpp
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / webaudio / audiobuffersource-loop-grain-no-duration.html
blob47858dfccddb6325d70add16a359640c99004d3d
1 <!doctype html>
2 <html>
3 <head>
4 <title>Test AudioBufferSourceNode looping without explicit duration</title>
5 <script src="resources/compatibility.js"></script>
6 <script src="resources/audio-testing.js"></script>
7 <script src="../resources/js-test.js"></script>
8 </head>
10 <body>
11 <script>
12 description("Test AudioBufferSourceNode looping without explicit duration");
14 var context;
15 var buffer;
16 var output;
17 var expected;
18 var sampleRate = 44100;
19 var sourceFrames = 8;
20 // How many loops of the source we want to render. Any whole number greater than 1 will work.
21 var loopCount = 4;
22 var renderFrames = sourceFrames * loopCount;
25 function checkResult(renderedBuffer) {
26 var badIndex = -1;
27 var success = true;
29 expected = buffer.getChannelData(0);
30 output = renderedBuffer.getChannelData(0);
32 // Verify the output has the expected data. The actual output should be a loopCount copies
33 // of the source buffer.
34 for (var k = 0; k < loopCount; ++k) {
35 // Check that this current subset is a linear ramp matching the original source.
36 for (var n = 0; n < sourceFrames; ++n) {
37 if (expected[n] != output[n + k * sourceFrames]) {
38 // Remember the first bad sample and exit all loops now.
39 badIndex = n + k * sourceFrames;
40 success = false;
41 break;
44 if (!success)
45 break;
48 if (success) {
49 testPassed("Source looped correctly");
50 } else {
51 testFailed("First incorrect sample at index " + badIndex);
55 function runTest() {
56 window.jsTestIsAsync = true;
58 // Create a short linear ramp and enable looping. The test will verify that the ramp was
59 // looped the appropriate number of times.
60 context = new OfflineAudioContext(1, renderFrames, sampleRate);
61 buffer = createLinearRampBuffer(context, sourceFrames);
62 var source = context.createBufferSource();
63 source.buffer = buffer;
64 source.connect(context.destination);
66 // Loop the source, and start the source with an offset, but without a duration. In this
67 // case, the source should loop "forever". See crbug.com/457009. The case where the
68 // duration is given is covered in other tests.
69 source.loop = true;
70 source.start(0, 0);
71 context.startRendering()
72 .then(checkResult)
73 .then(finishJSTest);
76 runTest();
77 </script>
78 </body>
79 </html>