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

Side by Side Diff: third_party/WebKit/LayoutTests/webaudio/AudioBufferSource/audiosource-premature-gc.html

Issue 2783553002: Convert AudioBufferSource tests to new Audit (Closed)
Patch Set: Indent neatly. Created 3 years, 8 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
1 <!doctype html> 1 <!doctype html>
2 <html> 2 <html>
3 <head> 3 <head>
4 <title>Test premature GC upon OscillatorNode and AudioBufferSourceNode</titl e> 4 <title>Test premature GC upon OscillatorNode and AudioBufferSourceNode</titl e>
5 <script src="../../resources/testharness.js"></script> 5 <script src="../../resources/testharness.js"></script>
6 <script src="../../resources/testharnessreport.js"></script> 6 <script src="../../resources/testharnessreport.js"></script>
7 <script src="../resources/audit-util.js"></script> 7 <script src="../resources/audit-util.js"></script>
8 <script src="../resources/audio-testing.js"></script> 8 <script src="../resources/audit.js"></script>
9 </head> 9 </head>
10 10
11 <body> 11 <body>
12 <script type="text/javascript"> 12 <script type="text/javascript">
13 13
14 var sampleRate = 44100; 14 var sampleRate = 44100;
15 var renderDuration = 1; 15 var renderDuration = 1;
16 16
17 var audit = Audit.createTaskRunner(); 17 var audit = Audit.createTaskRunner();
18 18
19 19
20 // Create a graph for testing in an isolated scope. Returns |context|. 20 // Create a graph for testing in an isolated scope. Returns |context|.
21 // Create two nodes and schedule only one of them. Then check if |onended| 21 // Create two nodes and schedule only one of them. Then check if |onended|
22 // from the scheduled node is fired correctly. 22 // from the scheduled node is fired correctly.
23 function createGraphInIsolatedScope(sourceNodeType, done) { 23 function createGraphInIsolatedScope(sourceNodeType, task, should) {
24 24
25 'use strict'; 25 'use strict';
26 26
27 var context = new OfflineAudioContext(1, renderDuration * sampleRate, sa mpleRate); 27 var context = new OfflineAudioContext(1, renderDuration * sampleRate, sa mpleRate);
28 28
29 { 29 {
30 let node = context['create' + sourceNodeType](); 30 let node = context['create' + sourceNodeType]();
31 node.connect(context.destination); 31 node.connect(context.destination);
32 32
33 if (sourceNodeType === 'BufferSource') { 33 if (sourceNodeType === 'BufferSource') {
34 let emptyBuffer = context.createBuffer(1, sampleRate, sampleRate); 34 let emptyBuffer = context.createBuffer(1, sampleRate, sampleRate);
35 node.buffer = emptyBuffer; 35 node.buffer = emptyBuffer;
36 } 36 }
37 37
38 // If the node is GCed, |onended| won't be fired. Then this test 38 // If the node is GCed, |onended| won't be fired. Then this test
39 // will be timed out because done() will not get called. 39 // will be timed out because done() will not get called.
40 node.onended = function () { 40 node.onended = function () {
41 Should(sourceNodeType + 'Node 1 survived GC and onended event fired' , true).beEqualTo(true); 41 should(true, sourceNodeType +
42 done(); 42 'Node 1 survived GC and onended event fired')
43 .beEqualTo(true);
44 task.done();
43 }; 45 };
44 46
45 node.start(); 47 node.start();
46 node.stop(0.5 * renderDuration); 48 node.stop(0.5 * renderDuration);
47 } 49 }
48 50
49 // Suspend and GC before the render finishes. The time position is 51 // Suspend and GC before the render finishes. The time position is
50 // arbitrary. GC should collect |osc2| because it is not scheduled. 52 // arbitrary. GC should collect |osc2| because it is not scheduled.
51 context.suspend(0.1 * renderDuration).then(function () { 53 context.suspend(0.1 * renderDuration).then(function () {
52 gc(); 54 gc();
53 context.resume(); 55 context.resume();
54 }); 56 });
55 57
56 context.startRendering(); 58 context.startRendering();
57 } 59 }
58 60
59 audit.defineTask('oscillator-onended', function (done) { 61 audit.define('oscillator-onended', (task, should) => {
60 createGraphInIsolatedScope('Oscillator', done); 62 createGraphInIsolatedScope('Oscillator', task, should);
61 }); 63 });
62 64
63 audit.defineTask('buffersource-onended', function (done) { 65 audit.define('buffersource-onended', (task, should) => {
64 createGraphInIsolatedScope('BufferSource', done); 66 createGraphInIsolatedScope('BufferSource', task, should);
65 }); 67 });
66 68
67 audit.defineTask('finish', function (done) { 69 audit.run();
68 done();
69 });
70
71
72 audit.runTasks(
73 'oscillator-onended',
74 'buffersource-onended',
75 'finish'
76 );
77
78 succesfullyParsed = true;
79 </script> 70 </script>
80 </body> 71 </body>
81 </html> 72 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698