Chromium Code Reviews| Index: third_party/WebKit/LayoutTests/media/video-canvas.html |
| diff --git a/third_party/WebKit/LayoutTests/media/video-canvas.html b/third_party/WebKit/LayoutTests/media/video-canvas.html |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..e7cbe67a78f1d1dd8f2dbcd60e09aa47dc29d61f |
| --- /dev/null |
| +++ b/third_party/WebKit/LayoutTests/media/video-canvas.html |
| @@ -0,0 +1,65 @@ |
| +<!DOCTYPE html> |
| +<title>Test "video" as a source for "canvas".</title> |
| +<script src="../resources/testharness.js"></script> |
| +<script src="../resources/testharnessreport.js"></script> |
| +<script src="media-file.js"></script> |
| +<video></video> |
| +<canvas width="160" height="120"></canvas> |
| +<script> |
| +async_test(function(t) { |
| + var ctx; |
| + var width; |
| + var height; |
| + var results = { |
| + current: 0, |
| + values: [ |
| + { time: 0, r: 255, g: 255, b: 0 }, |
| + { time: 2, r: 0, g: 9, b: 237 }, |
| + { time: 4, r: 0, g: 32, b: 209 }, |
| + { time: 6, r: 0, g: 54, b: 182 }, |
| + { time: 8, r: 0, g: 77, b: 154 }, |
| + { time: 10, r: 0, g: 97, b: 126 } |
| + ] |
| + }; |
| + |
| + var video = document.querySelector("video"); |
| + |
| + video.onloadedmetadata = t.step_func(function() { |
| + width = video.videoWidth / 2; |
| + height = video.videoHeight / 2; |
| + |
| + ctx = document.querySelector("canvas").getContext("2d"); |
| + ctx.fillStyle = "yellow"; |
| + ctx.fillRect(0, 0, width, height); |
| + testFrame(); |
| + }); |
| + |
| + function testFrame() { |
| + var expected = results.values[results.current]; |
| + if (expected.time) |
| + video.currentTime = expected.time; |
| + |
| + setTimeout(function() { |
|
fs
2016/07/02 18:33:45
Could we use 'seeked' for this? (May need special-
fs
2016/07/02 18:39:44
Possibly combined with rAF or setTimeout(..., 0).
Srirama
2016/07/03 04:31:34
Done.
|
| + var expected = results.values[results.current]; |
| + if (expected.time) |
| + ctx.drawImage(video, 0, 0, width, height); |
| + |
| + var frame = ctx.getImageData(0, 0, width, height); |
| + r = frame.data[4 * 2 * width + 16 + 0]; |
| + g = frame.data[4 * 2 * width + 16 + 1]; |
| + b = frame.data[4 * 2 * width + 16 + 2]; |
|
fs
2016/07/02 18:33:45
var r = ...;
et.c
Srirama
2016/07/03 04:31:34
Done.
|
| + |
| + assert_equals(r, expected.r); |
| + assert_equals(g, expected.g); |
| + assert_equals(b, expected.b); |
| + |
| + if (++results.current == results.values.length) |
| + t.done(); |
| + else |
| + setTimeout(testFrame, 0); |
| + }, 100); |
| + } |
| + |
| + video.src = findMediaFile("video", "content/counting"); |
| +}); |
| +</script> |