Bug 1149494 - Part 2: Add mochitest. r=jesup, a=sledru
authorAndreas Pehrson <pehrsons@gmail.com>
Wed, 08 Apr 2015 17:59:30 +1200
changeset 266961 4ad26ed2c2e9f4b9c69dd543e8a96b5f171097e4
parent 266960 3aa52ed1f8d95b59d812e071357c0f2e30661750
child 266962 3034a08beebdd0f59ae2a693b916cf76fa722c2f
push id830
push userraliiev@mozilla.com
push dateFri, 19 Jun 2015 19:24:37 +0000
treeherdermozilla-release@932614382a68 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjesup, sledru
bugs1149494
milestone39.0a2
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 == 'mulet' || buildapp == 'b2g' || toolkit == 'android' # no screenshare on b2g/android # Bug 1141029 Mulet parity with B2G Desktop for TC
 [test_getUserMedia_basicWindowshare.html]
 skip-if = buildapp == 'mulet' || 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' && 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>