| Index: third_party/WebKit/LayoutTests/webaudio/AudioContext/audiocontext-suspend-resume.html
|
| diff --git a/third_party/WebKit/LayoutTests/webaudio/AudioContext/audiocontext-suspend-resume.html b/third_party/WebKit/LayoutTests/webaudio/AudioContext/audiocontext-suspend-resume.html
|
| index 037d2b801a7605d83c04c4923b3b16c87fc7513e..9bd1a7da5649d883fd82579bac81c6783672d213 100644
|
| --- a/third_party/WebKit/LayoutTests/webaudio/AudioContext/audiocontext-suspend-resume.html
|
| +++ b/third_party/WebKit/LayoutTests/webaudio/AudioContext/audiocontext-suspend-resume.html
|
| @@ -2,150 +2,116 @@
|
| <html>
|
| <head>
|
| <title>Test AudioContext.suspend() and AudioContext.resume()</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 suspend/resume for an (offline) AudioContext");
|
| - window.jsTestIsAsync = true;
|
| + let offlineContext;
|
| + let osc;
|
| + let p1;
|
| + let p2;
|
| + let p3;
|
|
|
| - var offlineContext;
|
| - var osc;
|
| - var p1;
|
| - var p2;
|
| - var p3;
|
| + let sampleRate = 44100;
|
| + let durationInSeconds = 1;
|
|
|
| - var sampleRate = 44100;
|
| - var durationInSeconds = 1;
|
| -
|
| - var audit = Audit.createTaskRunner();
|
| -
|
| - // Convenience function that returns a function that calls the |passFailFunc|
|
| - // with the given |message|. The |passFailFunc| should be either |testPassed|
|
| - // or |testFailed|.
|
| - function handlePromise(passFailFunc, message) {
|
| - return function () {
|
| - passFailFunc(message);
|
| - };
|
| - }
|
| + let audit = Audit.createTaskRunner();
|
|
|
| // Task: test suspend().
|
| - audit.defineTask('test-suspend', function (done) {
|
| -
|
| - // Test suspend/resume. Ideally this test is best with a online
|
| - // AudioContext, but content shell doesn't really have a working online
|
| - // AudioContext. Hence, use an OfflineAudioContext. Not all possible
|
| - // scenarios can be easily checked with an offline context instead of an
|
| + audit.define('test-suspend', function (task, should) {
|
| + task.describe("Test suspend() for offline context");
|
| + // Test suspend/resume. Ideally this test is best with a online
|
| + // AudioContext, but content shell doesn't really have a working online
|
| + // AudioContext. Hence, use an OfflineAudioContext. Not all possible
|
| + // scenarios can be easily checked with an offline context instead of an
|
| // online context.
|
|
|
| // Create an audio context with an oscillator.
|
| - shouldNotThrow("offlineContext = new OfflineAudioContext(1, durationInSeconds * sampleRate, sampleRate)");
|
| + should(() => {
|
| + offlineContext = new OfflineAudioContext(1, durationInSeconds *
|
| + sampleRate, sampleRate);
|
| + },
|
| + "offlineContext = new OfflineAudioContext(1, " + (
|
| + durationInSeconds *
|
| + sampleRate) + ", " + sampleRate + ")"
|
| + )
|
| + .notThrow();
|
| osc = offlineContext.createOscillator();
|
| osc.connect(offlineContext.destination);
|
|
|
| // Verify the state.
|
| - shouldBeEqualToString("offlineContext.state", "suspended");
|
| + should(offlineContext.state, "offlineContext.state")
|
| + .beEqualTo("suspended");
|
|
|
| // Multiple calls to suspend() should not be a problem. But we can't test
|
| // that on an offline context. Thus, check that suspend() on an
|
| // OfflineAudioContext rejects the promise.
|
| - shouldNotThrow("p1 = offlineContext.suspend()");
|
| - shouldBeType("p1", "Promise");
|
| - p1.then(
|
| - handlePromise(testFailed, "offlineContext.suspend() should have been rejected for an offline context"),
|
| - function (e) {
|
| - if (e.name === "TypeError") {
|
| - testPassed(
|
| - "offlineContext.suspend() was correctly rejected: " + e);
|
| - } else {
|
| - testFailed(
|
| - "offlineContext.suspend() was correctly rejected but expected TypeError, not: " + e);
|
| - }
|
| - }
|
| - ).then(done);
|
| + should(() => p1 = offlineContext.suspend(),
|
| + "p1 = offlineContext.suspend()")
|
| + .notThrow();
|
| + should(p1 instanceof Promise, "p1 instanceof Promise")
|
| + .beTrue();
|
| +
|
| + should(p1, "p1")
|
| + .beRejected()
|
| + .then(task.done.bind(task));
|
| });
|
|
|
|
|
| // Task: test resume().
|
| - audit.defineTask('test-resume', function (done) {
|
| -
|
| + audit.define('test-resume', function (task, should) {
|
| + task.describe("Test resume() for offline context");
|
| // Multiple calls to resume should not be a problem. But we can't test
|
| // that on an offline context. Thus, check that resume() on an
|
| // OfflineAudioContext rejects the promise.
|
| - shouldNotThrow("p2 = offlineContext.resume()");
|
| - shouldBeType("p2", "Promise");
|
| -
|
| + should(() => p2 = offlineContext.resume(),
|
| + "p2 = offlineContext.resume()")
|
| + .notThrow();
|
| + should(p2 instanceof Promise, "p2 instanceof Promise")
|
| + .beTrue();
|
| +
|
| // Resume doesn't actually resume an offline context
|
| - shouldBeEqualToString("offlineContext.state", "suspended");
|
| - p2.then(
|
| - handlePromise(testFailed, "offlineContext.resume() should have been rejected for an offline context"),
|
| - function (e) {
|
| - if (e.name === "InvalidStateError") {
|
| - testPassed(
|
| - "offlineContext.resume() was correctly rejected: " + e);
|
| - } else {
|
| - testFailed(
|
| - "offlineContext.resume() was correctly rejected but expected InvalidAccessError, not: " + e);
|
| - }
|
| - }
|
| - ).then(done);
|
| + should(offlineContext.state, "offlineContext.state")
|
| + .beEqualTo("suspended");
|
| + should(p2, "p2")
|
| + .beRejected()
|
| + .then(task.done.bind(task));
|
| });
|
|
|
| // Task: test the state after context closed.
|
| - audit.defineTask('test-after-close', function (done) {
|
| -
|
| + audit.define('test-after-close', function (task, should) {
|
| + task.describe("Test state after context closed");
|
| // Render the offline context.
|
| osc.start();
|
|
|
| // Test suspend/resume in tested promise pattern. We don't care about the
|
| // actual result of the offline rendering.
|
| - shouldNotThrow("p3 = offlineContext.startRendering()");
|
| - p3.then(function () {
|
| - shouldBeEqualToString("offlineContext.state", "closed");
|
| + should(() => p3 = offlineContext.startRendering(),
|
| + "p3 = offlineContext.startRendering()")
|
| + .notThrow();
|
|
|
| - // suspend() should be rejected on a closed context.
|
| - offlineContext.suspend().then(
|
| - handlePromise(testFailed, "offlineContext.suspend() on a closed context not rejected"),
|
| - function (e) {
|
| - if (e.name === "TypeError") {
|
| - testPassed("offlineContext.suspend() on a closed context rejected: " + e);
|
| - } else {
|
| - testFailed("offlineContext.suspend() on a closed context rejected but expected TypeError, not: " + e);
|
| - }
|
| - }
|
| - ).then(function () {
|
| - // resume() should be rejected on closed context.
|
| - offlineContext.resume().then(
|
| - handlePromise(testFailed, "offlineContext.resume() on a closed context not rejected"),
|
| - function (e) {
|
| - if (e.name === "InvalidStateError") {
|
| - testPassed("offlineContext.resume() on a closed context rejected: " + e);
|
| - } else {
|
| - testFailed("offlineContext.resume() on a closed context rejected but expected InvalidStateError, not: " + e);
|
| - }
|
| - }
|
| - ).then(done);
|
| - });
|
| + p3.then(() => {
|
| + should(offlineContext.state, "offlineContext.state")
|
| + .beEqualTo("closed");
|
|
|
| + // suspend() should be rejected on a closed context.
|
| + should(offlineContext.suspend(), "offlineContext.suspend()")
|
| + .beRejected()
|
| + .then(() => {
|
| + // resume() should be rejected on closed context.
|
| + should(offlineContext.resume(),
|
| + "offlineContext.resume()")
|
| + .beRejected()
|
| + .then(task.done.bind(task));
|
| + })
|
| });
|
| });
|
|
|
| - audit.defineTask('finish-test', function (done) {
|
| - done();
|
| - finishJSTest();
|
| - });
|
| -
|
| - audit.runTasks(
|
| - 'test-suspend',
|
| - 'test-resume',
|
| - 'test-after-close',
|
| - 'finish-test'
|
| - );
|
| -
|
| - successfullyParsed = true;
|
| + audit.run();
|
| </script>
|
| </body>
|
| </html>
|
|
|