OLD | NEW |
---|---|
(Empty) | |
1 <!doctype html> | |
2 <html> | |
3 <head> | |
4 <title>Test premature GC upon OscillatorNode and AudioBufferSourceNode</titl e> | |
5 <script src="../resources/js-test.js"></script> | |
6 <script src="resources/audio-testing.js"></script> | |
7 </head> | |
8 | |
9 <body> | |
10 <script type="text/javascript"> | |
11 description("Test premature GC upon OscillatorNode and AudioBufferSourceNo de"); | |
12 window.jsTestIsAsync = true; | |
13 | |
14 var sampleRate = 44100; | |
15 var renderDuration = 1; | |
16 | |
17 var audit = Audit.createTaskRunner(); | |
18 | |
19 | |
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| | |
22 // from the scheduled node is fired correctly. | |
23 function createGraphInIsolatedScope(sourceNodeType, done) { | |
24 | |
25 'use strict'; | |
26 | |
27 var context = new OfflineAudioContext(1, renderDuration * sampleRate, sa mpleRate); | |
28 | |
29 { | |
30 let node1 = context['create' + sourceNodeType](); | |
31 let node2 = context['create' + sourceNodeType](); | |
32 node1.connect(context.destination); | |
33 node2.connect(context.destination); | |
34 | |
35 if (sourceNodeType === 'BufferSource') { | |
36 let dummy = context.createBuffer(1, sampleRate, sampleRate); | |
Raymond Toy
2016/02/25 16:34:56
Pick a more descriptive name than "dummy".
hongchan
2016/02/25 18:00:36
Done.
| |
37 node1.buffer = dummy; | |
38 node2.buffer = dummy; | |
39 } | |
40 | |
41 node1.onended = function () { | |
42 testPassed(sourceNodeType + 'Node 1 survived GC and onended event fi red.'); | |
43 done(); | |
44 }; | |
45 | |
46 node2.onended = function () { | |
47 testFailed(sourceNodeType + 'Node 2 did not get collected.'); | |
48 finishJSTest(); | |
Raymond Toy
2016/02/25 16:34:56
Why finishJSTest() here? Isn't the one in the "fi
hongchan
2016/02/25 18:00:36
I will remove this.
| |
49 }; | |
Raymond Toy
2016/02/25 16:34:56
How is node2.onended supposed to work? node2 isn'
hongchan
2016/02/25 18:00:36
Removing.
| |
50 | |
51 node1.start(); | |
52 node1.stop(0.5 * renderDuration); | |
53 } | |
54 | |
55 // Suspend and GC before the render finishes. The time position is | |
56 // arbitrary. GC should collect |osc2| because it is not scheduled. | |
57 context.suspend(0.1 * renderDuration).then(function () { | |
58 gc(); | |
59 context.resume(); | |
60 }); | |
61 | |
62 context.startRendering(); | |
63 } | |
64 | |
65 audit.defineTask('oscillator-onended', function (done) { | |
66 createGraphInIsolatedScope('Oscillator', done); | |
67 }); | |
68 | |
69 audit.defineTask('buffersource-onended', function (done) { | |
70 createGraphInIsolatedScope('BufferSource', done); | |
71 }); | |
72 | |
73 audit.defineTask('finish', function (done) { | |
74 finishJSTest(); | |
75 done(); | |
76 }); | |
77 | |
78 | |
79 audit.runTasks( | |
80 'oscillator-onended', | |
81 'buffersource-onended', | |
82 'finish' | |
83 ); | |
84 | |
85 succesfullyParsed = true; | |
sof
2016/02/25 16:31:55
nit: do you need this?
hongchan
2016/02/25 18:00:36
All other layout tests of WebAudio has this. I thi
Raymond Toy
2016/02/25 18:02:20
I don't think it's needed. The most recently adde
| |
86 </script> | |
87 </body> | |
88 </html> | |
OLD | NEW |