blob: 823812dcbc7604ffd774870bdb07a2ef29a655ee [file] [log] [blame]
<!DOCTYPE html>
<html>
<head>
<script src="../resources/js-test-pre.js"></script>
<script src="resources/audio-testing.js"></script>
</head>
<body>
<div id="description"></div>
<div id="console"></div>
<script>
description("Test that re-sizing the FFT arrays does not fail.");
if (window.testRunner) {
testRunner.dumpAsText();
testRunner.waitUntilDone();
}
var doTest = function(fftSize, illegal) {
var c = new webkitOfflineAudioContext(1, 1000, 44100);
var a = c.createAnalyser();
try {
a.fftSize = fftSize;
if (illegal)
testFailed("No exception thrown for illegal fftSize " + fftSize + ".");
else
testPassed("Successfully set legal fftSize " + fftSize + ".");
} catch(e) {
testPassed("Exception thrown for illegal fftSize " + fftSize + ".");
}
// This arbitrary size does not affect the correctness of the test.
var arr = new Float32Array(100);
a.getFloatFrequencyData(arr);
}
doTest(-1, true);
doTest(0, true);
doTest(1, true);
for (var i = 2; i <= 0x20000; i *= 2) {
if (i >= 32 && i <= 2048)
doTest(i, false);
else
doTest(i, true);
doTest(i + 1, true);
}
if (window.testRunner)
testRunner.notifyDone();
testPassed("webkitAudioContext survived multiple invalid FFT array resizings.");
</script>
<script src="../resources/js-test-post.js"></script>
</body>
</html>