Chromium Code Reviews| 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 renderQuantum = 128; | |
| 18 var scheduledSuspendTime = 0.1; | |
|
Raymond Toy
2015/05/28 16:37:34
Same comments here as for the suspend-resume-event
hongchan
2015/06/09 20:49:58
Acknowledged.
| |
| 19 | |
| 20 // Get the time quantized by render quantum size. | |
| 21 function quantizeByRenderQuantum(time) { | |
| 22 var samples = time * sampleRate; | |
| 23 return (samples - (samples % renderQuantum)) / sampleRate; | |
| 24 } | |
| 25 | |
| 26 function onSuspended() { | |
| 27 Should('context.currentTime', context.currentTime) | |
| 28 .beEqualTo(quantizeByRenderQuantum(scheduledSuspendTime)); | |
| 29 | |
| 30 // When context.currentTime 0.1 > renderDuration, the promise should be | |
| 31 // rejected and throw an exception. | |
| 32 scheduledSuspendTime = context.currentTime + 0.1; | |
| 33 context.suspend(scheduledSuspendTime).then(onSuspended); | |
| 34 context.resume(); | |
| 35 } | |
| 36 | |
| 37 context = new OfflineAudioContext(1, sampleRate * renderDuration, sampleRa te); | |
| 38 | |
| 39 context.suspend(scheduledSuspendTime).then(onSuspended); | |
| 40 | |
| 41 context.startRendering().then(function () { | |
| 42 Should('context.state', context.state).beEqualTo('closed'); | |
| 43 finishJSTest(); | |
| 44 }); | |
| 45 | |
| 46 successfullyParsed = true; | |
| 47 </script> | |
| 48 | |
| 49 </body> | |
| 50 </html> | |
| OLD | NEW |