diff options
author | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
---|---|---|
committer | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
commit | 5f8de423f190bbb79a62f804151bc24824fa32d8 (patch) | |
tree | 10027f336435511475e392454359edea8e25895d /dom/media/tests/mochitest/test_getUserMedia_mediaElementCapture_video.html | |
parent | 49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff) | |
download | UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip |
Add m-esr52 at 52.6.0
Diffstat (limited to 'dom/media/tests/mochitest/test_getUserMedia_mediaElementCapture_video.html')
-rw-r--r-- | dom/media/tests/mochitest/test_getUserMedia_mediaElementCapture_video.html | 130 |
1 files changed, 130 insertions, 0 deletions
diff --git a/dom/media/tests/mochitest/test_getUserMedia_mediaElementCapture_video.html b/dom/media/tests/mochitest/test_getUserMedia_mediaElementCapture_video.html new file mode 100644 index 000000000..a1097094e --- /dev/null +++ b/dom/media/tests/mochitest/test_getUserMedia_mediaElementCapture_video.html @@ -0,0 +1,130 @@ +<!DOCTYPE HTML> +<html> +<head> + <script type="application/javascript" src="/tests/dom/canvas/test/captureStream_common.js"></script> + <script type="application/javascript" src="mediaStreamPlayback.js"></script> + <script type="application/javascript" src="head.js"></script> +</head> +<body> +<pre id="test"> +<script> + +createHTML({ + bug: "1259788", + title: "Test CaptureStream video content on HTMLMediaElement playing a gUM MediaStream", + visible: true +}); + +var gUMVideoElement; +var captureStreamElement; + +// We check a pixel somewhere away from the top left corner since +// MediaEngineDefault puts semi-transparent time indicators there. +const offsetX = 20; +const offsetY = 20; +const threshold = 16; +const pausedTimeout = 1000; +const h = new CaptureStreamTestHelper2D(50, 50); + +var checkHasFrame = video => h.waitForPixel(video, offsetX, offsetY, px => { + let result = h.isOpaquePixelNot(px, h.black, threshold); + info("Checking that we have a frame, got [" + + Array.slice(px) + "]. Pass=" + result); + return result; +}); + +var checkVideoPlaying = video => checkHasFrame(video) + .then(() => { + let startPixel = { data: h.getPixel(video, offsetX, offsetY) + , name: "startcolor" + }; + return h.waitForPixel(video, offsetX, offsetY, px => { + let result = h.isPixelNot(px, startPixel, threshold) + info("Checking playing, [" + Array.slice(px) + "] vs [" + + Array.slice(startPixel.data) + "]. Pass=" + result); + return result; + }); + }); + +var checkVideoPaused = video => checkHasFrame(video) + .then(() => { + let startPixel = { data: h.getPixel(video, offsetX, offsetY) + , name: "startcolor" + }; + return h.waitForPixel(video, offsetX, offsetY, px => { + let result = h.isOpaquePixelNot(px, startPixel, threshold); + info("Checking paused, [" + Array.slice(px) + "] vs [" + + Array.slice(startPixel.data) + "]. Pass=" + result); + return result; + }, pausedTimeout); + }).then(result => ok(!result, "Frame shouldn't change within " + pausedTimeout / 1000 + " seconds.")); + +runTest(() => getUserMedia({video: true, fake: true}) + .then(stream => { + gUMVideoElement = + createMediaElement("video", "gUMVideo"); + gUMVideoElement.srcObject = stream; + gUMVideoElement.play(); + + info("Capturing"); + captureStreamElement = + createMediaElement("video", "captureStream"); + captureStreamElement.srcObject = gUMVideoElement.mozCaptureStream(); + captureStreamElement.play(); + + // Adding a dummy audio track to the stream will keep a consuming media + // element from ending. + // We could also solve it by repeatedly play()ing or autoplay, but then we + // wouldn't be sure the media element stopped rendering video because it + // went to the ended state or because there were no frames for the track. + let osc = createOscillatorStream(new AudioContext(), 1000); + captureStreamElement.srcObject.addTrack(osc.getTracks()[0]); + + return checkVideoPlaying(captureStreamElement); + }) + .then(() => { + info("Video flowing. Pausing."); + gUMVideoElement.pause(); + + return checkVideoPaused(captureStreamElement); + }) + .then(() => { + info("Video stopped flowing. Playing."); + gUMVideoElement.play(); + + return checkVideoPlaying(captureStreamElement); + }) + .then(() => { + info("Video flowing. Removing source."); + var stream = gUMVideoElement.srcObject; + gUMVideoElement.srcObject = null; + + return checkVideoPaused(captureStreamElement).then(() => stream); + }) + .then(stream => { + info("Video stopped flowing. Setting source."); + gUMVideoElement.srcObject = stream; + return checkVideoPlaying(captureStreamElement); + }) + .then(() => { + info("Video flowing. Changing source by track manipulation. Remove first."); + var track = gUMVideoElement.srcObject.getTracks()[0]; + gUMVideoElement.srcObject.removeTrack(track); + return checkVideoPaused(captureStreamElement).then(() => track); + }) + .then(track => { + info("Video paused. Changing source by track manipulation. Add first."); + gUMVideoElement.srcObject.addTrack(track); + gUMVideoElement.play(); + return checkVideoPlaying(captureStreamElement); + }) + .then(() => { + gUMVideoElement.srcObject.getTracks().forEach(t => t.stop()); + ok(true, "Test passed."); + }) + .catch(e => ok(false, "Test failed: " + e + (e.stack ? "\n" + e.stack : "")))); + +</script> +</pre> +</body> +</html> |