OLD | NEW |
---|---|
(Empty) | |
1 <!DOCTYPE html> | |
2 <title>Test "video" as a source for "canvas".</title> | |
3 <script src="../resources/testharness.js"></script> | |
4 <script src="../resources/testharnessreport.js"></script> | |
5 <script src="media-file.js"></script> | |
6 <video></video> | |
7 <canvas width="160" height="120"></canvas> | |
8 <script> | |
9 async_test(function(t) { | |
10 var ctx; | |
11 var width; | |
12 var height; | |
13 var results = { | |
14 current: 0, | |
15 values: [ | |
16 { time: 0, r: 255, g: 255, b: 0 }, | |
17 { time: 2, r: 0, g: 9, b: 237 }, | |
18 { time: 4, r: 0, g: 32, b: 209 }, | |
19 { time: 6, r: 0, g: 54, b: 182 }, | |
20 { time: 8, r: 0, g: 77, b: 154 }, | |
21 { time: 10, r: 0, g: 97, b: 126 } | |
22 ] | |
23 }; | |
24 | |
25 var video = document.querySelector("video"); | |
26 | |
27 video.onloadedmetadata = t.step_func(function() { | |
28 width = video.videoWidth / 2; | |
29 height = video.videoHeight / 2; | |
30 | |
31 ctx = document.querySelector("canvas").getContext("2d"); | |
32 ctx.fillStyle = "yellow"; | |
33 ctx.fillRect(0, 0, width, height); | |
34 testFrame(); | |
35 }); | |
36 | |
37 video.onseeked = t.step_func(function() { | |
38 ctx.drawImage(video, 0, 0, width, height); | |
39 testFrame(); | |
40 }); | |
41 | |
42 function testFrame() { | |
43 var expected = results.values[results.current]; | |
44 var frame = ctx.getImageData(0, 0, width, height); | |
45 var r = frame.data[4 * 2 * width + 16 + 0]; | |
46 var g = frame.data[4 * 2 * width + 16 + 1]; | |
47 var b = frame.data[4 * 2 * width + 16 + 2]; | |
48 | |
49 assert_equals(r, expected.r); | |
fs
2016/07/03 15:39:42
I suspect that it'd make sense for these to be ass
Srirama
2016/07/03 15:50:41
Acknowledged.
| |
50 assert_equals(g, expected.g); | |
51 assert_equals(b, expected.b); | |
52 | |
53 if (++results.current == results.values.length) | |
54 t.done(); | |
55 else | |
56 video.currentTime = results.values[results.current].time; | |
57 } | |
58 | |
59 video.src = findMediaFile("video", "content/counting"); | |
60 }); | |
61 </script> | |
OLD | NEW |