Chromium Code Reviews| Index: third_party/WebKit/LayoutTests/webaudio/audiosource-premature-gc.html |
| diff --git a/third_party/WebKit/LayoutTests/webaudio/audiosource-premature-gc.html b/third_party/WebKit/LayoutTests/webaudio/audiosource-premature-gc.html |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..964821c0837185806db7452f067e1ae1817992bf |
| --- /dev/null |
| +++ b/third_party/WebKit/LayoutTests/webaudio/audiosource-premature-gc.html |
| @@ -0,0 +1,88 @@ |
| +<!doctype html> |
| +<html> |
| + <head> |
| + <title>Test premature GC upon OscillatorNode and AudioBufferSourceNode</title> |
| + <script src="../resources/js-test.js"></script> |
| + <script src="resources/audio-testing.js"></script> |
| + </head> |
| + |
| + <body> |
| + <script type="text/javascript"> |
| + description("Test premature GC upon OscillatorNode and AudioBufferSourceNode"); |
| + window.jsTestIsAsync = true; |
| + |
| + var sampleRate = 44100; |
| + var renderDuration = 1; |
| + |
| + var audit = Audit.createTaskRunner(); |
| + |
| + |
| + // Create a graph for testing in an isolated scope. Returns |context|. |
| + // Create two nodes and schedule only one of them. Then check if |onended| |
| + // from the scheduled node is fired correctly. |
| + function createGraphInIsolatedScope(sourceNodeType, done) { |
| + |
| + 'use strict'; |
| + |
| + var context = new OfflineAudioContext(1, renderDuration * sampleRate, sampleRate); |
| + |
| + { |
| + let node1 = context['create' + sourceNodeType](); |
| + let node2 = context['create' + sourceNodeType](); |
| + node1.connect(context.destination); |
| + node2.connect(context.destination); |
| + |
| + if (sourceNodeType === 'BufferSource') { |
| + 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.
|
| + node1.buffer = dummy; |
| + node2.buffer = dummy; |
| + } |
| + |
| + node1.onended = function () { |
| + testPassed(sourceNodeType + 'Node 1 survived GC and onended event fired.'); |
| + done(); |
| + }; |
| + |
| + node2.onended = function () { |
| + testFailed(sourceNodeType + 'Node 2 did not get collected.'); |
| + 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.
|
| + }; |
|
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.
|
| + |
| + node1.start(); |
| + node1.stop(0.5 * renderDuration); |
| + } |
| + |
| + // Suspend and GC before the render finishes. The time position is |
| + // arbitrary. GC should collect |osc2| because it is not scheduled. |
| + context.suspend(0.1 * renderDuration).then(function () { |
| + gc(); |
| + context.resume(); |
| + }); |
| + |
| + context.startRendering(); |
| + } |
| + |
| + audit.defineTask('oscillator-onended', function (done) { |
| + createGraphInIsolatedScope('Oscillator', done); |
| + }); |
| + |
| + audit.defineTask('buffersource-onended', function (done) { |
| + createGraphInIsolatedScope('BufferSource', done); |
| + }); |
| + |
| + audit.defineTask('finish', function (done) { |
| + finishJSTest(); |
| + done(); |
| + }); |
| + |
| + |
| + audit.runTasks( |
| + 'oscillator-onended', |
| + 'buffersource-onended', |
| + 'finish' |
| + ); |
| + |
| + 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
|
| + </script> |
| + </body> |
| +</html> |