Chromium Code Reviews| Index: third_party/WebKit/LayoutTests/webaudio/OfflineAudioContext/offlineaudiocontext-suspend-resume-promise.html |
| diff --git a/third_party/WebKit/LayoutTests/webaudio/OfflineAudioContext/offlineaudiocontext-suspend-resume-promise.html b/third_party/WebKit/LayoutTests/webaudio/OfflineAudioContext/offlineaudiocontext-suspend-resume-promise.html |
| index b02df2e7ab7f5449373ae131644b0f3b6a9753fb..ad04b9bcf0b2b664c4de5fd0f2d0d3e714a6e7d9 100644 |
| --- a/third_party/WebKit/LayoutTests/webaudio/OfflineAudioContext/offlineaudiocontext-suspend-resume-promise.html |
| +++ b/third_party/WebKit/LayoutTests/webaudio/OfflineAudioContext/offlineaudiocontext-suspend-resume-promise.html |
| @@ -1,16 +1,15 @@ |
| <!doctype html> |
| <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 src="../resources/audit.js"></script> |
| </head> |
| <body> |
| <script> |
| - description('Test promise resolution of OfflineAudioContext.resume() and OfflineAudioContext.suspend().'); |
| - window.jsTestIsAsync = true; |
| - |
| + var audit = Audit.createTaskRunner(); |
| var context; |
| // The sample rate is multiple of the rendering quantum, so suspension |
| @@ -25,43 +24,57 @@ |
| // in to the render quantum boundary. |
| var suspendInterval = 0.25; |
| - context = new OfflineAudioContext(1, sampleRate * renderDuration, sampleRate); |
| - |
| - function onSuspended() { |
| - if (context.state === 'suspended' && context.currentTime === scheduledSuspendTime) { |
| - |
| - testPassed('suspend promise resolved: context is suspended at ' + |
| - scheduledSuspendTime + ' second(s).'); |
| + function onSuspended(should) { |
| + if (context.state === 'suspended' && context.currentTime === |
| + scheduledSuspendTime) { |
|
hongchan
2017/02/07 18:38:43
I find this line break is weird. This should be:
Raymond Toy
2017/02/07 19:11:10
js-(un)beautify. I'll reindent this with clang-fo
|
| + should(context.state === 'suspended' && context.currentTime === |
| + scheduledSuspendTime, |
|
hongchan
2017/02/07 18:38:43
Ditto.
|
| + 'Context suspended at ' + scheduledSuspendTime + ' second(s)') |
| + .beTrue(); |
| scheduledSuspendTime = context.currentTime + suspendInterval; |
| // Scheduling a suspend before the render duration should pass. |
| if (scheduledSuspendTime < renderDuration) { |
| - context.suspend(scheduledSuspendTime).then(onSuspended); |
| - testPassed('A new suspend has been scheduled at ' + |
| - scheduledSuspendTime + ' second(s).'); |
| + should(() => context.suspend(scheduledSuspendTime).then(() => |
| + onSuspended(should)), |
| + 'Scheduling a new suspend at ' + |
| + scheduledSuspendTime + ' second(s)') |
| + .notThrow(); |
| } |
| // Scheduling a suspend exactly at the render duration should be |
| // rejected. |
| if (scheduledSuspendTime === renderDuration) { |
| - Should('Scheduling at ' + renderDuration + ' seconds', |
| - context.suspend(scheduledSuspendTime)).beRejected(); |
| + should(context.suspend(scheduledSuspendTime), |
| + 'Scheduling at ' + renderDuration + ' seconds' |
| + ).beRejected(); |
| } |
| - context.resume(); |
| + context.resume(); |
| } |
| } |
| - // Schedule the first suspension. |
| - context.suspend(scheduledSuspendTime).then(onSuspended); |
| - testPassed('A new suspend has been scheduled at ' + scheduledSuspendTime + ' second(s).'); |
| - |
| - context.startRendering().then(function () { |
| - Should('Promise context.state', context.state).beEqualTo('closed'); |
| - }).then(finishJSTest); |
| - |
| - successfullyParsed = true; |
| + audit.define('test', (task, should) => { |
| + task.describe('Promise resolution of resume() and suspend()'); |
| + context = new OfflineAudioContext(1, sampleRate * renderDuration, |
| + sampleRate); |
| + |
| + // Schedule the first suspension. |
| + should(() => context.suspend(scheduledSuspendTime) |
| + .then(() => |
| + onSuspended(should)), |
| + 'Scheduling a new suspend at ' + scheduledSuspendTime + |
| + ' second(s)') |
| + .notThrow(); |
| + |
| + context.startRendering().then(function () { |
| + should(context.state, 'Promise context.state') |
| + .beEqualTo('closed'); |
| + }).then(() => task.done()); |
| + }); |
| + |
| + audit.run(); |
| </script> |
| </body> |