gecko/content/media/test/test_wave_data_s16.html
Chris Double bd28db8dee Bug 635649 - Refactor Wave backend to use content/media nsBuiltinDecoder framework - r=kinetik
commit c7e190d81b10e7425b53217352c126adfbb79c4a
Author: Chris Double <chris.double@double.co.nz>
Date:   Thu Mar 24 18:09:06 2011 +1300

    Fix
2011-03-30 18:37:42 +13:00

54 lines
1.5 KiB
HTML

<!DOCTYPE HTML>
<html>
<head>
<title>Wave Media test: ended</title>
<script type="text/javascript" src="/MochiKit/packed.js"></script>
<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">
// Test if the ended event works correctly.
var endPassed = false;
var completed = false;
function audioavailable(e) {
if (completed)
return false;
completed = true;
var samples = e.frameBuffer;
var time = e.time;
ok(samples.length >= 3, "Must be 3 or more samples. There were " + samples.length);
if (samples.length >= 3) {
ok(samples[0] > 0.99 && samples[0] < 1.01, "First sound sample should be close to 1.0. It was " + samples[0]);
ok(samples[1] > -1.01 && samples [1] < 0.01, "Second sound sample should be close to -1.0. It was " + samples[1]);
ok(samples[2] > -0.01 && samples[2] < 0.01, "Third sound sample should be close to 0. It was " + samples[2]);
}
// Only care about the first few samples
SimpleTest.finish();
return false;
}
function startTest() {
if (completed)
return false;
var v = document.getElementById('v');
v.addEventListener('MozAudioAvailable', audioavailable, false);
v.play();
return false;
}
SimpleTest.waitForExplicitFinish();
</script>
</pre>
<audio id='v'
onloadedmetadata='return startTest();'>
<source type='audio/x-wav' src='wavedata_s16.wav'>
</audio>
</body>
</html>