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

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

Issue 2459233002: Consolidate implementation of ImageBitmapRenderingContext (Closed)
Patch Set: fix a layout test failure 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
« no previous file with comments | « no previous file | third_party/WebKit/LayoutTests/fast/canvas/imagebitmap/transferFromImageBitmap-nullability.html » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 function testCanvas_0f0(ctx) {
6 var colorData = ctx.getImageData(50, 50, 1, 1).data;
7 assert_equals(colorData[0], 0);
8 assert_equals(colorData[1], 255);
9 assert_equals(colorData[2], 0);
10 assert_equals(colorData[3], 255);
11 }
5 12
6 function testCanvas_0f0(ctx) { 13 function testException(image) {
7 var colorData = ctx.getImageData(50, 50, 1, 1).data; 14 var dstCanvas = document.createElement('canvas');
8 assert_equals(colorData[0], 0); 15 dstCanvas.width = dstCanvas.height = 100;
9 assert_equals(colorData[1], 255); 16 var dstCtx = dstCanvas.getContext('bitmaprenderer');
10 assert_equals(colorData[2], 0); 17 assert_true(dstCtx instanceof ImageBitmapRenderingContext);
11 assert_equals(colorData[3], 255); 18 dstCtx.transferFromImageBitmap(image);
19
20 // image is detached after calling transferFromImageBitmap,
21 // so call transferFromImageBitmap(image) should throw InvalidStateError
22 assert_throws("InvalidStateError", function() {dstCtx.transferFromImageBitma p(image);});
12 } 23 }
13 24
14 function testDrawCanvasWithImageBitamp(image) { 25 function testDrawCanvasWithImageBitamp(image) {
15 var dstCanvas = document.createElement('canvas'); 26 var dstCanvas = document.createElement('canvas');
16 dstCanvas.width = dstCanvas.height = 100; 27 dstCanvas.width = dstCanvas.height = 100;
17 var dstCtx = dstCanvas.getContext('bitmaprenderer'); 28 var dstCtx = dstCanvas.getContext('bitmaprenderer');
18 dstCtx.transferFromImageBitmap(image); 29 assert_true(dstCtx instanceof ImageBitmapRenderingContext);
30 dstCtx.transferFromImageBitmap(image);
19 31
20 var myCanvas = document.createElement('canvas'); 32 // Calling dstCtx.canvas should get the same canvas as the dstCanvas
21 myCanvas.width = myCanvas.height = 100; 33 var testCanvas = dstCtx.canvas;
22 var myCtx = myCanvas.getContext('2d'); 34 assert_equals(dstCanvas.width, testCanvas.width);
23 myCtx.drawImage(dstCanvas, 10, 10); 35 assert_equals(dstCanvas.height, testCanvas.height);
24 testCanvas_0f0(myCtx); 36
37 // After transferFromImageBitmap, image's width && height should be 0
38 assert_equals(image.width, 0);
39 assert_equals(image.height, 0);
40
41 var myCanvas = document.createElement('canvas');
42 myCanvas.width = myCanvas.height = 100;
43 var myCtx = myCanvas.getContext('2d');
44 myCtx.drawImage(dstCanvas, 10, 10);
45 testCanvas_0f0(myCtx);
25 } 46 }
26 47
27 promise_test(function() { 48 promise_test(function() {
28 var canvas = document.createElement('canvas'); 49 var canvas = document.createElement('canvas');
29 canvas.width = canvas.height = 100; 50 canvas.width = canvas.height = 100;
30 var ctx = canvas.getContext('2d'); 51 var ctx = canvas.getContext('2d');
31 ctx.fillStyle = '#0f0'; 52 ctx.fillStyle = '#0f0';
32 ctx.fillRect(0, 0, 100, 100); 53 ctx.fillRect(0, 0, 100, 100);
33 testCanvas_0f0(ctx); 54 testCanvas_0f0(ctx);
34 55
35 return createImageBitmap(canvas).then(testDrawCanvasWithImageBitamp); 56 return createImageBitmap(canvas).then(testDrawCanvasWithImageBitamp);
36 }, 'testDrawCanvasWithImageBitamp should not return any error'); 57 }, 'testDrawCanvasWithImageBitamp should not return any error');
37 58
59 promise_test(function() {
60 var canvas = document.createElement('canvas');
61 canvas.width = canvas.height = 100;
62 var ctx = canvas.getContext('2d');
63 ctx.fillStyle = '#0f0';
64 ctx.fillRect(0, 0, 100, 100);
65
66 return createImageBitmap(canvas).then(testException);
67 }, 'transferFromImageBitmap(image) with a neutered image should throw InvalidSta teError');
68
38 </script> 69 </script>
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/LayoutTests/fast/canvas/imagebitmap/transferFromImageBitmap-nullability.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698