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

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

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

Powered by Google App Engine
This is Rietveld 408576698