Index: LayoutTests/webaudio/offlineaudiocontext-suspend-resume-eventhandler.html |
diff --git a/LayoutTests/webaudio/offlineaudiocontext-suspend-resume-eventhandler.html b/LayoutTests/webaudio/offlineaudiocontext-suspend-resume-eventhandler.html |
new file mode 100644 |
index 0000000000000000000000000000000000000000..66c4f1f9ca3af104d55eac40467c4aa2b4d7fae5 |
--- /dev/null |
+++ b/LayoutTests/webaudio/offlineaudiocontext-suspend-resume-eventhandler.html |
@@ -0,0 +1,56 @@ |
+<!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('Test event handler callback from OfflineAudioContext resume/suspend.'); |
+ window.jsTestIsAsync = true; |
+ |
+ var context; |
+ var sampleRate = 44100; |
+ var renderDuration = 2; |
+ var renderQuantum = 128; |
+ var scheduledSuspendTime = 0.1; |
Raymond Toy
2015/05/28 16:37:34
I think you should compute scheduledSuspendTime fr
hongchan
2015/06/09 20:49:58
It should not matter, I believe. It should do what
|
+ |
+ // Get the time quantized by render quantum size. |
+ function quantizeByRenderQuantum(time) { |
+ var samples = time * sampleRate; |
+ return (samples - (samples % renderQuantum)) / sampleRate; |
+ } |
+ |
+ function runTest() { |
+ context = new OfflineAudioContext(1, sampleRate * renderDuration, sampleRate); |
+ |
+ context.onstatechange = function () { |
+ if (context.state === 'suspended') { |
+ Should('context.currentTime', context.currentTime) |
+ .beEqualTo(quantizeByRenderQuantum(scheduledSuspendTime)); |
+ |
+ // When context.currentTime 0.1 > renderDuration, the promise should |
Raymond Toy
2015/05/28 16:37:34
"currentTime 0.1"?
hongchan
2015/06/09 20:49:58
Oops. This should read |context.currentTime + 0.1
|
+ // be rejected and throw an exception. |
+ scheduledSuspendTime = context.currentTime + 0.1; |
Raymond Toy
2015/05/28 16:37:34
This delta of 0.1 should also be computed so that
hongchan
2015/06/09 20:49:58
I don't think it matters as the comment above.
|
+ context.suspend(scheduledSuspendTime); |
+ context.resume(); |
+ } |
+ }; |
+ |
+ context.oncomplete = function () { |
+ Should('context.state', context.state).beEqualTo('closed'); |
+ finishJSTest(); |
+ }; |
+ |
+ context.suspend(scheduledSuspendTime); |
+ context.startRendering(); |
Raymond Toy
2015/05/28 16:37:34
If you really want to use oncomplete instead of a
hongchan
2015/06/09 20:49:58
This test is about testing all event handlers are
|
+ } |
+ |
+ runTest(); |
+ successfullyParsed = true; |
+ </script> |
+ |
+ </body> |
+</html> |