2011-03-30 05:37:42 +00:00
|
|
|
<!DOCTYPE HTML>
|
|
|
|
<html>
|
|
|
|
<head>
|
|
|
|
<title>Wave Media test: ended</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">
|
|
|
|
// Test if the ended event works correctly.
|
|
|
|
var endPassed = false;
|
|
|
|
var completed = false;
|
|
|
|
|
|
|
|
function audioavailable(e) {
|
|
|
|
if (completed)
|
2012-08-15 04:41:24 +00:00
|
|
|
return;
|
2011-03-30 05:37:42 +00:00
|
|
|
|
|
|
|
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]);
|
2011-03-31 01:08:49 +00:00
|
|
|
ok(samples[1] > -1.01 && samples [1] < -0.99, "Second sound sample should be close to -1.0. It was " + samples[1]);
|
2011-03-30 05:37:42 +00:00
|
|
|
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();
|
|
|
|
}
|
|
|
|
|
|
|
|
function startTest() {
|
|
|
|
if (completed)
|
2012-08-15 04:41:24 +00:00
|
|
|
return;
|
2011-03-30 05:37:42 +00:00
|
|
|
var v = document.getElementById('v');
|
|
|
|
v.addEventListener('MozAudioAvailable', audioavailable, false);
|
|
|
|
v.play();
|
|
|
|
}
|
|
|
|
|
|
|
|
SimpleTest.waitForExplicitFinish();
|
|
|
|
</script>
|
|
|
|
</pre>
|
|
|
|
<audio id='v'
|
|
|
|
onloadedmetadata='return startTest();'>
|
|
|
|
<source type='audio/x-wav' src='wavedata_u8.wav'>
|
|
|
|
</audio>
|
|
|
|
</body>
|
|
|
|
</html>
|