5 <script src="../fast/js/resources/js-test-pre.js"></script>
10 <div id="description"></div>
11 <div id="console"></div>
14 description("This tests that we don't trigger an assertion failure due to AudioNode connection order.");
16 var sampleRate = 44100.0;
17 var renderLengthSeconds = 0.125;
18 var delayTimeSeconds = 0.1;
20 function createSinWaveBuffer(context, lengthInSeconds, frequency) {
21 var audioBuffer = context.createBuffer(1, lengthInSeconds * sampleRate, sampleRate);
23 var n = audioBuffer.length;
24 var data = audioBuffer.getChannelData(0);
26 for (var i = 0; i < n; ++i) {
27 data[i] = Math.sin(frequency * 2 * Math.PI * i / sampleRate);
34 if (window.layoutTestController) {
35 layoutTestController.overridePreference("WebKitWebAudioEnabled", "1");
36 layoutTestController.dumpAsText();
37 layoutTestController.waitUntilDone();
40 window.jsTestIsAsync = true;
42 // Create offline audio context.
43 var context = new webkitAudioContext(1, sampleRate * renderLengthSeconds, sampleRate);
44 var toneBuffer = createSinWaveBuffer(context, renderLengthSeconds, 880);
46 var bufferSource = context.createBufferSource();
47 bufferSource.buffer = toneBuffer;
48 bufferSource.connect(context.destination);
50 var delay = context.createDelayNode();
51 delay.delayTime.value = delayTimeSeconds;
53 // We connect delay node to gain node before anything is connected to delay node itself.
54 // We do this because we try to trigger the ASSERT which might be fired due to AudioNode connection order,
55 // especially when gain node and delay node is involved e.g. https://bugs.webkit.org/show_bug.cgi?id=76685.
57 var gain = context.createGainNode();
58 gain.connect(context.destination);
61 bufferSource.noteOn(0);
63 context.oncomplete = finishJSTest;
64 context.startRendering();
71 <script src="../fast/js/resources/js-test-post.js"></script>