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

Side by Side Diff: third_party/WebKit/LayoutTests/webaudio/internals/audiosource-premature-gc.html

Issue 2895963003: Apply layout-test-tidy to LayoutTests/webaudio (Closed)
Patch Set: Created 3 years, 7 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
OLDNEW
1 <!doctype html> 1 <!DOCTYPE html>
2 <html> 2 <html>
3 <head> 3 <head>
4 <title>Test premature GC upon OscillatorNode and AudioBufferSourceNode</titl e> 4 <title>
5 Test premature GC upon OscillatorNode and AudioBufferSourceNode
6 </title>
5 <script src="../../resources/testharness.js"></script> 7 <script src="../../resources/testharness.js"></script>
6 <script src="../../resources/testharnessreport.js"></script> 8 <script src="../../resources/testharnessreport.js"></script>
7 <script src="../resources/audit-util.js"></script> 9 <script src="../resources/audit-util.js"></script>
8 <script src="../resources/audit.js"></script> 10 <script src="../resources/audit.js"></script>
9 </head> 11 </head>
12 <body>
13 <script id="layout-test-code">
14 let sampleRate = 44100;
15 let renderDuration = 1;
10 16
11 <body> 17 let audit = Audit.createTaskRunner();
12 <script type="text/javascript">
13
14 var sampleRate = 44100;
15 var renderDuration = 1;
16
17 var audit = Audit.createTaskRunner();
18 18
19 19
20 // Create a graph for testing in an isolated scope. Returns |context|. 20 // Create a graph for testing in an isolated scope. Returns |context|.
21 // Create two nodes and schedule only one of them. Then check if |onended| 21 // Create two nodes and schedule only one of them. Then check if |onended|
22 // from the scheduled node is fired correctly. 22 // from the scheduled node is fired correctly.
23 function createGraphInIsolatedScope(sourceNodeType, task, should) { 23 function createGraphInIsolatedScope(sourceNodeType, task, should) {
24
25 'use strict'; 24 'use strict';
26 25
27 var context = new OfflineAudioContext(1, renderDuration * sampleRate, sa mpleRate); 26 let context =
27 new OfflineAudioContext(1, renderDuration * sampleRate, sampleRate);
28 28
29 { 29 {
30 let node = context['create' + sourceNodeType](); 30 let node = context['create' + sourceNodeType]();
31 node.connect(context.destination); 31 node.connect(context.destination);
32 32
33 if (sourceNodeType === 'BufferSource') { 33 if (sourceNodeType === 'BufferSource') {
34 let emptyBuffer = context.createBuffer(1, sampleRate, sampleRate); 34 let emptyBuffer = context.createBuffer(1, sampleRate, sampleRate);
35 node.buffer = emptyBuffer; 35 node.buffer = emptyBuffer;
36 } 36 }
37 37
38 // If the node is GCed, |onended| won't be fired. Then this test 38 // If the node is GCed, |onended| won't be fired. Then this test
39 // will be timed out because done() will not get called. 39 // will be timed out because done() will not get called.
40 node.onended = function () { 40 node.onended = function() {
41 should(true, sourceNodeType + 41 should(
42 'Node 1 survived GC and onended event fired') 42 true,
43 .beEqualTo(true); 43 sourceNodeType + 'Node 1 survived GC and onended event fired')
44 .beEqualTo(true);
44 task.done(); 45 task.done();
45 }; 46 };
46 47
47 node.start(); 48 node.start();
48 node.stop(0.5 * renderDuration); 49 node.stop(0.5 * renderDuration);
49 } 50 }
50 51
51 // Suspend and GC before the render finishes. The time position is 52 // Suspend and GC before the render finishes. The time position is
52 // arbitrary. GC should collect |osc2| because it is not scheduled. 53 // arbitrary. GC should collect |osc2| because it is not scheduled.
53 context.suspend(0.1 * renderDuration).then(function () { 54 context.suspend(0.1 * renderDuration).then(function() {
54 gc(); 55 gc();
55 context.resume(); 56 context.resume();
56 }); 57 });
57 58
58 context.startRendering(); 59 context.startRendering();
59 } 60 }
60 61
61 audit.define('oscillator-onended', (task, should) => { 62 audit.define('oscillator-onended', (task, should) => {
62 createGraphInIsolatedScope('Oscillator', task, should); 63 createGraphInIsolatedScope('Oscillator', task, should);
63 }); 64 });
64 65
65 audit.define('buffersource-onended', (task, should) => { 66 audit.define('buffersource-onended', (task, should) => {
66 createGraphInIsolatedScope('BufferSource', task, should); 67 createGraphInIsolatedScope('BufferSource', task, should);
67 }); 68 });
68 69
69 audit.run(); 70 audit.run();
70 </script> 71 </script>
71 </body> 72 </body>
72 </html> 73 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698