Bug 1240478 - Add test for video size on 'loadedmetadata'. r=jesup,jib
authorAndreas Pehrson <pehrsons@gmail.com>
Thu, 21 Jan 2016 19:42:55 +0800
changeset 327093 ca4fa9403dc62a083491d8083a6f21547a3ea0c4
parent 327092 16928e1771cad373a1f9f7c3503b4041ba3333d0
child 327094 b35aa9ae63e8f6a1ad074ac3bd96348093a0e688
push id10194
push userdmitchell@mozilla.com
push dateFri, 29 Jan 2016 17:28:53 +0000
reviewersjesup, jib
bugs1240478
milestone47.0a1
Bug 1240478 - Add test for video size on 'loadedmetadata'. r=jesup,jib
dom/media/tests/mochitest/mochitest.ini
dom/media/tests/mochitest/test_getUserMedia_loadedmetadata.html
--- a/dom/media/tests/mochitest/mochitest.ini
+++ b/dom/media/tests/mochitest/mochitest.ini
@@ -49,16 +49,17 @@ skip-if = buildapp == 'b2g' || toolkit =
 skip-if = buildapp == 'b2g' || toolkit == 'android' # no windowshare on b2g/android # Bug 1141029 Mulet parity with B2G Desktop for TC
 [test_getUserMedia_basicVideoAudio.html]
 skip-if = (toolkit == 'gonk' || buildapp == 'mulet' && debug) # debug-only failure, turned an intermittent (bug 962579) into a permanant orange
 [test_getUserMedia_bug1223696.html]
 [test_getUserMedia_constraints.html]
 [test_getUserMedia_callbacks.html]
 skip-if = toolkit == 'gonk' || buildapp == 'mulet' # Bug 1063290, intermittent timeout # TC: Bug 1144079 - Re-enable Mulet mochitests and reftests taskcluster-specific disables.
 [test_getUserMedia_gumWithinGum.html]
+[test_getUserMedia_loadedmetadata.html]
 [test_getUserMedia_mediaStreamConstructors.html]
 [test_getUserMedia_playAudioTwice.html]
 [test_getUserMedia_playVideoAudioTwice.html]
 [test_getUserMedia_playVideoTwice.html]
 [test_getUserMedia_spinEventLoop.html]
 skip-if = (toolkit == 'gonk' || buildapp == 'mulet' && debug) # copied from basicAudio
 [test_getUserMedia_stopAudioStream.html]
 [test_getUserMedia_stopAudioStreamWithFollowupAudio.html]
new file mode 100644
--- /dev/null
+++ b/dom/media/tests/mochitest/test_getUserMedia_loadedmetadata.html
@@ -0,0 +1,36 @@
+<!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");
+    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>