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

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: Restructured the resolution of suspend promise 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;
19
20 // Get the time quantized by render quantum size.
21 function quantizeTimeByRenderQuantum(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(quantizeTimeByRenderQuantum(scheduledSuspendTime));
29
30 // When |context.currentTime + 0.1 > renderDuration|, the promise
31 // should be rejected and throw an exception.
32 scheduledSuspendTime = context.currentTime + 0.1;
33 if (scheduledSuspendTime > renderDuration) {
34 Should('context.suspend(scheduledSuspendTime)',
35 context.suspend(scheduledSuspendTime)).beRejected();
36 } else {
37 context.suspend(scheduledSuspendTime).then(onSuspended);
38 }
39 context.resume();
40 }
41
42 context = new OfflineAudioContext(1, sampleRate * renderDuration, sampleRa te);
43
44 context.suspend(scheduledSuspendTime).then(onSuspended);
45
46 context.startRendering().then(function () {
47 Should('context.state', context.state).beEqualTo('closed');
48 finishJSTest();
49 });
50
51 successfullyParsed = true;
52 </script>
53
54 </body>
55 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698