Move parseFontFaceDescriptor to CSSPropertyParser.cpp
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / webaudio / scriptprocessornode-premature-death.html
blob1eafd5c30a2440dce6439782360ea3558f112a96
1 <!DOCTYPE html>
2 <script src="../resources/js-test.js"></script>
3 <script src="resources/compatibility.js"></script>
4 <body>
5 <script>
6 description('Tests that a script processor node is not prematurely GCed');
7 var jsTestIsAsync = true;
9 if (!window.internals) {
10 testFailed('This test requires window.internals.');
11 finishJSTest();
14 var wasCalled, wasCollectedPrematurely, savedNode, savedCallback;
16 function test(saveReference, nextStep) {
17 debug('Testing ' + (saveReference ? 'with' : 'without') + ' explicitly ' +
18 'keeping a reference to the script processor node alive.');
20 // Create an audio context
21 var context = new OfflineAudioContext(
22 2, // channels
23 4096, // length (frames)
24 44100.0); // sample rate
26 // Set up a source, reading from an empty buffer
27 var source = context.createBufferSource();
28 source.buffer = context.createBuffer(
29 2, // source channels
30 4096, // length (frames)
31 44100.0); // sample rate
33 // Set up a script processor node to generate something
34 var node = context.createScriptProcessor(
35 512, // buffer size
36 0, // input channels
37 2); // output channels
39 // source -> script processor node -> destination
40 source.connect(node);
41 node.connect(context.destination);
43 // Set up something which indicates whether we're called to
44 // generate anything
46 wasCalled = false;
47 var callback = function () { wasCalled = true; };
48 node.onaudioprocess = callback;
50 if (saveReference) {
51 savedNode = node;
52 savedCallback = callback;
55 // Watch the callback; if it dies, we're obviously not generating anything
57 var observation = internals.observeGC(callback);
58 node = callback = null;
59 gc();
60 wasCollectedPrematurely = observation.wasCollected;
62 // Make some noise!
64 source.start(0);
65 context.oncomplete = check(nextStep);
66 context.startRendering();
69 function check(nextStep) {
70 return function () {
71 shouldBeFalse('wasCollectedPrematurely');
72 shouldBeTrue('wasCalled');
73 nextStep();
77 function step1() {
78 test(true, step2);
81 function step2() {
82 test(false, finishJSTest);
85 step1();
87 var successfullyParsed = true;
88 </script>