Move parseFontFaceDescriptor to CSSPropertyParser.cpp
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / webaudio / offlineaudiocontext-promise.html
blob7c8c07a0a946a940a69b2c21e87211530ec23cee
1 <!doctype html>
2 <html>
3 <head>
4 <script src="../resources/js-test.js"></script>
5 <script src="resources/compatibility.js"></script>
6 <script src="resources/audio-testing.js"></script>
7 <title>OfflineAudioContext.startRendering Promise with oncomplete</title>
8 </head>
10 <body>
11 <script>
12 description("Test OfflineAudioContext.startRendering Promise with oncomplete");
14 var context;
15 var promise;
16 var renderedData;
17 var promiseData;
19 var sampleRate = 48000;
20 var renderSeconds = 1;
21 var renderFrames = sampleRate * renderSeconds;
22 var contextChannels = 2;
24 function compareData() {
25 // The spec implies that the same buffer is returned by both oncomplete and the promise.
26 // Check that they are identical.
27 if (renderedData === promiseData) {
28 testPassed("AudioBuffer returned by oncomplete and promise are identical");
29 } else {
30 testFailed("AudioBuffer returned by oncomplete and promise are NOT identical");
32 finishJSTest();
35 function checkResult (event) {
36 renderedData = event.renderedBuffer;
37 promise.then(function (result) {
38 promiseData = result;
39 compareData();
40 });
43 // Create an offline context and verify that both the oncomplete and promise are returned with
44 // the same stuff.
45 function runTest() {
46 window.jsTestIsAsync = true;
48 context = new OfflineAudioContext(contextChannels, renderFrames, sampleRate);
50 var buffer = context.createBuffer(contextChannels, renderFrames, sampleRate);
51 for (var k = 0; k < renderFrames; ++k) {
52 buffer.getChannelData(0)[k] = 1;
53 buffer.getChannelData(1)[k] = 2;
56 var source = context.createBufferSource();
57 source.buffer = buffer;
58 source.connect(context.destination);
59 source.start();
61 context.oncomplete = checkResult;
63 promise = context.startRendering();
67 runTest();
68 successfullyParsed = true;
69 </script>
71 </body>
72 </html>