Bug 1149494 - Part 2: Add mochitest. r=jesup, a=sledru
authorAndreas Pehrson <pehrsons@gmail.com>
Wed, 08 Apr 2015 17:59:30 +1200
changeset 258410 c821f76bf302
parent 258409 d46cb3b3ebb3
child 258411 e62ca3da49e1
push id4661
push userryanvm@gmail.com
push date2015-04-09 18:39 +0000
treeherdermozilla-beta@3f5e298cb641 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjesup, sledru
bugs1149494
milestone38.0
Bug 1149494 - Part 2: Add mochitest. r=jesup, a=sledru
dom/media/tests/mochitest/mochitest.ini
dom/media/tests/mochitest/test_getUserMedia_basicVideo_playAfterLoadedmetadata.html
--- a/dom/media/tests/mochitest/mochitest.ini
+++ b/dom/media/tests/mochitest/mochitest.ini
@@ -28,16 +28,18 @@ skip-if = toolkit == 'gonk' # b2g(Bug 96
 [test_dataChannel_bug1013809.html]
 skip-if = toolkit == 'gonk' # b2g emulator seems to be too slow (Bug 1016498 and 1008080)
 [test_dataChannel_noOffer.html]
 skip-if = toolkit == 'gonk' # b2g (Bug 1059867)
 [test_getUserMedia_basicAudio.html]
 skip-if = (toolkit == 'gonk' && debug) # debug-only failure
 [test_getUserMedia_basicVideo.html]
 skip-if = (toolkit == 'gonk' && debug) # debug-only failure
+[test_getUserMedia_basicVideo_playAfterLoadedmetadata.html]
+skip-if = (toolkit == 'gonk' && debug) # debug-only failure
 [test_getUserMedia_basicScreenshare.html]
 skip-if = buildapp == 'b2g' || toolkit == 'android' # no screenshare on b2g/android
 [test_getUserMedia_basicWindowshare.html]
 skip-if = buildapp == 'b2g' || toolkit == 'android' # no windowshare on b2g/android
 [test_getUserMedia_basicVideoAudio.html]
 skip-if = (toolkit == 'gonk' && debug) # debug-only failure, turned an intermittent (bug 962579) into a permanant orange
 [test_getUserMedia_constraints.html]
 skip-if = toolkit == 'gonk' || toolkit == 'android' # Bug 1063290, intermittent timeout
new file mode 100644
--- /dev/null
+++ b/dom/media/tests/mochitest/test_getUserMedia_basicVideo_playAfterLoadedmetadata.html
@@ -0,0 +1,43 @@
+<!DOCTYPE HTML>
+<html>
+<head>
+  <script type="application/javascript" src="mediaStreamPlayback.js"></script>
+</head>
+<body>
+<pre id="test">
+<script type="application/javascript">
+  createHTML({
+    title: "getUserMedia Basic Video shall receive 'loadedmetadata' without play()ing",
+    bug: "1149494"
+  });
+  /**
+   * Run a test to verify that we will always get 'loadedmetadata' from a video
+   * HTMLMediaElement playing a gUM MediaStream.
+   */
+  runTest(() => {
+    var testVideo = createMediaElement('video', 'testVideo');
+    var constraints = {video: true};
+
+    getUserMedia(constraints).then(aStream => {
+      checkMediaStreamTracks(constraints, aStream);
+
+      var playback = new LocalMediaStreamPlayback(testVideo, aStream);
+      var video = playback.mediaElement;
+
+      video.mozSrcObject = aStream;
+      return new Promise(resolve => {
+        ok(playback.mediaElement.paused,
+           "Media element should be paused before play()ing");
+        video.addEventListener('loadedmetadata', function() {
+          ok(video.videoWidth > 0, "Expected nonzero video width");
+          ok(video.videoHeight > 0, "Expected nonzero video width");
+          resolve();
+        });
+      });
+    }).then(() => SimpleTest.finish(), generateErrorCallback());
+  });
+
+</script>
+</pre>
+</body>
+</html>