Chromium Code Reviews| Index: third_party/WebKit/LayoutTests/webaudio/AudioContext/audiocontext-close.html |
| diff --git a/third_party/WebKit/LayoutTests/webaudio/AudioContext/audiocontext-close.html b/third_party/WebKit/LayoutTests/webaudio/AudioContext/audiocontext-close.html |
| index c97ef2c97e777fb3a5a2cd8a946b9d0de9d7cd47..af48b01f889167b0bc40e656572ec5bdd29d3f3b 100644 |
| --- a/third_party/WebKit/LayoutTests/webaudio/AudioContext/audiocontext-close.html |
| +++ b/third_party/WebKit/LayoutTests/webaudio/AudioContext/audiocontext-close.html |
| @@ -2,133 +2,188 @@ |
| <html> |
| <head> |
| <title>Test AudioContext.close()</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("Basic functionality test of closing an AudioContext"); |
| - window.jsTestIsAsync = true; |
| + let context; |
| + let destination; |
| + let offline; |
| + let osc; |
| + let gain; |
| + let offlinePromise; |
| + let wave = new Float32Array(1); |
| - var context; |
| - var destination; |
| - var offline; |
| - var osc; |
| - var gain; |
| - var promise1; |
| - var promise2; |
| - var offlinePromise; |
| - var wave = new Float32Array(1); |
| - |
| - var audit = Audit.createTaskRunner(); |
| + let audit = Audit.createTaskRunner(); |
| // Task: test online context (1). |
| - audit.defineTask('test-online-context-1', function (done) { |
| - |
| + audit.define('test-online-context-1', function (task, should) { |
| + task.describe("Test online context 1"); |
| // Create a context and verify that the various states are correct and |
| // that close() exists. |
| - shouldNotThrow("context = new AudioContext()"); |
| - shouldBeEqualToString("context.state", "running"); |
| + should(function () { |
| + context = new AudioContext(); |
| + }, "context = new AudioContext()") |
| + .notThrow();; |
|
hongchan
2017/01/20 23:08:41
Two semicolons.
Raymond Toy
2017/01/23 19:24:59
Done.
|
| + should(context.state, "context.state") |
| + .beEqualTo("running"); |
| // Create gain and oscillator for testing later. |
| - shouldNotThrow("osc = context.createOscillator()"); |
| - shouldNotThrow("gain = context.createGain()"); |
| + should(function () { |
|
hongchan
2017/01/20 23:08:41
Let's use () => {} notation.
Raymond Toy
2017/01/23 19:24:59
Done.
|
| + osc = context.createOscillator() |
| + }, "osc = context.createOscillator()") |
| + .notThrow(); |
| + should(function () { |
| + gain = context.createGain(); |
| + }, "gain = context.createGain()") |
| + .notThrow(); |
| destination = context.destination; |
| - shouldNotThrow("gain.connect(context.destination)"); |
| + should(function () { |
| + gain.connect(context.destination); |
| + }, "gain.connect(context.destination)") |
| + .notThrow(""); |
| // Close the context. When the promise is resolved, continue the next |
| // test task. |
| - context.close().then( |
| - function () { |
| - testPassed("context.close() was correctly resolved"); |
| - shouldNotThrow("gain.disconnect(destination)"); |
| - }, |
| - function () { |
| - testFailed("context.close() was erroneously rejected"); |
| - } |
| - ).then(done); |
| - |
| + should(context.close().then(function () { |
| + should(function () { |
| + gain.disconnect(destination) |
| + }, "gain.disconnect(destination) after close") |
| + .notThrow(); |
| + }), "context.close()") |
| + .beResolved() |
| + .then(task.done.bind(this)); |
| }); |
| // Task: test online context (2). |
| - audit.defineTask('test-online-context-2', function (done) { |
| - |
| + audit.define('test-online-context-2', function (task, should) { |
| + task.describe("Test closed online context 2"); |
| // Context is closed, so verify that we cannot create any more nodes, |
| // nor connect any. |
| - shouldThrow("context.createAnalyser()"); |
| - shouldThrow("context.createBiquadFilter()"); |
| + should(function () { |
| + context.createAnalyser(); |
| + }, "context.createAnalyser()") |
| + .throw("InvalidStateError"); |
| + should(function () { |
| + context.createBiquadFilter(); |
| + }, "context.createBiquadFilter()") |
| + .throw("InvalidStateError"); |
| // createBuffer is an exception because it's not really tied in any way |
| // to an audio context. And it's useful to be able to create a buffer |
| // inside the oncomplete event of an offline context to use for testing |
| // purposes. |
| - shouldNotThrow("context.createBuffer(1, 1, 48000)"); |
| - |
| - shouldThrow("context.createBufferSource()"); |
| - shouldThrow("context.createChannelMerger()"); |
| - shouldThrow("context.createChannelSplitter()"); |
| - shouldThrow("context.createConvolver()"); |
| - shouldThrow("context.createDelay()"); |
| - shouldThrow("context.createDynamicsCompressor()"); |
| - shouldThrow("context.createGain()"); |
| - shouldThrow("context.createOscillator()"); |
| - shouldThrow("context.createPanner()"); |
| - shouldThrow("context.createPeriodicWave(wave, wave)"); |
| - shouldThrow("context.createScriptProcessor()"); |
| - shouldThrow("context.createStereoPanner()"); |
| - shouldThrow("context.createWaveShaper()"); |
| - |
| - shouldThrow("osc.connect(gain)"); |
| - shouldNotThrow("gain.disconnect()"); |
| + should(function () { |
| + context.createBuffer(1, 1, 48000); |
| + }, "context.createBuffer(1, 1, 48000)") |
| + .notThrow(); |
| + |
| + should(function () { |
| + context.createBufferSource(); |
| + }, "context.createBufferSource()") |
| + .throw("InvalidStateError"); |
| + should(function () { |
| + context.createChannelMerger(); |
| + }, "context.createChannelMerger()") |
| + .throw("InvalidStateError"); |
| + should(function () { |
| + context.createChannelSplitter(); |
| + }, "context.createChannelSplitter()") |
| + .throw("InvalidStateError"); |
| + should(function () { |
| + context.createConvolver(); |
| + }, "context.createConvolver()") |
| + .throw("InvalidStateError"); |
| + should(function () { |
| + context.createDelay(); |
| + }, "context.createDelay()") |
| + .throw("InvalidStateError"); |
| + should(function () { |
| + context.createDynamicsCompressor(); |
| + }, "context.createDynamicsCompressor()") |
| + .throw("InvalidStateError"); |
| + should(function () { |
| + context.createGain(); |
| + }, "context.createGain()") |
| + .throw("InvalidStateError"); |
| + should(function () { |
| + context.createOscillator(); |
| + }, "context.createOscillator()") |
| + .throw("InvalidStateError"); |
| + should(function () { |
| + context.createPanner(); |
| + }, "context.createPanner()") |
| + .throw("InvalidStateError"); |
| + should(function () { |
| + context.createPeriodicWave(wave, wave); |
| + }, "context.createPeriodicWave(wave, wave)") |
| + .throw( |
|
hongchan
2017/01/20 23:08:41
No line break needed.
Raymond Toy
2017/01/23 19:24:59
Done.
|
| + "InvalidStateError"); |
| + should(function () { |
| + context.createScriptProcessor(); |
| + }, "context.createScriptProcessor()") |
| + .throw("InvalidStateError"); |
| + should(function () { |
| + context.createStereoPanner(); |
| + }, "context.createStereoPanner()") |
| + .throw("InvalidStateError"); |
| + should(function () { |
| + context.createWaveShaper(); |
| + }, "context.createWaveShaper()") |
| + .throw("InvalidStateError"); |
| + |
| + should(function () { |
| + osc.connect(gain); |
| + }, "osc.connect(gain)") |
| + .throw("InvalidStateError"); |
| + should(function () { |
| + gain.disconnect(); |
| + }, "gain.disconnect()").notThrow(); |
| // Can't resume a context that is closed (released). |
| - context.resume().then( |
| - function () { |
| - testFailed("Attempt to resume a closed context erroneously succeeded"); |
| - }, |
| - function () { |
| - testPassed("Attempt to resume a closed context was correctly rejected"); |
| - } |
| - ).then(done); |
| + should(context.resume(), "context.resume()") |
| + .beRejected() |
| + .then(task.done.bind(task)); |
| }); |
| - // Task: test online context (3). |
| - audit.defineTask('test-online-context-3', function (done) { |
|
hongchan
2017/01/20 23:08:41
An extra line added here.
Raymond Toy
2017/01/23 19:24:59
Done.
|
| + // Task: test online context (3). |
| + audit.define('test-online-context-3', function (task, should) { |
| + task.describe("Close an online context again"); |
| // Try closing the context again. The promise should be rejected. |
| - context.close().then( |
| - function () { |
| - testFailed("Closing context again erroneously resolved successfully."); |
| - }, |
| - function () { |
| - testPassed("Closing context again correctly rejected promise."); |
| - // Finally, run GC. The context should be gone, but this seems difficult to verify. |
| - gc(); |
| - shouldBeNull("context.destination"); |
| - } |
| - ).then(done); |
| + should(context.close(), "context.close() again") |
| + .beRejected() |
| + .then(function () { |
| + // Finally, run GC. The context should be gone, but this seems |
| + // difficult to verify. |
| + if (window.gc) |
| + gc(); |
| + should(context.destination, "context.destination") |
| + .beEqualTo(null); |
| + }) |
| + .then(task.done.bind(task)); |
| }); |
| // Task: test offline context (1). |
| - audit.defineTask('test-offline-context-1', function (done) { |
| - |
| + audit.define('test-offline-context-1', function (task, should) { |
| + task.describe("Test offline context"); |
| // For an offline context, verify that close is not defined. |
| - shouldNotThrow("offline = new OfflineAudioContext(1, 1000, 48000)"); |
| - shouldBeEqualToString("offline.state", "suspended"); |
| - shouldBeUndefined("offline.close"); |
| - done(); |
| + should(function () { |
| + offline = new OfflineAudioContext(1, 1000, 48000); |
| + }, "offline = new OfflineAudioContext(1, 1000, 48000)") |
| + .notThrow(); |
| + should(offline.state, "offline.state") |
| + .beEqualTo("suspended"); |
| + should(offline.close, "offline.close") |
| + .beEqualTo(undefined); |
| + task.done(); |
| }); |
| - audit.defineTask('finish-test', function (done) { |
| - done(); |
| - finishJSTest(); |
| - }); |
| - |
| - audit.runTasks(); |
| - |
| - successfullyParsed = true; |
| + audit.run(); |
| </script> |
| </body> |
| </html> |