blob: 882ccfadc3a229ea42439afaf3709ce89253101f [file] [log] [blame]
<!DOCTYPE html>
<html>
<head>
<script src="resources/audio-testing.js"></script>
<script src="../fast/js/resources/js-test-pre.js"></script>
</head>
<body>
<div id="description"></div>
<div id="console"></div>
<script>
description("Basic test for AudioPannerNode.");
function runTest() {
if (window.testRunner) {
testRunner.dumpAsText();
testRunner.waitUntilDone();
}
window.jsTestIsAsync = true;
var context = new webkitAudioContext();
var panner = context.createPanner();
if (panner.numberOfInputs === 1)
testPassed("AudioPannerNode has one input.");
else
testFailed("AudioPannerNode should have one input.");
if (panner.numberOfOutputs === 1)
testPassed("AudioPannerNode has one output.");
else
testFailed("AudioPannerNode should have one output.");
if (panner.panningModel === panner.HRTF)
testPassed("panningModel default value is HRTF.");
else
testFailed("panningModel default value is not HRTF.");
// Set the panning model and see if it can be read back correctly.
panner.panningModel = panner.EQUALPOWER;
if (panner.panningModel === 0)
testPassed("panningModel set to EQUALPOWER model and read correctly.");
else
testFailed("panningModel set to EQUALPOWER (0) but returned " + panner.panningModel);
panner.panningModel = panner.HRTF;
if (panner.panningModel === 1)
testPassed("panningModel set to HRTF model and read correctly.");
else
testFailed("panningModel set to HRTF (1) but returned " + panner.panningModel);
// SOUNDFIELD should throw exception because it is not
// currently implemented. (See https://bugs.webkit.org/show_bug.cgi?id=77367)
try {
panner.panningModel = panner.SOUNDFIELD;
testFailed("Setting panningModel to SOUNDFIELD should throw exception because it is not implemented.");
} catch(e) {
testPassed("Setting panningModel to SOUNDFIELD correctly throws exception because it is not implemented.");
}
// Other invalid models should throw an exception.
try {
panner.panningModel = panner.SOUNDFIELD + 1;
testFailed("Illegal panningModel should throw exception.");
} catch(e) {
testPassed("Illegal panningModel correctly throws exception.");
}
panner.distanceModel = panner.LINEAR_DISTANCE;
if (panner.distanceModel === 0)
testPassed("distanceModel set to LINEAR_DISTANCE and read correctly.");
else
testFailed("distanceModel set to LINEAR_DISTANCE (0) but returned " + panner.distanceModel);
panner.distanceModel = panner.INVERSE_DISTANCE;
if (panner.distanceModel === 1)
testPassed("distanceModel set to INVERSE_DISTANCE and read correctly.");
else
testFailed("distanceModel set to INVERSE_DISTANCE (1) but returned " + panner.distanceModel);
panner.distanceModel = panner.EXPONENTIAL_DISTANCE;
if (panner.distanceModel === 2)
testPassed("distanceModel set to EXPONENTIAL_DISTANCE and read correctly.");
else
testFailed("distanceModel set to EXPONENTIAL_DISTANCE (2) but returned " + panner.distanceModel);
try {
panner.distanceModel = panner.EXPONENTIAL_DISTANCE + 1;
testFailed("Illegal distanceModel should throw exception.");
} catch(e) {
testPassed("Illegal distanceModel correctly throws exception.");
}
finishJSTest();
}
runTest();
successfullyParsed = true;
</script>
<script src="../fast/js/resources/js-test-post.js"></script>
</body>
</html>