Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(23)

Side by Side Diff: LayoutTests/webaudio/offlineaudiocontext-suspend-resume-promise.html

Issue 1140723003: Implement suspend() and resume() for OfflineAudioContext (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Initial review + layout tests Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(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>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698