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

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

Issue 2464093002: Revert of 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
« 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
5 function testCanvas_0f0(ctx) { 6 function testCanvas_0f0(ctx) {
6 var colorData = ctx.getImageData(50, 50, 1, 1).data; 7 var colorData = ctx.getImageData(50, 50, 1, 1).data;
7 assert_equals(colorData[0], 0); 8 assert_equals(colorData[0], 0);
8 assert_equals(colorData[1], 255); 9 assert_equals(colorData[1], 255);
9 assert_equals(colorData[2], 0); 10 assert_equals(colorData[2], 0);
10 assert_equals(colorData[3], 255); 11 assert_equals(colorData[3], 255);
11 }
12
13 function testException(image) {
14 var dstCanvas = document.createElement('canvas');
15 dstCanvas.width = dstCanvas.height = 100;
16 var dstCtx = dstCanvas.getContext('bitmaprenderer');
17 assert_true(dstCtx instanceof ImageBitmapRenderingContext);
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);});
23 } 12 }
24 13
25 function testDrawCanvasWithImageBitamp(image) { 14 function testDrawCanvasWithImageBitamp(image) {
26 var dstCanvas = document.createElement('canvas'); 15 var dstCanvas = document.createElement('canvas');
27 dstCanvas.width = dstCanvas.height = 100; 16 dstCanvas.width = dstCanvas.height = 100;
28 var dstCtx = dstCanvas.getContext('bitmaprenderer'); 17 var dstCtx = dstCanvas.getContext('bitmaprenderer');
29 assert_true(dstCtx instanceof ImageBitmapRenderingContext); 18 dstCtx.transferFromImageBitmap(image);
30 dstCtx.transferFromImageBitmap(image);
31 19
32 // Calling dstCtx.canvas should get the same canvas as the dstCanvas 20 var myCanvas = document.createElement('canvas');
33 var testCanvas = dstCtx.canvas; 21 myCanvas.width = myCanvas.height = 100;
34 assert_equals(dstCanvas.width, testCanvas.width); 22 var myCtx = myCanvas.getContext('2d');
35 assert_equals(dstCanvas.height, testCanvas.height); 23 myCtx.drawImage(dstCanvas, 10, 10);
36 24 testCanvas_0f0(myCtx);
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);
46 } 25 }
47 26
48 promise_test(function() { 27 promise_test(function() {
49 var canvas = document.createElement('canvas'); 28 var canvas = document.createElement('canvas');
50 canvas.width = canvas.height = 100; 29 canvas.width = canvas.height = 100;
51 var ctx = canvas.getContext('2d'); 30 var ctx = canvas.getContext('2d');
52 ctx.fillStyle = '#0f0'; 31 ctx.fillStyle = '#0f0';
53 ctx.fillRect(0, 0, 100, 100); 32 ctx.fillRect(0, 0, 100, 100);
54 testCanvas_0f0(ctx); 33 testCanvas_0f0(ctx);
55 34
56 return createImageBitmap(canvas).then(testDrawCanvasWithImageBitamp); 35 return createImageBitmap(canvas).then(testDrawCanvasWithImageBitamp);
57 }, 'testDrawCanvasWithImageBitamp should not return any error'); 36 }, 'testDrawCanvasWithImageBitamp should not return any error');
58 37
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
69 </script> 38 </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