dom/media/test/test_media_sniffer.html
author Dorel Luca <dluca@mozilla.com>
Sat, 12 Jan 2019 01:28:30 +0200
changeset 453595 c45da646fc6140bd59a36bda18f6cecde6163feb
parent 329662 7b434711753b98a87603453caaa0945791ffe12b
child 469641 ba6f655fd68963530c866d0d4a48c3db3d307777
permissions -rw-r--r--
Backed out changeset 24243f13c895 (bug 1519308) for build bustage in mozbuild/mozbuild/test/configure/test_checks_configure.py. CLOSED TREE

<!DOCTYPE HTML>
<html>
<head>
  <title>Media test: sniffing</title>
  <meta charset='utf-8'>
  <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="manifest.js"></script>
</head>
<body>
<pre id="test">
<script class="testbody" type="text/javascript">
var manager = new MediaTestManager;

function finish_test(element) {
  element.removeEventListener("error", onerror);
  removeNodeAndSource(element);
  manager.finished(element.token);
}

function onmetadataloaded(e) {
  var t = e.target;
  ++t.srcIndex;
  ok(true, "The media loads when loaded via " + t.src);
  if (t.srcIndex < t.srcList.length) {
    t.src = t.srcList[t.srcIndex];
  } else {
    finish_test(t);
  }
}

function onerror(e) {
  var t = e.target;
  t.removeEventListener('error', onerror);
  ok(false, "The media could not be loaded." + t.src + "\n");
  finish_test(t);
}

function startTest(test, token) {
  var elemType = /^audio/.test(test.type) ? "audio" : "video";
  var element = document.createElement(elemType);
  // This .sjs file serve the media file without Content-Type header, or with a
  // specific Content-Type header.
  var baseSrc = 'contentType.sjs?file=' + test.name;
  element.srcList = [
    baseSrc + "&nomime",
    baseSrc + "&type=application/octet-stream",
    baseSrc + "&type=audio/wav",
    baseSrc + "&type=text/html",
    baseSrc + "&type=absolute_nonsense"
  ];
  element.srcIndex = 0;
  element.src = element.srcList[element.srcIndex];
  element.token = token;
  element.controls = true;
  element.preload = "metadata";
  document.body.appendChild(element);
  manager.started(token);
  element.addEventListener("loadedmetadata", onmetadataloaded);
  element.addEventListener("error", onerror);
}

manager.runTests(gSnifferTests, startTest);
</script>
</pre>
</body>
</html>