<!DOCTYPE html>

<html>
<head>
<script src="../resources/js-test.js"></script>
<script src="resources/audio-testing.js"></script>
<script src="resources/delay-testing.js"></script>
</head>

<body>

<div id="description"></div>
<div id="console"></div>

<script>
description("Tests that DelayNode delayTime parameter can be scheduled at a given time.");

function runTest() {
    window.jsTestIsAsync = true;
        
    // Create offline audio context.
    var context = new OfflineAudioContext(1, sampleRate * renderLengthSeconds, sampleRate);
    var toneBuffer = createToneBuffer(context, 20, 20 * toneLengthSeconds, sampleRate); // 20Hz tone
    
    var bufferSource = context.createBufferSource();
    bufferSource.buffer = toneBuffer;

    var delay = context.createDelay();
    
    // Schedule delay time at time zero.
    delay.delayTime.setValueAtTime(delayTimeSeconds, 0);

    bufferSource.connect(delay);
    delay.connect(context.destination);
    bufferSource.start(0);
    
    context.oncomplete = checkDelayedResult(toneBuffer);
    context.startRendering();
}

runTest();

</script>
</body>
</html>
