<!DOCTYPE html>
<title>Test "ended" event fires again after changing source after "ended" event.</title>
<script src="../resources/testharness.js"></script>
<script src="../resources/testharnessreport.js"></script>
<audio autoplay></audio>
<script>
async_test(function(t) {
var endedCount = 0;
var audio = document.querySelector("audio");
audio.onended = t.step_func(function() {
switch (++endedCount)
{
case 1:
assert_greater_than(audio.playbackRate, 0);
assert_true(audio.ended);
// Verify ended stays true even if playbackRate == 0
// since that is technically still "forward".
audio.playbackRate = 0;
assert_true(audio.ended);
try {
audio.playbackRate = -0.1;
} catch (exception) {
// "Backward" playback is not supported.
assert_equals(exception.name, "NotSupportedError")
}
// Change src but don't seek so that internal state isn't reset.
audio.src = "content/silence.oga";
assert_false(audio.ended);
break;
case 2:
assert_true(audio.ended);
t.done();
break;
}
});
audio.src = "content/silence.oga"
});
</script>