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

Side by Side Diff: third_party/WebKit/LayoutTests/fast/canvas/canvas-drawImage-live-video.html

Issue 2674863003: Use testharness.js instead of js-test.js in LayoutTests/fast/canvas tests. (Closed)
Patch Set: Corrections Created 3 years, 10 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 unified diff | Download patch
OLDNEW
1 <html> 1 <html>
2 <head> 2 <head>
3 <style type="text/css"> 3 <style type="text/css">
4 video { 4 video {
5 display: none; 5 display: none;
6 } 6 }
7 </style> 7 </style>
8 </head> 8 </head>
9 <body> 9 <body>
10 <canvas id="canvas"></canvas> 10 <canvas id="canvas"></canvas>
11 <video id="video"> 11 <video id="video">
12 <source src="../../media/resources/test-live.webm" type='video/webm' /> 12 <source src="../../media/resources/test-live.webm" type='video/webm' />
13 </video> 13 </video>
14 <script src="../../resources/js-test.js"></script> 14 <script src="../../resources/testharness.js"></script>
15 <script> 15 <script src="../../resources/testharnessreport.js"></script>
16 description('Verify that consecutive drawImage from a live video correctly pro pagates frame updates.'); 16 <script>
17 if (window.testRunner) { 17 test(function(t) {
Justin Novosad 2017/02/09 20:32:01 why no longer async?
zakerinasab 2017/02/13 16:25:19 Done.
18 testRunner.dumpAsText();
19 testRunner.waitUntilDone();
20 }
21
22 var canvas = document.getElementById("canvas"); 18 var canvas = document.getElementById("canvas");
23 canvas.width = 100; 19 canvas.width = 100;
24 canvas.height = 100; 20 canvas.height = 100;
25 var ctx = canvas.getContext("2d"); 21 var ctx = canvas.getContext("2d");
26 22
27 var video = document.getElementById("video"); 23 var video = document.getElementById("video");
28 video.addEventListener("playing", drawFirstFrame, true); 24 video.addEventListener("playing", drawFirstFrame, true);
29 video.play(); 25 video.play();
30 26
31 function drawFirstFrame() { 27 function drawFirstFrame() {
Justin Novosad 2017/02/09 20:32:01 Test ends before this is called.
zakerinasab 2017/02/13 16:25:19 Done.
32 video.removeEventListener("playing", drawFirstFrame, true); 28 video.removeEventListener("playing", drawFirstFrame, true);
33 ctx.drawImage(video, 0, 0, canvas.width, canvas.height); 29 ctx.drawImage(video, 0, 0, canvas.width, canvas.height);
34 requestAnimationFrame(function() { 30 requestAnimationFrame(function() {
35 video.addEventListener("timeupdate", updateVideo, true); 31 video.addEventListener("timeupdate", updateVideo, true);
36 }); 32 });
37 } 33 }
38 34
39 var referenceImageData; 35 var referenceImageData;
40 var processedFirstFrame = false; 36 var processedFirstFrame = false;
41 var imagesAreTheSame; 37 var imagesAreTheSame;
42 38
43 function updateVideo() { 39 function updateVideo() {
44 if (!processedFirstFrame) { 40 if (!processedFirstFrame) {
45 ctx.drawImage(video, 0, 0, canvas.width, canvas.height); 41 ctx.drawImage(video, 0, 0, canvas.width, canvas.height);
46 referenceImageData = ctx.getImageData(0, 0, canvas.width, canvas.height); 42 referenceImageData = ctx.getImageData(0, 0, canvas.width, canvas.height);
47 processedFirstFrame = true; 43 processedFirstFrame = true;
48 } else { 44 } else {
49 video.removeEventListener("timeupdate", updateVideo, true); 45 video.removeEventListener("timeupdate", updateVideo, true);
50 ctx.drawImage(video, 0, 0, canvas.width, canvas.height); 46 ctx.drawImage(video, 0, 0, canvas.width, canvas.height);
51 var imageData = ctx.getImageData(0, 0, canvas.width, canvas.height); 47 var imageData = ctx.getImageData(0, 0, canvas.width, canvas.height);
52 imagesAreTheSame = true; 48 imagesAreTheSame = true;
53 for(var i = 0; i < imageData.data.length; ++i) { 49 for(var i = 0; i < imageData.data.length; ++i) {
54 if (imageData.data[i] != referenceImageData.data[i]) { 50 if (imageData.data[i] != referenceImageData.data[i]) {
55 imagesAreTheSame = false; 51 imagesAreTheSame = false;
56 break; 52 break;
57 } 53 }
58 } 54 }
59 shouldBeFalse("imagesAreTheSame"); 55 assert_fasle(imagesAreTheSame);
60 if (window.testRunner)
61 testRunner.notifyDone();
62 } 56 }
63 } 57 }
64 </script> 58 }, 'Verify that consecutive drawImage from a live video correctly propagates fra me updates.');
59 </script>
65 </body> 60 </body>
66 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698