Source code

Revision control

Copy as Markdown

Other Tools

Test Info:

<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>
<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;
a.src =; =;
// Tags should not be available immediately.
var exception_fired = false;
try {
} catch (e) {
is(, 'InvalidStateError',
"early mozGetMetadata() should throw InvalidStateError");
exception_fired = true;
"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 ''</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;
// 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");
manager.runTests(gMetadataTests, startTest);