Chromium Code Reviews| Index: third_party/WebKit/LayoutTests/webaudio/OfflineAudioContext/onstatechange.html |
| diff --git a/third_party/WebKit/LayoutTests/webaudio/OfflineAudioContext/onstatechange.html b/third_party/WebKit/LayoutTests/webaudio/OfflineAudioContext/onstatechange.html |
| index 4e20b77ff3d7ca1470146d98d4606b16ad2cf85b..fbc7ec771dd6feaff9d87f00a0745e6b940999eb 100644 |
| --- a/third_party/WebKit/LayoutTests/webaudio/OfflineAudioContext/onstatechange.html |
| +++ b/third_party/WebKit/LayoutTests/webaudio/OfflineAudioContext/onstatechange.html |
| @@ -2,17 +2,15 @@ |
| <html> |
| <head> |
| <title>Test statechange event</title> |
| - <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 statechange event is properly signaled") |
| - |
| - window.jsTestIsAsync = true; |
| - |
| + var audit = Audit.createTaskRunner(); |
| var secondsToRender = 2; |
| var sampleRate = 48000; |
| @@ -20,30 +18,35 @@ |
| var context; |
| var contextState; |
| - function checkStateChange (e) { |
| + function checkStateChange (e, should) { |
| contextState = e.currentTarget.state; |
| switch (stateChangeCount) { |
| case 0: |
| - shouldBeEqualToString("contextState", "running"); |
| + should(contextState, "context.state") |
| + .beEqualTo("running"); |
| break; |
| case 1: |
| - shouldBeEqualToString("contextState", "closed"); |
| + should(contextState, "context.state") |
| + .beEqualTo("closed"); |
| break; |
| default: |
| - testFailed("Expected only two state changes but got " + stateChangeCount); |
| + should(stateChangeCount, "Number of state changes") |
| + .beLessThanOrEqualTo(2) |
| } |
| ++stateChangeCount; |
| } |
| - function finalCheck() { |
| + function finalCheck(should) { |
| // Final check that we got the right number of state changes and the correct final state. |
| - shouldBeEqualToNumber("stateChangeCount", 2); |
| - shouldBeEqualToString("context.state", "closed"); |
| - finishJSTest(); |
| + should(stateChangeCount, "stateChangeCount") |
| + .beEqualTo(2); |
| + should(context.state, "context.state") |
| + .beEqualTo("closed"); |
| } |
| - function runTest() { |
| + audit.define('test', (task, should) => { |
| + task.describe('Signaling of statechange event'); |
| // Create an offline context with a source passing through a convolver. The convolver is |
| // just to waste some time. |
| context = new OfflineAudioContext(1, secondsToRender * sampleRate, sampleRate); |
| @@ -60,20 +63,22 @@ |
| source.start(); |
| - context.onstatechange = checkStateChange; |
| + context.onstatechange = (e) => checkStateChange(e, should); |
|
hongchan
2017/02/07 18:38:43
(event)
Raymond Toy
2017/02/07 19:11:10
Done.
|
| - context.startRendering().then(function () { |
| - testPassed("context finished rendering") |
| - }); |
| + should(context.startRendering(), "Context rendering") |
| + .beResolved(); |
| // Don't want to set an oncomplete for the context and don't want to use the promise because |
| // the order of the state change event and resolving the promise is not specified. Thus, |
| // just wait for a bit and then finish the test. We assume the offline context runs faster |
| // than realtime. |
| - setTimeout(finalCheck, secondsToRender * 1000); |
| - } |
| + setTimeout(() => { |
| + finalCheck(should); |
| + task.done(); |
| + }, secondsToRender * 1000); |
| + }); |
| - runTest(); |
| + audit.run(); |
| </script> |
| </body> |
| </html> |