mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-01 14:45:29 +00:00
55 lines
1.6 KiB
HTML
55 lines
1.6 KiB
HTML
<!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)
|
|
return;
|
|
|
|
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.99, "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();
|
|
}
|
|
|
|
function startTest() {
|
|
if (completed)
|
|
return;
|
|
SpecialPowers.pushPrefEnv({"set": [["media.audio_data.enabled", true]]},
|
|
function () {
|
|
var v = document.getElementById('v');
|
|
v.addEventListener('MozAudioAvailable', audioavailable, false);
|
|
v.play();
|
|
});
|
|
}
|
|
|
|
SimpleTest.waitForExplicitFinish();
|
|
</script>
|
|
</pre>
|
|
<audio id='v'
|
|
preload="metadata"
|
|
onloadedmetadata='return startTest();'>
|
|
<source type='audio/x-wav' src='wavedata_u8.wav'>
|
|
</audio>
|
|
</body>
|
|
</html>
|