Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / media / video-capture-canvas.html
blobf11faf5d0fc01bca6eb5ff4011e5f65c7e3423cc
1 <!DOCTYPE HTML">
2 <html>
3 <head>
4 <script src=media-file.js></script>
5 <script src=video-test.js></script>
6 <script src=video-played.js></script>
7 <script src="../resources/js-test.js"></script>
9 <script type="text/javascript">
11 if (window.internals)
12 window.internals.settings.setMediaPlaybackRequiresUserGesture(true);
14 function gotStream(stream)
16 consoleWrite("got a stream");
17 previewURL = URL.createObjectURL(stream);
18 video.src = previewURL;
19 consoleWrite("start preview");
22 function gotStreamFailed(error)
24 consoleWrite("Failed to get access to local media. Error code was " + error.code);
27 function canplaythrough()
29 width = canvas.width;
30 height = canvas.height;
31 ctx = canvas.getContext("2d");
32 ctx.fillStyle = 'black';
33 ctx.fillRect(0, 0, width, height);
35 consoleWrite("paint to canvas");
36 ctx.drawImage(video, 0, 0, width, height);
37 shouldBeTrue("!!ctx.getImageData(0, 0, width, height)");
39 frame = ctx.getImageData(0, 0, width, height);
40 r = frame.data[0];
41 g = frame.data[1];
42 b = frame.data[2];
43 testExpected("r+g+b", 0, "!=");
44 endTest();
47 function playPreview()
49 findMediaElement();
50 canvas = document.getElementsByTagName('canvas')[0];
51 try {
52 consoleWrite("request access to local media");
53 navigator.webkitGetUserMedia({video:true}, gotStream, gotStreamFailed);
54 } catch (e) {
55 consoleWrite("getUserMedia error " + "(" + e.name + " / " + e.message + ")");
58 waitForEvent('canplaythrough', canplaythrough);
61 </script>
62 </head>
64 <body onload="playPreview()">
65 <video width="320" height="240" autoplay="autoplay"></video>
66 <canvas width="1" height="1" ></canvas>
67 </body>
68 </html>