gecko/content/media/test/test_decode_error.html

54 lines
1.8 KiB
HTML

<!DOCTYPE HTML>
<html>
<head>
<title>Media test: unknown/invalid formats raise decode error</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" />
<script type="text/javascript" src="use_large_cache.js"></script>
<script type="text/javascript" src="manifest.js"></script>
</head>
<body>
<pre id="test">
<script class="testbody" type="text/javascript">
var manager = new MediaTestManager;
function startTest(test, token) {
var v = document.createElement("video");
manager.started(token);
v.addEventListener("error", function (event) {
var el = event.currentTarget;
is(event.type, "error", "Expected event of type 'error'");
ok(el.error, "Element 'error' attr expected to have a value");
ok(el.error instanceof MediaError, "Element 'error' attr expected to be MediaError");
is(el.error.code, MediaError.MEDIA_ERR_DECODE, "Expected a decode error");
is(el.networkState, HTMLMediaElement.NETWORK_EMPTY, "networkState should be EMPTY");
el._sawError = true;
}, false);
v.addEventListener("emptied", function (event) {
var el = event.currentTarget;
is(el.networkState, HTMLMediaElement.NETWORK_EMPTY, "networkState should be EMPTY");
ok(el._sawError, "Expected error event");
manager.finished(token);
}, false);
v.addEventListener("loadedmetadata", function () {
ok(false, "Unexpected loadedmetadata event");
}, false);
v.autoplay = true;
v.addEventListener("ended", function () {
ok(false, "Unexpected ended event");
}, false);
v.src = test.name; // implicitly starts a load.
}
manager.runTests(gDecodeErrorTests, startTest);
</script>
</pre>
</body>
</html>