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

Side by Side Diff: LayoutTests/webaudio/javascriptaudionode-premature-death.html

Issue 21216002: Demonstrate that Web Audio does not keep callbacks alive long enough. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 7 years, 4 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 | Annotate | Revision Log
OLDNEW
(Empty)
1 <!DOCTYPE html>
2 <script src="../fast/js/resources/js-test-pre.js"></script>
3 <body>
4 <script>
5 description('Tests that a JavaScriptAudioNode is not prematurely GCed');
6 var jsTestIsAsync = true;
7
8 if (!window.internals)
9 testFailed('This test requires window.internals.');
10
11 // Create an audio context
12 var context = new webkitOfflineAudioContext(
13 /* channels: */ 2, /* length, frames: */ 512, /* sample rate: */ 44100.0);
Chris Rogers 2013/07/30 18:55:54 Because of internal buffering used in the ScriptPr
dominicc (has gone to gerrit) 2013/07/31 00:45:59 I cribbed these values from LayoutTests/webaudio/r
14
15 // Set up a source, reading from an empty buffer
16 var source = context.createBufferSource();
17 source.buffer = context.createBuffer(
18 /* source channels: */ 2, /* length, frames: */ 512,
Chris Rogers 2013/07/30 18:55:54 Similar to above comment - I'd increase 512 -> 409
19 /* sample rate: */ 44100.0);
20
21 // Set up a JavaScript audio node to generate something
22 var node = context.createJavaScriptNode(
Chris Rogers 2013/07/30 18:55:54 nit: the new method name is called "createScriptPr
23 /* buffer size: */ 512, /* input channels: */ 0, /* output channels: */ 2);
24
25 // source -> JavaScript audio node -> destination
Chris Rogers 2013/07/30 18:55:54 "JavaScript audio node" -> "script processor node"
26 source.connect(node);
27 node.connect(context.destination);
28
29 // Set up something which indicates whether we're called to generate anything
30
31 var wasCalled = false;
32 var callback = function () { wasCalled = true; };
33 node.onaudioprocess = callback;
34
35 // Watch the callback; if it dies, we're obviously not generating anything
36
37 var observation = internals.observeGC(callback);
38 node = callback = null;
39 gc();
40 var wasCollectedPrematurely = observation.wasCollected;
41
42 // Make some noise!
43
44 source.noteOn(0);
Chris Rogers 2013/07/30 18:55:54 new method name: noteOn() -> start()
45 context.oncomplete = finishTest;
46 context.startRendering();
47
48 function finishTest() {
49 shouldBeFalse('wasCollectedPrematurely');
50 shouldBeTrue('wasCalled');
51 finishJSTest();
52 }
53
54 var successfullyParsed = true;
55 </script>
56 <script src="../fast/js/resources/js-test-post.js"></script>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698