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

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: Simplify changes (startNode > start) 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..4034c7eda5429f2c083628c13d47e5976a95820e
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/webaudio/audiosource-premature-gc.html
@@ -0,0 +1,63 @@
+<!doctype html>
+<html>
+ <head>
+ <title>Test premature GC upon OscillatorNode and AudioBufferSourceNode</title>
+ <script src="../resources/js-test.js"></script>
+ </head>
+
+ <body>
+ <script type="text/javascript">
+ description("Test premature GC upon OscillatorNode and AudioBufferSourceNode");
+ window.jsTestIsAsync = true;
+
+ var sampleRate = 44100;
+ var renderLength = 2 * sampleRate;
+
+ var context = new OfflineAudioContext(1, renderLength, sampleRate);
+
+ // Immediately execute this code inside of the closure. This way |osc| is
+ // contained in the scope and will be a possible target of GC. However,
+ // it will survive GC since it has a pending activity because it is
+ // scheduled. Thus |onended| will be fired eventually.
+ (function () {
sof 2016/02/24 07:51:10 There's an output ordering issue here, the deliver
+ var osc = context.createOscillator();
+ osc.connect(context.destination);
+ osc.onended = function () {
+ testPassed('OscillatorNode survived GC and onended event fired.');
+ };
+
+ // Play the oscillator for 1 second.
+ osc.start();
+ osc.stop(1);
+ })();
+
+ // The below does the same thing, but with AudioBufferSourceNode.
+ (function () {
+ var source = context.createBufferSource();
+ var dummy = context.createBuffer(1, sampleRate, sampleRate);
+ source.buffer = dummy;
+
+ source.connect(context.destination);
+
+ source.onended = function () {
+ testPassed('AudioBufferSourceNode survived GC and onended event fired.');
+ };
+
+ source.start();
+ })();
+
+ // Suspend the rendering at 0.1 second and perform GC. The reference to
+ // the oscillator and the buffer source should not be collected.
+ context.suspend(0.1).then(function () {
+ gc();
+ context.resume();
+ });
+
+ context.startRendering().then(function () {
+ finishJSTest();
+ });
+
+ 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