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..e5ab096bc77ee5ee75bc1730b41c9e5d39e352b2 |
--- /dev/null |
+++ b/LayoutTests/webaudio/offlineaudiocontext-suspend-resume-eventhandler.html |
@@ -0,0 +1,69 @@ |
+<!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 renderQuantumDur = 128 / sampleRate; |
+ |
+ var suspendCount = 0; |
+ var expectedSuspendTime = [ |
+ 0.09868480725623582, |
+ 0.19736961451247165, |
+ 0.2960544217687075, |
+ 0.3947392290249433, |
+ 0.49342403628117915, |
+ 0.592108843537415, |
+ 0.6907936507936508, |
+ 0.7894784580498866, |
+ 0.8881632653061224, |
+ 0.9868480725623583, |
+ 1.0855328798185941, |
+ 1.18421768707483, |
+ 1.2829024943310658, |
+ 1.3815873015873017, |
+ 1.4802721088435373, |
+ 1.5789569160997732, |
+ 1.677641723356009, |
+ 1.7763265306122449, |
+ 1.8750113378684807, |
+ 1.9736961451247166 |
+ ]; |
+ |
+ function runTest() { |
+ context = new OfflineAudioContext(1, sampleRate * renderDuration, sampleRate); |
+ |
+ context.onstatechange = function () { |
+ if (context.state === 'suspended') { |
+ Should('context.currentTime', context.currentTime) |
+ .beEqualTo(expectedSuspendTime[suspendCount++]); |
+ context.suspend(context.currentTime + 0.1); |
+ context.resume(); |
+ } |
+ }; |
+ |
+ context.oncomplete = function () { |
+ Should('context.state', context.state).beEqualTo('closed'); |
+ finishJSTest(); |
+ }; |
+ |
+ context.suspend(0.1); |
+ context.startRendering(); |
+ } |
+ |
+ runTest(); |
+ successfullyParsed = true; |
+ </script> |
+ |
+ </body> |
+</html> |