summaryrefslogtreecommitdiffstats
path: root/dom/media/test/test_decode_error.html
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 00:47:55 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 00:47:55 +0000
commit26a029d407be480d791972afb5975cf62c9360a6 (patch)
treef435a8308119effd964b339f76abb83a57c29483 /dom/media/test/test_decode_error.html
parentInitial commit. (diff)
downloadfirefox-26a029d407be480d791972afb5975cf62c9360a6.tar.xz
firefox-26a029d407be480d791972afb5975cf62c9360a6.zip
Adding upstream version 124.0.1.upstream/124.0.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'dom/media/test/test_decode_error.html')
-rw-r--r--dom/media/test/test_decode_error.html66
1 files changed, 66 insertions, 0 deletions
diff --git a/dom/media/test/test_decode_error.html b/dom/media/test/test_decode_error.html
new file mode 100644
index 0000000000..27b83cd3f9
--- /dev/null
+++ b/dom/media/test/test_decode_error.html
@@ -0,0 +1,66 @@
+<!DOCTYPE HTML>
+<html>
+<head>
+ <title>Media test: unknown/invalid formats raise decode error</title>
+ <script src="/tests/SimpleTest/SimpleTest.js"></script>
+ <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
+ <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 ok = function (condition, name) {
+ SimpleTest.ok(condition, test.name + ": " + name);
+ }
+ var is = function (a, b, name) {
+ SimpleTest.is(a, b, test.name + ": " + name);
+ }
+
+ 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");
+ if (v.readyState == v.HAVE_NOTHING) {
+ is(el.error.code, MediaError.MEDIA_ERR_SRC_NOT_SUPPORTED, "Expected media not supported error");
+ } else {
+ is(el.error.code, MediaError.MEDIA_ERR_DECODE, "Expected a decode error");
+ }
+ ok(typeof el.error.message === 'string' || el.error.message instanceof String, "Element 'message' attr expected to be a string");
+ ok(el.error.message.length, "Element 'message' attr has content");
+ el._sawError = true;
+ manager.finished(token);
+ });
+
+ v.addEventListener("loadeddata", function () {
+ ok(false, "Unexpected loadeddata event");
+ manager.finished(token);
+ });
+
+ v.autoplay = true;
+ v.addEventListener("ended", function () {
+ ok(false, "Unexpected ended event");
+ manager.finished(token);
+ });
+
+ v.src = test.name; // implicitly starts a load.
+}
+
+SimpleTest.waitForExplicitFinish();
+SpecialPowers.pushPrefEnv({
+ "set": [
+ ["media.cache_size", 40000],
+ ]
+}, beginTest);
+function beginTest() {
+ manager.runTests(gDecodeErrorTests, startTest);
+}
+</script>
+</pre>
+</body>
+</html>