|
| 1 | +<!DOCTYPE HTML> |
| 2 | +<html> |
| 3 | +<head> |
| 4 | + <title>Invalid formats raise decode errors with default messages for CORS cross-origin media</title> |
| 5 | + <script src="/tests/SimpleTest/SimpleTest.js"></script> |
| 6 | + <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" /> |
| 7 | + <script type="text/javascript" src="manifest.js"></script> |
| 8 | +</head> |
| 9 | +<body> |
| 10 | +<pre id="test"> |
| 11 | +<script class="testbody" type="text/javascript"> |
| 12 | +const manager = new MediaTestManager; |
| 13 | +let gotErrSrcNotSupported = false; |
| 14 | +let gotErrDecode = false; |
| 15 | + |
| 16 | +function startTest(test, token) { |
| 17 | + const is = function(a, b, name) { |
| 18 | + SimpleTest.is(a, b, `${test.name}: ${name}`); |
| 19 | + }; |
| 20 | + const v = document.createElement("video"); |
| 21 | + manager.started(token); |
| 22 | + v.addEventListener("error", event => { |
| 23 | + if (v.readyState == v.HAVE_NOTHING) { |
| 24 | + is(v.error.code, MediaError.MEDIA_ERR_SRC_NOT_SUPPORTED, |
| 25 | + "Expected code for a load error"); |
| 26 | + is(v.error.message, "Failed to open media", |
| 27 | + "Expected message for a load error"); |
| 28 | + gotErrSrcNotSupported = true; |
| 29 | + } else { |
| 30 | + is(v.error.code, MediaError.MEDIA_ERR_DECODE, |
| 31 | + "Expected code for a decode error"); |
| 32 | + is(v.error.message, "Failed to decode media", |
| 33 | + "Expected message for a decode error"); |
| 34 | + gotErrDecode = true; |
| 35 | + } |
| 36 | + manager.finished(token); |
| 37 | + }); |
| 38 | + |
| 39 | + v.autoplay = true; |
| 40 | + |
| 41 | + // CORS-cross-origin URL. |
| 42 | + v.src = `http://example.com/tests/dom/media/test/${test.name}`; |
| 43 | +} |
| 44 | + |
| 45 | +gTestPrefs.push(["media.cache_size", 40000]); |
| 46 | +manager.onFinished = () => { |
| 47 | + ok(gotErrSrcNotSupported, "At least one test led to src-not-supported"); |
| 48 | + ok(gotErrDecode, "At least one test led to a decode error"); |
| 49 | +}; |
| 50 | +manager.runTests(gErrorTests, startTest); |
| 51 | +</script> |
| 52 | +</pre> |
| 53 | +</body> |
| 54 | +</html> |
0 commit comments