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

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

Issue 1405413004: Implement suspend() and resume() for OfflineAudioContext (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Updating UseCounter.h after L-G-T-M Created 5 years 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() and O fflineAudioContext.suspend().');
12 window.jsTestIsAsync = true;
13
14 var context;
15
16 // The sample rate is multiple of the rendering quantum, so suspension
17 // times fall in to the render quantum boundary.
18 var renderQuantum = 128;
19
20 var sampleRate = renderQuantum * 100;
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 context = new OfflineAudioContext(1, sampleRate * renderDuration, sampleRa te);
29
30 function onSuspended() {
31 if (context.state === 'suspended' && context.currentTime === scheduledSu spendTime) {
32
33 testPassed('suspend promise resolved: context is suspended at ' +
34 scheduledSuspendTime + ' second(s).');
35
36 scheduledSuspendTime = context.currentTime + suspendInterval;
37
38 // Scheduling a suspend before the render duration should pass.
39 if (scheduledSuspendTime < renderDuration) {
40 context.suspend(scheduledSuspendTime).then(onSuspended);
41 testPassed('A new suspend has been scheduled at ' +
42 scheduledSuspendTime + ' second(s).');
43 }
44
45 // Scheduling a suspend exactly at the render duration should be
46 // rejected.
47 if (scheduledSuspendTime === renderDuration) {
48 Should('Scheduling at ' + renderDuration + ' seconds',
49 context.suspend(scheduledSuspendTime)).beRejected();
50 }
51
52 context.resume();
53 }
54 }
55
56 // Schedule the first suspension.
57 context.suspend(scheduledSuspendTime).then(onSuspended);
58 testPassed('A new suspend has been scheduled at ' + scheduledSuspendTime + ' second(s).');
59
60 context.startRendering().then(function () {
61 Should('Promise context.state', context.state).beEqualTo('closed');
62 }).then(finishJSTest);
63
64 successfullyParsed = true;
65 </script>
66
67 </body>
68 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698