dom/media/tests/mochitest/test_getUserMedia_loadedmetadata.html
author Alex Chronopoulos <achronop@gmail.com>
Wed, 28 Sep 2016 13:43:41 +0300
changeset 418328 843bbaa0f3f54424862645e2c0fbe139b501fb9f
parent 408395 63d043a689cac950bcebd9eec0a7e583d2612f03
child 427402 d921975370c727914809408b2a7402532b255779
permissions -rw-r--r--
Bug 1256079 - Append video element to the document. r=pehrsons MozReview-Commit-ID: F0tGd4kk0mD

<!DOCTYPE HTML>
<html>
<head>
  <script type="application/javascript" src="mediaStreamPlayback.js"></script>
</head>
<body>
<pre id="test">
<script type="application/javascript">
  createHTML({
    title: "getUserMedia in media element should have video dimensions on loadedmetadata",
    bug: "1240478"
  });
  /**
   * Tests that assigning a stream to a media element results in the
   * "loadedmetadata" event without having to play() the media element.
   *
   * Also makes sure that the video size has been set on "loadedmetadata".
   */
  runTest(function () {
    var v = document.createElement("video");
    document.body.appendChild(v);
    v.preload = "metadata";

    var constraints = {video: true, audio: true};
    return getUserMedia(constraints).then(stream => new Promise(resolve => {
      v.srcObject = stream;
      v.onloadedmetadata = resolve;
    })).then(() => {
      isnot(v.videoWidth, 0, "videoWidth shall be set on 'loadedmetadata'");
      isnot(v.videoHeight, 0, "videoHeight shall be set on 'loadedmetadata'");
    });
  });

</script>
</pre>
</body>
</html>