OLD | NEW |
---|---|
1 <!doctype html> | 1 <!doctype html> |
2 <html> | 2 <html> |
3 <head> | 3 <head> |
4 <script src="../resources/js-test.js"></script> | 4 <script src="../resources/js-test.js"></script> |
5 <script src="resources/audio-testing.js"/> | |
6 <script src="resources/compatibility.js"></script> | 5 <script src="resources/compatibility.js"></script> |
6 <script src="resources/audio-testing.js"></script> | |
Raymond Toy
2015/02/23 21:37:38
Does the order matter?
| |
7 <title>OfflineAudioContext.startRendering Promise with oncomplete</title> | 7 <title>OfflineAudioContext.startRendering Promise with oncomplete</title> |
8 </head> | 8 </head> |
9 | 9 |
10 <body> | 10 <body> |
11 <script> | 11 <script> |
12 description("Test OfflineAudioContext.startRendering Promise with oncomple te") | 12 description("Test OfflineAudioContext.startRendering Promise with oncomple te"); |
13 | 13 |
14 var context; | 14 var context; |
15 var promise; | 15 var promise; |
16 var renderedData; | 16 var renderedData; |
17 var promiseData; | 17 var promiseData; |
18 | 18 |
19 var sampleRate = 48000; | 19 var sampleRate = 48000; |
20 var renderSeconds = 1; | 20 var renderSeconds = 1; |
21 var renderFrames = sampleRate * renderSeconds; | 21 var renderFrames = sampleRate * renderSeconds; |
22 var contextChannels = 2; | 22 var contextChannels = 2; |
23 | 23 |
24 function compareData() { | 24 function compareData() { |
25 // The spec implies that the same buffer is returned by both oncomplete and the promise. | 25 // The spec implies that the same buffer is returned by both oncomplete and the promise. |
26 // Check that they are identical. | 26 // Check that they are identical. |
27 if (renderedData === promiseData) { | 27 if (renderedData === promiseData) { |
28 testPassed("AudioBuffer returned by oncomplete and promise are identic al"); | 28 testPassed("AudioBuffer returned by oncomplete and promise are identic al"); |
29 } else { | 29 } else { |
30 testPassed("AudioBuffer returned by oncomplete and promise are NOT ide ntical"); | 30 testFailed("AudioBuffer returned by oncomplete and promise are NOT ide ntical"); |
31 } | 31 } |
32 finishJSTest(); | 32 finishJSTest(); |
33 } | 33 } |
34 | 34 |
35 function checkResult (event) | 35 function checkResult (event) { |
36 { | |
37 renderedData = event.renderedBuffer; | 36 renderedData = event.renderedBuffer; |
38 promise.then(function (result) { | 37 promise.then(function (result) { |
39 promiseData = result; | 38 promiseData = result; |
40 compareData(); | 39 compareData(); |
41 }); | 40 }); |
42 | |
43 } | 41 } |
42 | |
44 // Create an offline context and verify that both the oncomplete and promi se are returned with | 43 // Create an offline context and verify that both the oncomplete and promi se are returned with |
45 // the same stuff. | 44 // the same stuff. |
46 function runTest() { | 45 function runTest() { |
47 window.jsTestIsAsync = true; | 46 window.jsTestIsAsync = true; |
48 | 47 |
49 context = new OfflineAudioContext(contextChannels, renderFrames, sampleR ate); | 48 context = new OfflineAudioContext(contextChannels, renderFrames, sampleR ate); |
50 | 49 |
51 var buffer = context.createBuffer(contextChannels, renderFrames, sampleR ate); | 50 var buffer = context.createBuffer(contextChannels, renderFrames, sampleR ate); |
52 for (var k = 0; k < renderFrames; ++k) { | 51 for (var k = 0; k < renderFrames; ++k) { |
53 buffer.getChannelData(0)[k] = 1; | 52 buffer.getChannelData(0)[k] = 1; |
(...skipping 10 matching lines...) Expand all Loading... | |
64 promise = context.startRendering(); | 63 promise = context.startRendering(); |
65 | 64 |
66 } | 65 } |
67 | 66 |
68 runTest(); | 67 runTest(); |
69 successfullyParsed = true; | 68 successfullyParsed = true; |
70 </script> | 69 </script> |
71 | 70 |
72 </body> | 71 </body> |
73 </html> | 72 </html> |
OLD | NEW |