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

Side by Side Diff: third_party/WebKit/LayoutTests/webaudio/AudioNode/audionode-connect-order.html

Issue 2651623004: Convert more AudioNode tests to use testharness (Closed)
Patch Set: Fix bad indentation. Created 3 years, 11 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 2
3 <html> 3 <html>
4 <head> 4 <head>
5 <script src="../../resources/js-test.js"></script> 5 <script src="../../resources/testharness.js"></script>
6 <script src="../../resources/testharnessreport.js"></script>
6 <script src="../resources/audit-util.js"></script> 7 <script src="../resources/audit-util.js"></script>
7 <script src="../resources/audio-testing.js"></script> 8 <script src="../resources/audit.js"></script>
8 </head> 9 </head>
9 10
10 <body> 11 <body>
11
12 <div id="description"></div>
13 <div id="console"></div>
14
15 <script> 12 <script>
16 description("This tests that we don't trigger an assertion failure due to AudioN ode connection order."); 13 let audit = Audit.createTaskRunner();
17 14 let sampleRate = 44100.0;
18 var sampleRate = 44100.0; 15 let renderLengthSeconds = 0.125;
19 var renderLengthSeconds = 0.125; 16 let delayTimeSeconds = 0.1;
20 var delayTimeSeconds = 0.1;
21 17
22 function createSinWaveBuffer(context, lengthInSeconds, frequency) { 18 function createSinWaveBuffer(context, lengthInSeconds, frequency) {
23 var audioBuffer = context.createBuffer(1, lengthInSeconds * sampleRate, samp leRate); 19 let audioBuffer =
20 context.createBuffer(1, lengthInSeconds * sampleRate, sampleRate);
24 21
25 var n = audioBuffer.length; 22 let n = audioBuffer.length;
26 var data = audioBuffer.getChannelData(0); 23 let data = audioBuffer.getChannelData(0);
27 24
28 for (var i = 0; i < n; ++i) { 25 for (let i = 0; i < n; ++i) {
29 data[i] = Math.sin(frequency * 2 * Math.PI * i / sampleRate); 26 data[i] = Math.sin(frequency * 2 * Math.PI * i / sampleRate);
30 } 27 }
31 28
32 return audioBuffer; 29 return audioBuffer;
33 } 30 }
34 31
35 function runTest() { 32 audit.define('Test connections', function(task, should) {
36 if (window.testRunner) { 33 task.describe('AudioNode connection order doesn\'t trigger assertion errors');
37 testRunner.dumpAsText(); 34 // Create offline audio context.
38 testRunner.waitUntilDone(); 35 let context =
39 } 36 new OfflineAudioContext(1, sampleRate * renderLengthSeconds, sampleRate);
40 37 let toneBuffer = createSinWaveBuffer(context, renderLengthSeconds, 880);
41 window.jsTestIsAsync = true;
42
43 // Create offline audio context.
44 var context = new OfflineAudioContext(1, sampleRate * renderLengthSeconds, s ampleRate);
45 var toneBuffer = createSinWaveBuffer(context, renderLengthSeconds, 880);
46
47 var bufferSource = context.createBufferSource();
48 bufferSource.buffer = toneBuffer;
49 bufferSource.connect(context.destination);
50 38
51 var delay = context.createDelay(); 39 let bufferSource = context.createBufferSource();
52 delay.delayTime.value = delayTimeSeconds; 40 bufferSource.buffer = toneBuffer;
41 bufferSource.connect(context.destination);
53 42
54 // We connect delay node to gain node before anything is connected to delay node itself. 43 let delay = context.createDelay();
55 // We do this because we try to trigger the ASSERT which might be fired due to AudioNode connection order, 44 delay.delayTime.value = delayTimeSeconds;
56 // especially when gain node and delay node is involved e.g. https://bugs.we bkit.org/show_bug.cgi?id=76685.
57 45
58 var gain = context.createGain(); 46 // We connect delay node to gain node before anything is connected to delay
47 // node itself. We do this because we try to trigger the ASSERT which might
48 // be fired due to AudioNode connection order, especially when gain node and
49 // delay node is involved
50 // e.g. https://bugs.webkit.org/show_bug.cgi?id=76685.
51
52 should(() => {
53 let gain = context.createGain();
59 gain.connect(context.destination); 54 gain.connect(context.destination);
60 delay.connect(gain); 55 delay.connect(gain);
56 }, 'Connecting nodes').notThrow();
61 57
62 bufferSource.start(0); 58 bufferSource.start(0);
63 59
64 context.oncomplete = finishJSTest; 60 let promise = context.startRendering();
65 context.startRendering();
66 }
67 61
68 runTest(); 62 should(promise, 'OfflineContext startRendering()')
63 .beResolved()
64 .then(task.done.bind(task));
65 });
66
67 audit.run();
69 68
70 </script> 69 </script>
71 70
72 </body> 71 </body>
73 </html> 72 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698