OLD | NEW |
(Empty) | |
| 1 <!doctype html> |
| 2 <html> |
| 3 <head> |
| 4 <script src="../resources/js-test.js"></script> |
| 5 <script src="resources/compatibility.js"></script> |
| 6 <script src="resources/audio-testing.js"></script> |
| 7 </head> |
| 8 |
| 9 <body> |
| 10 <script> |
| 11 description('Test promise resolution of OfflineAudioContext resume/suspend
.'); |
| 12 window.jsTestIsAsync = true; |
| 13 |
| 14 var context; |
| 15 var sampleRate = 44100; |
| 16 var renderDuration = 2; |
| 17 var renderQuantumDur = 128 / sampleRate; |
| 18 |
| 19 var suspendCount = 0; |
| 20 var expectedSuspendTime = [ |
| 21 0.09868480725623582, |
| 22 0.19736961451247165, |
| 23 0.2960544217687075, |
| 24 0.3947392290249433, |
| 25 0.49342403628117915, |
| 26 0.592108843537415, |
| 27 0.6907936507936508, |
| 28 0.7894784580498866, |
| 29 0.8881632653061224, |
| 30 0.9868480725623583, |
| 31 1.0855328798185941, |
| 32 1.18421768707483, |
| 33 1.2829024943310658, |
| 34 1.3815873015873017, |
| 35 1.4802721088435373, |
| 36 1.5789569160997732, |
| 37 1.677641723356009, |
| 38 1.7763265306122449, |
| 39 1.8750113378684807, |
| 40 1.9736961451247166 |
| 41 ]; |
| 42 |
| 43 |
| 44 context = new OfflineAudioContext(1, sampleRate * renderDuration, sampleRa
te); |
| 45 |
| 46 function onSuspended() { |
| 47 Should('context.currentTime', context.currentTime) |
| 48 .beEqualTo(expectedSuspendTime[suspendCount++]); |
| 49 context.suspend(context.currentTime + 0.1).then(onSuspended); |
| 50 context.resume(); |
| 51 } |
| 52 |
| 53 context.suspend(0.1).then(onSuspended); |
| 54 |
| 55 context.startRendering().then(function () { |
| 56 Should('context.state', context.state).beEqualTo('closed'); |
| 57 finishJSTest(); |
| 58 }); |
| 59 |
| 60 successfullyParsed = true; |
| 61 </script> |
| 62 |
| 63 </body> |
| 64 </html> |
OLD | NEW |