gecko/content/media/webaudio/test/test_gainNode.html
Robert O'Callahan 82088f3e65 Bug 804387. Part 7.5: Make Web Audio tests context-rate-independent (disabling some decodeAudioData tests). r=ehsan
--HG--
extra : rebase_source : c625c50a08da1871e79851c2a824b0e3ea170eba
2013-02-05 10:57:36 +13:00

59 lines
1.6 KiB
HTML

<!DOCTYPE HTML>
<html>
<head>
<title>Test GainNode</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">
SimpleTest.waitForExplicitFinish();
addLoadEvent(function() {
SpecialPowers.setBoolPref("media.webaudio.enabled", true);
var context = new AudioContext();
var buffer = context.createBuffer(1, 2048, context.sampleRate);
for (var i = 0; i < 2048; ++i) {
buffer.getChannelData(0)[i] = Math.sin(440 * 2 * Math.PI * i / context.sampleRate);
}
var destination = context.destination;
var source = context.createBufferSource();
var gain = context.createGain();
source.buffer = buffer;
source.connect(gain);
gain.connect(destination);
ok(gain.gain, "The audioparam member must exist");
is(gain.gain.value, 1.0, "Correct initial value");
is(gain.gain.defaultValue, 1.0, "Correct default value");
is(gain.gain.minValue, 0, "Correct min value");
is(gain.gain.maxValue, 1.0, "Correct max value");
gain.gain.value = 0.5;
is(gain.gain.value, 0.5, "Correct initial value");
is(gain.gain.defaultValue, 1.0, "Correct default value");
is(gain.gain.minValue, 0, "Correct min value");
is(gain.gain.maxValue, 1.0, "Correct max value");
source.start(0);
SimpleTest.executeSoon(function() {
source.stop(0);
source.disconnect();
gain.disconnect();
SpecialPowers.clearUserPref("media.webaudio.enabled");
SimpleTest.finish();
});
});
</script>
</pre>
</body>
</html>