Chromium Code Reviews| Index: third_party/WebKit/LayoutTests/webaudio/AudioBufferSource/audiobuffersource.html |
| diff --git a/third_party/WebKit/LayoutTests/webaudio/AudioBufferSource/audiobuffersource.html b/third_party/WebKit/LayoutTests/webaudio/AudioBufferSource/audiobuffersource.html |
| index 27ca96f5ef5a54e1edf94df492f732adf325e7d2..1d725ee2d173d842fda7e17f943712c575906b26 100644 |
| --- a/third_party/WebKit/LayoutTests/webaudio/AudioBufferSource/audiobuffersource.html |
| +++ b/third_party/WebKit/LayoutTests/webaudio/AudioBufferSource/audiobuffersource.html |
| @@ -6,49 +6,59 @@ See if we can load an AudioBuffer, create an AudioBufferSourceNode, attach the b |
| <html> |
| <head> |
| -<script src="../../resources/js-test.js"></script> |
| +<script src="../../resources/testharness.js"></script> |
| +<script src="../../resources/testharnessreport.js"></script> |
| <script src="../resources/audit-util.js"></script> |
| -<script src="../resources/audio-testing.js"></script> |
| -<script type="text/javascript" src="../resources/buffer-loader.js"></script> |
| +<script src="../resources/audit.js"></script> |
| +<script src="../resources/buffer-loader.js"></script> |
| <script> |
| +let audit = Audit.createTaskRunner(); |
| -window.onload = init; |
| - |
| -var sampleRate = 44100.0; |
| -var lengthInSeconds = 2; |
| - |
| -var context = 0; |
| -var bufferLoader = 0; |
| - |
| -function init() { |
| - if (!window.testRunner) |
| - return; |
| - |
| - // Create offline audio context. |
| - context = new OfflineAudioContext(2, sampleRate * lengthInSeconds, sampleRate); |
| - |
| - bufferLoader = new BufferLoader( |
| - context, |
| - [ |
| - "../resources/hyper-reality/br-jam-loop.wav", |
| - ], |
| - finishedLoading |
| - ); |
| - |
| - bufferLoader.load(); |
| - testRunner.waitUntilDone(); |
| -} |
| +let sampleRate = 44100.0; |
| +let lengthInSeconds = 2; |
| + |
| +let context = 0; |
| +let bufferLoader = 0; |
| + |
| +// Note: The text output from this test is ignored. The test will generate |
| +// output WAV file that is compared to the expected file and these two should |
| +// match exactly. |
| +audit.define('test', (task, should) => { |
| + // This test requires testRunner to exist |
| + should(window.testRunner, 'window.testRunner').notBeEqualTo(undefined); |
| + |
| + // Create offline audio context. |
| + context = |
| + new OfflineAudioContext(2, sampleRate * lengthInSeconds, sampleRate); |
| + |
| + bufferLoader = new BufferLoader( |
|
hongchan
2017/02/27 18:05:35
Can this be replaced with Audit.loadFileFromURL()?
Raymond Toy
2017/02/27 18:48:08
Done.
|
| + context, |
| + [ |
| + '../resources/hyper-reality/br-jam-loop.wav', |
| + ], |
| + bufferList => { |
| + finishedLoading(bufferList, task, should); |
| + }); |
| + |
| + bufferLoader.load(); |
| + testRunner.waitUntilDone(); |
| +}); |
| + |
| +audit.run(); |
| + |
| +function finishedLoading(bufferList, task, should) { |
| + let bufferSource = context.createBufferSource(); |
| + bufferSource.buffer = bufferList[0]; |
| + |
| + bufferSource.connect(context.destination); |
| + bufferSource.start(0); |
| -function finishedLoading(bufferList) { |
| - var bufferSource = context.createBufferSource(); |
| - bufferSource.buffer = bufferList[0]; |
| - |
| - bufferSource.connect(context.destination); |
| - bufferSource.start(0); |
| - |
| - context.oncomplete = finishAudioTest; |
| - context.startRendering(); |
| + context.oncomplete = (event) => { |
|
hongchan
2017/02/27 18:05:35
Use promise?
|
| + finishAudioTest(event); |
| + task.done(); |
| + }; |
| + context.startRendering(); |
| } |
| </script> |