test for disabled track rendering
authorDominique Hazael-Massieux <dom@w3.org>
Tue, 04 Jun 2013 13:03:15 +0200
changeset 66 053a63e54839
parent 65 8cf68a742192
child 67 59076e347350
test for disabled track rendering
submitted/W3C/disabled-video-black.html
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/submitted/W3C/disabled-video-black.html	Tue Jun 04 13:03:15 2013 +0200
@@ -0,0 +1,52 @@
+<!doctype html>
+<html>
+<head>
+<title>getUserMedia({video:true}) creates a stream with one video track</title>
+<link rel="author" title="Dominique Hazael-Massieux" href="mailto:[email protected]"/>
+<link rel="help" href="http://dev.w3.org/2011/webrtc/editor/getusermedia.html#navigatorusermedia">
+<link rel='stylesheet' href='/resources/testharness.css' media='all'/>
+</head>
+<body>
+<p>When prompted, accept to share your video stream.</p>
+<h1>Description</h1>
+<p>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=featuredetection.js></script>
+<script src=prefix.js></script>
+<script>
+var vid = document.getElementById("vid");
+var cv = document.createElement("canvas");
+var t = async_test("Tests that a disabled video track in a MediaStream is rendered as blackness", {timeout: 10000});
+t.step(function() {
+  navigator.getUserMedia({video: true}, t.step_func(function (stream) {
+    // TODO remove when prefixes are gone
+    var srcObjName = FeatureNameInBrowser(vid, "srcObject");
+    var testOncePlaying = function() {
+       vid.removeEventListener("timeupdate", testOncePlaying, false);
+       stream.getVideoTracks()[0].enabled = 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);
+       }
+       t.done();
+    }
+    vid[srcObjName] = stream;
+    vid.play();
+    vid.addEventListener("timeupdate", t.step_func(testOncePlaying), false);
+
+  }), function(error) {});
+});
+</script>
+</body>
+</html>