Index: LayoutTests/webaudio/offlineaudiocontext-suspend-resume-basic.html |
diff --git a/LayoutTests/webaudio/offlineaudiocontext-suspend-resume-basic.html b/LayoutTests/webaudio/offlineaudiocontext-suspend-resume-basic.html |
new file mode 100644 |
index 0000000000000000000000000000000000000000..4bbc4313449b0891fdbd5dc65c723f762a51be1a |
--- /dev/null |
+++ b/LayoutTests/webaudio/offlineaudiocontext-suspend-resume-basic.html |
@@ -0,0 +1,76 @@ |
+<!doctype html> |
+<html> |
+ <head> |
+ <script src="../resources/js-test.js"></script> |
+ <script src="resources/compatibility.js"></script> |
+ <script src="resources/audio-testing.js"></script> |
+ </head> |
+ |
+ <body> |
+ <script> |
+ description('Suspending OfflineAudioContext at the same rendering block boundary.'); |
+ window.jsTestIsAsync = true; |
+ |
+ var sampleRate = 44100; |
+ var renderDuration = 1; |
+ var renderQuantum = 128; |
+ |
+ var audit = Audit.createTaskRunner(); |
+ |
+ // Task: Calling suspend with no argument should reject the promise. |
+ audit.defineTask('suspend-no-argument', function (done) { |
+ var context = new OfflineAudioContext(1, sampleRate * renderDuration, sampleRate); |
+ |
+ Should('context.suspend()', context.suspend()).beRejected().then(done); |
+ }); |
+ |
+ // Task: Calling multiple suspends at the same rendering quantum should reject |
+ // the promise. |
+ audit.defineTask('identical-suspend-time', function (done) { |
+ var context = new OfflineAudioContext(1, sampleRate * renderDuration, sampleRate); |
+ var suspendTime1 = renderQuantum / sampleRate; |
+ var suspendTime2 = (renderQuantum + renderQuantum * 0.5) / sampleRate; |
+ |
+ context.suspend(suspendTime1); |
+ |
+ Should('Calling multiple suspends at the same rendering quantum', |
+ context.suspend(suspendTime2)).beRejected().then(done); |
+ }); |
+ |
+ // Task: Resuming the context before the actual suspension happens. |
+ audit.defineTask('resume-before-suspend', function (done) { |
+ var context = new OfflineAudioContext(1, sampleRate * renderDuration, sampleRate); |
+ |
+ // Note that suspend is scheduled at 0.5 (after quantizing), but the resume() |
+ // in the next will be executed immediately after. |
+ context.suspend(0.5); |
+ |
+ Should('Resuming before suspend', context.resume()).beRejected().then(done); |
+ }); |
+ |
+ // Task: Calling resume on non-suspended context should reject the promise. |
+ audit.defineTask('resume-without-suspend', function (done) { |
+ var context = new OfflineAudioContext(1, sampleRate * renderDuration, sampleRate); |
+ |
+ Should('Calling resume on non-suspended context', context.resume()) |
+ .beRejected().then(done); |
+ }); |
+ |
+ audit.defineTask('finish', function (done) { |
+ finishJSTest(); |
+ done(); |
+ }); |
+ |
+ audit.runTasks( |
+ 'suspend-no-argument', |
+ 'identical-suspend-time', |
+ 'resume-before-suspend', |
+ 'resume-without-suspend', |
+ 'finish' |
+ ); |
+ |
+ successfullyParsed = true; |
+ </script> |
+ |
+ </body> |
+</html> |