dom/media/test/test_streams_tracks.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>Test MediaStreamTrack interfaces</title>
  <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 testTracks(tracks, hasTrack, kind, src) {
  is(tracks.length, hasTrack ? 1 : 0, "Correct track count for " + src);
  for (var i = 0; i < tracks.length; ++i) {
    var track = tracks[i];
    is(track.kind, kind, "Correct track kind for track " + i + " of " + src);
    var id = track.id;
    ok(/\{........-....-....-....-............\}/.test(track.id),
       "id " + track.id + " for track " + i + " of " + src + " has correct form");
  }
}

function onended(e) {
  var t = e.target;
  var audioTracks = t.stream.getAudioTracks();
  var videoTracks = t.stream.getVideoTracks();

  testTracks(audioTracks, t.test.hasAudio, "audio", t.src);
  testTracks(videoTracks, t.test.hasVideo, "video", t.src);

  manager.finished(t.token);
}

function startTest(test, token) {
  var element = document.createElement("video");

  element.token = token;
  manager.started(token);

  element.src = test.name;
  element.test = test;
  element.stream = element.mozCaptureStreamUntilEnded();
  element.addEventListener("ended", onended);

  element.play();
}

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