Move parseFontFaceDescriptor to CSSPropertyParser.cpp
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / webaudio / audiobuffersource-grain.html
blob0011e276bf76aa138cdd1b4c02dd00b877bc4d39
1 <!doctype html>
2 <html>
3 <head>
4 <title>Test Start Grain with Delayed Buffer Setting </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 setting the source buffer after starting the grain");
14 var context;
15 var source;
16 var buffer;
17 var renderedData;
19 var sampleRate = 44100;
21 var testDurationSec = 1;
22 var testDurationSamples = testDurationSec * sampleRate;
23 var startTime = 0.9 * testDurationSec;
25 function runTest() {
26 window.jsTestIsAsync = true;
28 context = new OfflineAudioContext(1, testDurationSamples, sampleRate);
29 context.oncomplete = checkResult;
31 buffer = createConstantBuffer(context, testDurationSamples, 1);
32 source = context.createBufferSource();
33 source.connect(context.destination);
35 // Start the source BEFORE we set the buffer. The grain offset and duration aren't
36 // important, as long as we specify some offset.
37 source.start(startTime, .1);
38 source.buffer = buffer;
40 // Render it!
41 context.startRendering();
44 function checkResult(event) {
45 var success = false;
47 renderedData = event.renderedBuffer.getChannelData(0);
49 // Check that the rendered data is not all zeroes. Any non-zero data means the test
50 // passed.
51 var startFrame = Math.round(startTime * sampleRate);
52 for (k = 0; k < renderedData.length; ++k) {
53 if (renderedData[k]) {
54 success = true;
55 break;
59 if (success)
60 testPassed("Buffer was played.");
61 else
62 testFailed("Buffer was not played.");
64 finishJSTest();
67 runTest();
68 successfullyParsed = true;
69 </script>
70 </body>
71 </html>