blob: 05f42a638a2d9a9681930efb03a840ee33c8ac1e [file] [log] [blame]
<!DOCTYPE html>
<html>
<head>
<script src="../resources/js-test-pre.js"></script>
<script src="resources/audio-testing.js"></script>
</head>
<body>
<script>
description("Basic tests for PeriodicWave.");
var context = new webkitAudioContext();
var zeroWaveCoef = new Float32Array(0);
var overWaveCoef = new Float32Array(4097);
var minWaveCoef = new Float32Array(1);
var maxWaveCoef = new Float32Array(4096);
try {
var zeroPeriodicWave = context.createPeriodicWave(zeroWaveCoef, zeroWaveCoef);
testFailed("IndexSizeError should be thrown for the length of Float32Array <= 0.");
} catch(e) {
if (e.code === DOMException.INDEX_SIZE_ERR)
testPassed("IndexSizeError was thrown for the length of Float32Array <= 0.");
else
testFailed("IndexSizeError should be thrown for the length of Float32Array <= 0.");
}
try {
var overPeriodicWave = context.createPeriodicWave(overWaveCoef, overWaveCoef);
testFailed("IndexSizeError should be thrown for the length of Float32Array > 4096.");
} catch(e) {
if (e.code === DOMException.INDEX_SIZE_ERR)
testPassed("IndexSizeError was thrown for the length of Float32Array > 4096.");
else
testFailed("IndexSizeError should be thrown for the length of Float32Array > 4096.");
}
try {
var diffPeriodicWave = context.createPeriodicWave(minWaveCoef, maxWaveCoef);
testFailed("IndexSizeError should be thrown for parameters are not eqaul lengths.");
} catch(e) {
if (e.code === DOMException.INDEX_SIZE_ERR)
testPassed("IndexSizeError was thrown for parameters are not eqaul lengths.");
else
testFailed("IndexSizeError should be thrown for parameters are not eqaul lengths.");
}
try {
var maxPeriodicWave = context.createPeriodicWave(maxWaveCoef, maxWaveCoef);
testPassed("PeriodicWave created successfully with the length of Float32Array = 4096.");
} catch(e) {
testFailed("Failed to create PeriodicWave with the length of Float32Array = 4096.");
}
</script>
<script src="../resources/js-test-post.js"></script>
</body>
</html>