Bug 1149494 - Part 2: Add mochitest. r=jesup, a=jocheng
--- a/dom/media/tests/mochitest/mochitest.ini
+++ b/dom/media/tests/mochitest/mochitest.ini
@@ -29,16 +29,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>