Index: third_party/WebKit/LayoutTests/webaudio/AudioBufferSource/audiobuffersource-late-start.html |
diff --git a/third_party/WebKit/LayoutTests/webaudio/AudioBufferSource/audiobuffersource-late-start.html b/third_party/WebKit/LayoutTests/webaudio/AudioBufferSource/audiobuffersource-late-start.html |
index 8c0cc40893e3d57c27b965adbed6e204114fe290..604a9d661a1e010dc28784181cbc4f97694ef76c 100644 |
--- a/third_party/WebKit/LayoutTests/webaudio/AudioBufferSource/audiobuffersource-late-start.html |
+++ b/third_party/WebKit/LayoutTests/webaudio/AudioBufferSource/audiobuffersource-late-start.html |
@@ -1,81 +1,84 @@ |
<!DOCTYPE html> |
<html> |
+ <head> |
+ <title> |
+ audiobuffersource-late-start.html |
+ </title> |
+ <script src="../../resources/testharness.js"></script> |
+ <script src="../../resources/testharnessreport.js"></script> |
+ <script src="../resources/audit-util.js"></script> |
+ <script src="../resources/audit.js"></script> |
+ </head> |
+ <body> |
+ <script id="layout-test-code"> |
+ let renderQuantum = 128; |
-<head> |
- <script src="../../resources/testharness.js"></script> |
- <script src="../../resources/testharnessreport.js"></script> |
- <script src="../resources/audit-util.js"></script> |
- <script src="../resources/audit.js"></script> |
-</head> |
+ let sampleRate = 44100; |
+ let renderDuration = 0.25; |
+ let startTime = 0.5 * renderDuration; |
-<body> |
- <script> |
+ let audit = Audit.createTaskRunner(); |
- var renderQuantum = 128; |
+ // Calculate the index for actual start time. |
+ function getStartIndex(time) { |
+ let startIndex = time * sampleRate; |
+ return startIndex -= (startIndex) % renderQuantum; |
+ } |
- var sampleRate = 44100; |
- var renderDuration = 0.25; |
- var startTime = 0.5 * renderDuration; |
+ // Get the index of value change. |
+ function getValueChangeIndex(array, targetValue) { |
+ return array.findIndex(function(element, index) { |
+ if (element === targetValue) |
+ return true; |
+ }); |
+ } |
- var audit = Audit.createTaskRunner(); |
+ audit.define('test-late-start', (task, should) => { |
+ let context = |
+ new OfflineAudioContext(1, renderDuration * sampleRate, sampleRate); |
+ let dcOffsetbuffer = createConstantBuffer(context, 1, 1.0); |
+ let source = context.createBufferSource(); |
+ source.buffer = dcOffsetbuffer; |
+ source.loop = true; |
+ source.connect(context.destination); |
- // Calculate the index for actual start time. |
- function getStartIndex(time) { |
- var startIndex = time * sampleRate; |
- return startIndex -= (startIndex) % renderQuantum; |
- } |
+ // Schedule source.start(0) at 0.01 second. The specified timing of |
+ // start() call is already passed in terms of the context time. So the |
+ // argument |0| will be clamped to the current context time. |
+ // |
+ // With the sample rate of 44100, 0.01 second is 441 samples. Rounding |
+ // it down to the render quantum gives 384 samples. This is clearly |
+ // larger than a single render quantum. |
+ // |
+ // See issue: crbug.com/462167 |
+ context.suspend(startTime).then(function() { |
+ source.start(0); |
+ context.resume(); |
+ }); |
- // Get the index of value change. |
- function getValueChangeIndex(array, targetValue) { |
- return array.findIndex(function (element, index) { |
- if (element === targetValue) |
- return true; |
- }); |
- } |
- |
- audit.define('test-late-start', (task, should) => { |
- var context = new OfflineAudioContext(1, renderDuration * sampleRate, sampleRate); |
- var dcOffsetbuffer = createConstantBuffer(context, 1, 1.0); |
- var source = context.createBufferSource(); |
- source.buffer = dcOffsetbuffer; |
- source.loop = true; |
- source.connect(context.destination); |
- |
- // Schedule source.start(0) at 0.01 second. The specified timing of |
- // start() call is already passed in terms of the context time. So the |
- // argument |0| will be clamped to the current context time. |
- // |
- // With the sample rate of 44100, 0.01 second is 441 samples. Rounding |
- // it down to the render quantum gives 384 samples. This is clearly larger |
- // than a single render quantum. |
- // |
- // See issue: crbug.com/462167 |
- context.suspend(startTime).then(function () { |
- source.start(0); |
- context.resume(); |
- }); |
- |
- // Start rendering and verify result: this verifies if 1) the rendered |
- // buffer contains at least one non-zero value and 2) the non-zero value is |
- // found later than the first output sample. |
- context.startRendering().then(function (buffer) { |
+ // Start rendering and verify result: this verifies if 1) the rendered |
+ // buffer contains at least one non-zero value and 2) the non-zero value |
+ // is found later than the first output sample. |
+ context.startRendering() |
+ .then(function(buffer) { |
- var channelData = buffer.getChannelData(0); |
- var startIndex = getStartIndex(startTime); |
- var nonZeroValueIndex = getValueChangeIndex(channelData, 1.0); |
+ let channelData = buffer.getChannelData(0); |
+ let startIndex = getStartIndex(startTime); |
+ let nonZeroValueIndex = getValueChangeIndex(channelData, 1.0); |
- should(channelData, 'The output').containValues([0, 1]); |
- should(nonZeroValueIndex, 'The index of value change') |
- .beEqualTo(startIndex); |
+ should(channelData, 'The output').containValues([0, 1]); |
+ should(nonZeroValueIndex, 'The index of value change') |
+ .beEqualTo(startIndex); |
- should(nonZeroValueIndex, 'The index of the first non-zero sample') |
- .notBeEqualTo(0) |
- |
- }).then(() => task.done()); |
- }); |
+ should( |
+ nonZeroValueIndex, 'The index of the first non-zero sample') |
+ .notBeEqualTo(0) |
- audit.run(); |
- </script> |
-</body> |
+ }) |
+ .then(() => task.done()); |
+ }); |
+ audit.run(); |
+ </script> |
+ </body> |
</html> |