gecko/content/media/webaudio/test/test_pannerNode.html
Ehsan Akhgari 94b2981ab9 Bug 833631 - Unprefix mozAudioContext; r=roc
--HG--
extra : rebase_source : 3c477a97ea842a806f6fad6f5c3a81d6e50b27c3
2013-01-22 20:12:21 -05:00

66 lines
1.9 KiB
HTML

<!DOCTYPE HTML>
<html>
<head>
<title>Test PannerNode</title>
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
</head>
<body>
<pre id="test">
<script class="testbody" type="text/javascript">
function near(a, b, msg) {
ok(Math.abs(a - b) < 1e-4, msg);
}
SimpleTest.waitForExplicitFinish();
addLoadEvent(function() {
SpecialPowers.setBoolPref("media.webaudio.enabled", true);
var context = new AudioContext();
var buffer = context.createBuffer(1, 2048, 44100);
for (var i = 0; i < 2048; ++i) {
buffer.getChannelData(0)[i] = Math.sin(440 * 2 * Math.PI * i / 44100);
}
var destination = context.destination;
var source = context.createBufferSource();
var panner = context.createPanner();
source.buffer = buffer;
source.connect(panner);
panner.connect(destination);
// Verify default values
is(panner.panningModel, 1, "Correct default value for panning model");
is(panner.distanceModel, 1, "Correct default value for distance model");
near(panner.refDistance, 1, "Correct default value for ref distance");
near(panner.maxDistance, 10000, "Correct default value for max distance");
near(panner.rolloffFactor, 1, "Correct default value for rolloff factor");
near(panner.coneInnerAngle, 360, "Correct default value for cone inner angle");
near(panner.coneOuterAngle, 360, "Correct default value for cone outer angle");
near(panner.coneOuterGain, 0, "Correct default value for cone outer gain");
panner.setPosition(1, 1, 1);
panner.setOrientation(1, 1, 1);
panner.setVelocity(1, 1, 1);
source.start(0);
SimpleTest.executeSoon(function() {
source.stop(0);
source.disconnect();
panner.disconnect();
SpecialPowers.clearUserPref("media.webaudio.enabled");
SimpleTest.finish();
});
});
</script>
</pre>
</body>
</html>