Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(27)

Unified Diff: LayoutTests/media/video-capture-canvas.html

Issue 428263004: Revert of Delete mediaPlaybackRequiresUserGesture (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: LayoutTests/media/video-capture-canvas.html
diff --git a/LayoutTests/media/video-capture-canvas.html b/LayoutTests/media/video-capture-canvas.html
new file mode 100644
index 0000000000000000000000000000000000000000..f11faf5d0fc01bca6eb5ff4011e5f65c7e3423cc
--- /dev/null
+++ b/LayoutTests/media/video-capture-canvas.html
@@ -0,0 +1,69 @@
+<!DOCTYPE HTML">
+<html>
+<head>
+<script src=media-file.js></script>
+<script src=video-test.js></script>
+<script src=video-played.js></script>
+<script src="../resources/js-test.js"></script>
+
+<script type="text/javascript">
+
+if (window.internals)
+ window.internals.settings.setMediaPlaybackRequiresUserGesture(true);
+
+function gotStream(stream)
+{
+ consoleWrite("got a stream");
+ previewURL = URL.createObjectURL(stream);
+ video.src = previewURL;
+ consoleWrite("start preview");
+}
+
+function gotStreamFailed(error)
+{
+ consoleWrite("Failed to get access to local media. Error code was " + error.code);
+}
+
+function canplaythrough()
+{
+ width = canvas.width;
+ height = canvas.height;
+ ctx = canvas.getContext("2d");
+ ctx.fillStyle = 'black';
+ ctx.fillRect(0, 0, width, height);
+
+ consoleWrite("paint to canvas");
+ ctx.drawImage(video, 0, 0, width, height);
+ shouldBeTrue("!!ctx.getImageData(0, 0, width, height)");
+
+ frame = ctx.getImageData(0, 0, width, height);
+ r = frame.data[0];
+ g = frame.data[1];
+ b = frame.data[2];
+ testExpected("r+g+b", 0, "!=");
+ endTest();
+}
+
+function playPreview()
+{
+ findMediaElement();
+ canvas = document.getElementsByTagName('canvas')[0];
+ try {
+ consoleWrite("request access to local media");
+ navigator.webkitGetUserMedia({video:true}, gotStream, gotStreamFailed);
+ } catch (e) {
+ consoleWrite("getUserMedia error " + "(" + e.name + " / " + e.message + ")");
+ }
+
+ waitForEvent('canplaythrough', canplaythrough);
+}
+
+</script>
+</head>
+
+<body onload="playPreview()">
+<video width="320" height="240" autoplay="autoplay"></video>
+<canvas width="1" height="1" ></canvas>
+</body>
+</html>
+

Powered by Google App Engine
This is Rietveld 408576698