blob: 64a84dac4b39be822d603c59aaf4f6d68067df41 [file] [log] [blame]
<!DOCTYPE html>
<html>
<head>
<script src="../resources/js-test.js"></script>
<script src="resources/compatibility.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 OfflineAudioContext(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 <= 32768)
doTest(i, false);
else
doTest(i, true);
doTest(i + 1, true);
}
if (window.testRunner)
testRunner.notifyDone();
testPassed("AudioContext survived multiple invalid FFT array resizings.");
</script>
</body>
</html>