diff options
Diffstat (limited to 'testing/web-platform/tests/mediacapture-streams/MediaStreamTrack-MediaElement-disabled-video-is-black.https.html')
-rw-r--r-- | testing/web-platform/tests/mediacapture-streams/MediaStreamTrack-MediaElement-disabled-video-is-black.https.html | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/testing/web-platform/tests/mediacapture-streams/MediaStreamTrack-MediaElement-disabled-video-is-black.https.html b/testing/web-platform/tests/mediacapture-streams/MediaStreamTrack-MediaElement-disabled-video-is-black.https.html new file mode 100644 index 0000000000..3652362b84 --- /dev/null +++ b/testing/web-platform/tests/mediacapture-streams/MediaStreamTrack-MediaElement-disabled-video-is-black.https.html @@ -0,0 +1,56 @@ +<!doctype html> +<html> +<head> +<title>A disabled video track is rendered as blackness</title> +<link rel="author" title="Dominique Hazael-Massieux" href="mailto:dom@w3.org"/> +<link rel="help" href="http://dev.w3.org/2011/webrtc/editor/getusermedia.html#introduction"> +<link rel="help" href="http://dev.w3.org/2011/webrtc/editor/getusermedia.html#mediastreams-as-media-elements"> +</head> +<body> +<p class="instructions">When prompted, accept to share your video stream.</p> +<h1 class="instructions">Description</h1> +<p class="instructions">This test checks that a disabled video track in a +MediaStream is rendered as blackness.</p> +<video id="vid"></video> + +<div id='log'></div> +<script src=/resources/testharness.js></script> +<script src=/resources/testharnessreport.js></script> +<script src=/resources/testdriver.js></script> +<script src=/resources/testdriver-vendor.js></script> +<script src=permission-helper.js></script> +<script> +const vid = document.getElementById("vid"); +const cv = document.createElement("canvas"); +promise_test(async () => { + await setMediaPermission("granted", ["camera"]); + const stream = await navigator.mediaDevices.getUserMedia({video: true}); + if (stream.getVideoTracks()[0].enabled) { + stream.getVideoTracks()[0].enabled = false; + } + + let resolveLoadedPromise; + const videoLoaded = new Promise(res => resolveLoadedPromise = res) + var testOnceLoadeddata = function() { + vid.removeEventListener("loadeddata", testOnceLoadeddata, false); + cv.width = vid.offsetWidth; + cv.height = vid.offsetHeight; + var ctx = cv.getContext("2d"); + ctx.drawImage(vid,0,0); + var imageData = ctx.getImageData(0, 0, cv.width, cv.height); + for (var i = 0; i < imageData.data.length; i+=4) { + assert_equals(imageData.data[i], 0, "No red component in pixel #" + i); + assert_equals(imageData.data[i + 1], 0, "No green component in pixel #" + i); + assert_equals(imageData.data[i + 2], 0, "No blue component in pixel #" + i); + assert_equals(imageData.data[i + 3], 255, "No transparency in pixel #" + i); + } + resolveLoadedPromise(); + }; + + vid.srcObject = stream; + vid.play(); + vid.addEventListener("loadeddata", testOnceLoadeddata, false); +}, "Tests that a disabled video track in a MediaStream is rendered as blackness"); +</script> +</body> +</html> |