summaryrefslogtreecommitdiffstats
path: root/dom/media/test/test_metadata.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_metadata.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_metadata.html')
-rw-r--r--dom/media/test/test_metadata.html81
1 files changed, 81 insertions, 0 deletions
diff --git a/dom/media/test/test_metadata.html b/dom/media/test/test_metadata.html
new file mode 100644
index 0000000000..2fc6ddffec
--- /dev/null
+++ b/dom/media/test/test_metadata.html
@@ -0,0 +1,81 @@
+<!DOCTYPE HTML>
+<html>
+<head>
+ <meta charset="utf-8">
+ <title>Test returning metadata from media files with mozGetMetadata()</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">
+<div id="output"></div>
+<script class="testbody" type="text/javascript">
+
+var manager = new MediaTestManager;
+
+function startTest(test, token) {
+ var a = document.createElement('audio');
+ a.preload = "metadata";
+ a.token = token;
+ manager.started(token);
+
+ a.src = test.name;
+ a.name = test.name;
+
+ // Tags should not be available immediately.
+ var exception_fired = false;
+ try {
+ a.mozGetMetadata();
+ } catch (e) {
+ is(e.name, 'InvalidStateError',
+ "early mozGetMetadata() should throw InvalidStateError");
+ exception_fired = true;
+ }
+ ok(exception_fired,
+ "mozGetMetadata() should throw an exception before HAVE_METADATA");
+
+ // Wait until metadata has loaded.
+ a.addEventListener('loadedmetadata', function() {
+ // read decoded tags
+ let tags = a.mozGetMetadata();
+ ok(tags, "mozGetMetadata() should return a truthy value");
+ // Dump them out.
+ var d = document.getElementById('output');
+ var html = '<table>\n';
+ html += '<caption><p>Called getMozMetadata()'
+ html += ' on '+test.name+'</p></caption>\n';
+ html += '<tr><th>tag</th>';
+ html += '<th>decoded value</th><th>expected value</th></tr>\n';
+ for (let tag in tags) {
+ html += '<tr><td>'+tag+'</td>';
+ html += '<td>'+tags[tag]+'</td>';
+ html += '<td>'+test.tags[tag]+'</td>';
+ html += '</tr>\n';
+ }
+ if (!Object.keys(tags).length) {
+ html += '<tr><td colspan=3 align=center><em>no tags</em></td></tr>\n';
+ }
+ html += '</table>\n';
+ var div = document.createElement('div');
+ div.innerHTML = html;
+ d.appendChild(div);
+ // Verify decoded tag values.
+ for (let tag in tags) {
+ is(tags[tag], test.tags[tag], "Tag '"+tag+"' should match");
+ }
+ // Verify expected tag values
+ for (let tag in test.tags) {
+ is(tags[tag], test.tags[tag], "Tag '"+tag+"' should match");
+ }
+ removeNodeAndSource(a);
+ manager.finished(token);
+ });
+}
+
+manager.runTests(gMetadataTests, startTest);
+
+</script>
+</pre>
+</body>
+</html>