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

Side by Side Diff: third_party/WebKit/LayoutTests/webaudio/offlineaudiocontext-suspend-resume-eventhandler.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 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
18 // times in the test will fall on the render quantum boundary. Although
19 // this is not necessary, it is easier to understand the test.
20 var sampleRate = renderQuantum * 100;
21
22 var renderDuration = 2;
23 var scheduledSuspendTime = 0;
24
25 // With the sample rate setting above, this ensures suspension time fall
26 // in to the render quantum boundary.
27 var suspendInterval = 0.25;
28
29 function runTest() {
30 context = new OfflineAudioContext(1, sampleRate * renderDuration, sample Rate);
31
32 context.onstatechange = function () {
33 if (context.state === 'suspended' && context.currentTime === scheduled SuspendTime) {
34
35 testPassed('onstatechange event handler: context is suspended at ' +
36 scheduledSuspendTime + ' second(s).');
37
38 scheduledSuspendTime = context.currentTime + suspendInterval;
39
40 // Scheduling a suspend before the render duration should pass.
41 if (scheduledSuspendTime < renderDuration) {
42 context.suspend(scheduledSuspendTime);
43 testPassed('A new suspend has been scheduled at ' +
44 scheduledSuspendTime + ' second(s).');
45 }
46
47 // Scheduling a suspend exactly at the render duration should be
48 // rejected.
49 if (scheduledSuspendTime === renderDuration) {
50 Should('Scheduling at ' + renderDuration + ' seconds',
51 context.suspend(scheduledSuspendTime)).beRejected();
52 }
53
54 context.resume();
55 }
56 };
57
58 // This test is for verifying all the event handlers on OAC and that is
59 // why 'oncomplete' is used here.
60 context.oncomplete = function () {
61 Should('oncomplete event handler: context.state', context.state).beEqu alTo('closed');
62 finishJSTest();
63 };
64
65 // Schedule the first suspension.
66 context.suspend(scheduledSuspendTime);
67 testPassed('A new suspend has been scheduled at ' + scheduledSuspendTime + ' second(s).');
68
69 context.startRendering();
70 }
71
72 runTest();
73 successfullyParsed = true;
74 </script>
75
76 </body>
77 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698