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() and O fflineAudioContext.suspend().'); | |
| 12 window.jsTestIsAsync = true; | |
| 13 | |
| 14 var context; | |
| 15 var renderQuantum = 128; | |
| 16 var sampleRate = renderQuantum * 100; | |
|
Raymond Toy
2015/06/12 21:11:36
Pretty much the same comments for this file as for
hongchan
2015/06/15 18:40:46
Done.
| |
| 17 var renderDuration = 2; | |
| 18 var scheduledSuspendTime = 0; | |
| 19 var suspendInterval = 0.25; | |
| 20 | |
| 21 context = new OfflineAudioContext(1, sampleRate * renderDuration, sampleRa te); | |
| 22 | |
| 23 function onSuspended() { | |
| 24 Should('context.currentTime', context.currentTime) | |
| 25 .beEqualTo(scheduledSuspendTime); | |
| 26 | |
| 27 // When |scheduledSuspendTime > renderDuration|, the promise should be | |
| 28 // rejected and throw an exception. | |
| 29 scheduledSuspendTime = context.currentTime + suspendInterval; | |
| 30 if (scheduledSuspendTime >= renderDuration) { | |
| 31 Should('context.suspend(scheduledSuspendTime)', | |
| 32 context.suspend(scheduledSuspendTime)).beRejected(); | |
| 33 } else { | |
| 34 context.suspend(scheduledSuspendTime).then(onSuspended); | |
| 35 } | |
| 36 context.resume(); | |
| 37 } | |
| 38 | |
| 39 context.suspend(scheduledSuspendTime).then(onSuspended); | |
| 40 context.startRendering().then(function () { | |
| 41 Should('context.state', context.state).beEqualTo('closed'); | |
| 42 finishJSTest(); | |
| 43 }); | |
| 44 | |
| 45 successfullyParsed = true; | |
| 46 </script> | |
| 47 | |
| 48 </body> | |
| 49 </html> | |
| OLD | NEW |