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

Side by Side Diff: third_party/WebKit/LayoutTests/fast/canvas/imagebitmap/transferFromImageBitmap-drawImage.html

Issue 2459233002: Consolidate implementation of ImageBitmapRenderingContext (Closed)
Patch Set: Created 4 years, 1 month 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 <!DOCTYPE html> 1 <!DOCTYPE html>
2 <script src="../../../resources/testharness.js"></script> 2 <script src="../../../resources/testharness.js"></script>
3 <script src="../../../resources/testharnessreport.js"></script> 3 <script src="../../../resources/testharnessreport.js"></script>
4 <script> 4 <script>
5 5
6 function testCanvas_0f0(ctx) { 6 function testCanvas_0f0(ctx) {
7 var colorData = ctx.getImageData(50, 50, 1, 1).data; 7 var colorData = ctx.getImageData(50, 50, 1, 1).data;
8 assert_equals(colorData[0], 0); 8 assert_equals(colorData[0], 0);
9 assert_equals(colorData[1], 255); 9 assert_equals(colorData[1], 255);
10 assert_equals(colorData[2], 0); 10 assert_equals(colorData[2], 0);
11 assert_equals(colorData[3], 255); 11 assert_equals(colorData[3], 255);
12 } 12 }
13 13
14 function testDrawCanvasWithImageBitamp(image) { 14 function testDrawCanvasWithImageBitamp(image) {
15 var dstCanvas = document.createElement('canvas'); 15 var dstCanvas = document.createElement('canvas');
16 dstCanvas.width = dstCanvas.height = 100; 16 dstCanvas.width = dstCanvas.height = 100;
17 var dstCtx = dstCanvas.getContext('bitmaprenderer'); 17 var dstCtx = dstCanvas.getContext('bitmaprenderer');
18 assert_true(dstCtx instanceof ImageBitmapRenderingContext);
18 dstCtx.transferFromImageBitmap(image); 19 dstCtx.transferFromImageBitmap(image);
19 20
21 // Calling dstCtx.canvas should get the same canvas as the dstCanvas
22 var testCanvas = dstCtx.canvas;
23 assert_equals(dstCanvas.width, testCanvas.width);
24 assert_equals(dstCanvas.height, testCanvas.height);
25
26 // After transferFromImageBitmap, image's width && height should be 0
27 assert_equals(image.width, 0);
28 assert_equals(image.height, 0);
29
20 var myCanvas = document.createElement('canvas'); 30 var myCanvas = document.createElement('canvas');
21 myCanvas.width = myCanvas.height = 100; 31 myCanvas.width = myCanvas.height = 100;
22 var myCtx = myCanvas.getContext('2d'); 32 var myCtx = myCanvas.getContext('2d');
23 myCtx.drawImage(dstCanvas, 10, 10); 33 myCtx.drawImage(dstCanvas, 10, 10);
24 testCanvas_0f0(myCtx); 34 testCanvas_0f0(myCtx);
25 } 35 }
26 36
27 promise_test(function() { 37 promise_test(function() {
28 var canvas = document.createElement('canvas'); 38 var canvas = document.createElement('canvas');
29 canvas.width = canvas.height = 100; 39 canvas.width = canvas.height = 100;
30 var ctx = canvas.getContext('2d'); 40 var ctx = canvas.getContext('2d');
31 ctx.fillStyle = '#0f0'; 41 ctx.fillStyle = '#0f0';
32 ctx.fillRect(0, 0, 100, 100); 42 ctx.fillRect(0, 0, 100, 100);
33 testCanvas_0f0(ctx); 43 testCanvas_0f0(ctx);
34 44
35 return createImageBitmap(canvas).then(testDrawCanvasWithImageBitamp); 45 return createImageBitmap(canvas).then(testDrawCanvasWithImageBitamp);
36 }, 'testDrawCanvasWithImageBitamp should not return any error'); 46 }, 'testDrawCanvasWithImageBitamp should not return any error');
37 47
38 </script> 48 </script>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698