Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / ManualTests / webaudio / audiobuffersource-gc.html
blob1d3a2944100e3b99857cd7d6c874cebc79190788
1 <!doctype html>
2 <html>
3 <head>
4 <title>Test GC of AudioBufferSourceNode</title>
5 <script>
6 var context;
7 var bufferLengthSeconds = 120;
8 var count = 0;
10 function runTest() {
12 // Create the context
13 context = new AudioContext();
15 // Continuously create AudioBufferSourceNodes with large AudioBuffers and immediately drop
16 // the references. This should not crash the browser.
17 setInterval(function () {
18 var source = context.createBufferSource();
19 var buffer = context.createBuffer(1, bufferLengthSeconds * context.sampleRate, context.sampleRate);
20 source.buffer = buffer;
21 buffer = null;
22 source = null;
23 ++count;
24 if ((count % 100) == 0)
25 console.log(count + " nodes generated");
26 }, 10);
28 </script>
29 </head>
31 <body>
32 <p>
33 This tests that we clear up source buffers that were never connected nor started. Press the
34 button to run the test. If everything is working correctly, there will be no crash. Watch the
35 messages in the console. Run this for at least 5000 nodes (see console for node count).
36 </p>
37 <button onclick="runTest()">Run AudioBufferSourceNode GC Test</button>
38 </body>
39 </html>