summaryrefslogtreecommitdiffstats
path: root/third_party/WebKit/LayoutTests/webaudio/delaynode-maxdelaylimit.html
blob: 9973e05d04331e133a5f8b2159bf600fccd95643 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
<!DOCTYPE html>

<html>
<head>
<script src="../fast/js/resources/js-test-pre.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 attribute and maximum allowed delay of DelayNode.");

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

    window.context = context;
    shouldThrow("context.createDelay(180)");
    shouldThrow("context.createDelay(0)");
    shouldThrow("context.createDelay(-1)");

    var delay = context.createDelay(179);
    delay.delayTime.value = delayTimeSeconds;
    window.delay = delay;
    shouldBeTrue("delay.delayTime.value === 0.5");

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

runTest();

</script>

</body>
</html>