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

Side by Side Diff: third_party/WebKit/LayoutTests/fast/canvas/canvas-createImageBitmap-animated.html

Issue 2679193002: Use testharness.js instead of js-test.js in LayoutTests/fast/canvas tests. (Closed)
Patch Set: 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 <script src="../../resources/testharness.js"></script>
2 <head> 2 <script src="../../resources/testharnessreport.js"></script>
3 <script src="../../resources/js-test.js"></script>
4 </head>
5 <body> 3 <body>
6 <script> 4 <script>
7 window.jsTestIsAsync = true; 5 var img = new Image();
6 img.onload = imageLoaded;
7 img.src = 'resources/green-red-animated.gif';
8 8
9 function shouldBeGreen(x, y) { 9 function consumeImageBitmap(image, t)
10 d = ctx.getImageData(x, y, 1, 1).data; 10 {
11 shouldBeTrue("d[0] == 0"); 11 var myCanvas = document.createElement('canvas');
12 shouldBeTrue("d[1] == 255"); 12 myCanvas.width = myCanvas.height = 200;
13 shouldBeTrue("d[2] == 0"); 13 var myCtx = myCanvas.getContext('bitmaprenderer');
14 shouldBeTrue("d[3] == 255"); 14 myCtx.transferFromImageBitmap(image);
15 }
16 15
17 var canvas = document.createElement("canvas"); 16 createImageBitmap(myCanvas).then(t.step_func_done(function(imageBitmap) {
18 canvas.width = 200; 17 var dstCanvas = document.createElement('canvas');
19 canvas.height = 200; 18 dstCanvas.width = dstCanvas.height = 200;
20 var ctx = canvas.getContext("2d"); 19 var dstCtx = dstCanvas.getContext('2d');
20 dstCtx.clearRect(0, 0, 200, 200);
21 dstCtx.drawImage(imageBitmap, 0, 0);
22 // If the ImageBitmap is green, we know that it is a snapshot of the gif 's 0th frame.
23 assert_array_equals(dstCtx.getImageData(100, 100, 1, 1).data, [0, 255, 0 , 255]);
24 }));
25 }
21 26
22 var img = new Image(); 27 function imageLoaded() {
23 img.onload = imageLoaded; 28 async_test(function(t) {
24 img.src = 'resources/green-red-animated.gif'; 29 createImageBitmap(img).then(t.step_func(function(image) {
Justin Novosad 2017/02/09 20:37:19 I don't think step_func is needed here. Also, it r
zakerinasab 2017/02/13 17:06:10 Done.
25 30 consumeImageBitmap(image, t);
26 function imageLoaded() { 31 }));
27 // If the ImageBitmap is green, we know that it is a snapshot of the gif 's 0th frame. 32 }, 'Test that createImageBitmap from an animated gif produces correct result .');
28 window.internals.advanceImageAnimation(img); 33 }
29 createImageBitmap(img).then(function (imageBitmap) {
30 ctx.drawImage(imageBitmap, 0, 0);
31 shouldBeGreen(100, 100);
32 finishJSTest();
33 }, function() {
34 testFailed("Promise was rejected.");
35 finishJSTest();
36 });
37 }
38 </script> 34 </script>
39 </body> 35 </body>
40 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698