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 event handler callback from OfflineAudioContext.resume() and OfflineAudioContext.suspend().'); | |
| 12 window.jsTestIsAsync = true; | |
| 13 | |
| 14 var context; | |
| 15 var renderQuantum = 128; | |
| 16 | |
| 17 // The sample rate is multiple of the rendering quantum, so suspension | |
|
Raymond Toy
2015/06/15 20:42:13
You mean the suspension times in this test. Say t
hongchan
2015/06/15 21:44:20
Done.
| |
| 18 // times fall in to the render quantum boundary. | |
| 19 var sampleRate = renderQuantum * 100; | |
| 20 | |
| 21 var renderDuration = 2; | |
| 22 var scheduledSuspendTime = 0; | |
| 23 | |
| 24 // With the sample rate setting above, this ensures suspension time fall | |
| 25 // in to the render quantum boundary. | |
| 26 var suspendInterval = 0.25; | |
| 27 | |
| 28 function runTest() { | |
| 29 context = new OfflineAudioContext(1, sampleRate * renderDuration, sample Rate); | |
| 30 | |
| 31 context.onstatechange = function () { | |
| 32 if (context.state === 'suspended') { | |
| 33 Should('context.currentTime', context.currentTime) | |
| 34 .beEqualTo(scheduledSuspendTime); | |
| 35 | |
| 36 scheduledSuspendTime = context.currentTime + suspendInterval; | |
| 37 | |
| 38 // Schedule the next suspension only when |scheduledSuspendTime| is | |
| 39 // less than |renderDuration|. Although suspend() will catch | |
| 40 // the out-of-bound error, but it will reject the promise and | |
| 41 // this test is for the event handler, not the promise. | |
| 42 if (scheduledSuspendTime < renderDuration) | |
| 43 context.suspend(scheduledSuspendTime); | |
| 44 | |
| 45 context.resume(); | |
| 46 } | |
| 47 }; | |
| 48 | |
| 49 // This test is for verifying all the event handlers on OAC and that is | |
| 50 // why 'oncomplete' is used here. | |
| 51 context.oncomplete = function () { | |
| 52 Should('context.state', context.state).beEqualTo('closed'); | |
| 53 finishJSTest(); | |
| 54 }; | |
| 55 | |
| 56 // Initiate the suspension loop. | |
| 57 context.suspend(scheduledSuspendTime); | |
| 58 context.startRendering(); | |
| 59 } | |
| 60 | |
| 61 runTest(); | |
| 62 successfullyParsed = true; | |
| 63 </script> | |
| 64 | |
| 65 </body> | |
| 66 </html> | |
| OLD | NEW |