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

Unified Diff: third_party/WebKit/LayoutTests/webaudio/audiosource-premature-gc.html

Issue 1593763002: Keep AudioSourceNode from premature GC with ScriptWrappable::hasPendingActivity() (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Cleaning up test Created 4 years, 10 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | third_party/WebKit/LayoutTests/webaudio/audiosource-premature-gc-expected.txt » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..aeffcabb32da5a8c464a9c2b813645140d88a305
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/webaudio/audiosource-premature-gc.html
@@ -0,0 +1,82 @@
+<!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 node = context['create' + sourceNodeType]();
+ node.connect(context.destination);
+
+ if (sourceNodeType === 'BufferSource') {
+ let emptyBuffer = context.createBuffer(1, sampleRate, sampleRate);
+ node.buffer = emptyBuffer;
+ }
+
+ // If the node is GCed, |onended| won't be fired. Then this test
+ // will be timed out because done() will not get called.
+ node.onended = function () {
+ testPassed(sourceNodeType + 'Node 1 survived GC and onended event fired.');
+ done();
+ };
+
+ node.start();
+ node.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;
+ </script>
+ </body>
+</html>
« no previous file with comments | « no previous file | third_party/WebKit/LayoutTests/webaudio/audiosource-premature-gc-expected.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698