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

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

Issue 2251493003: Adding nullability support to ImageBitmapRenderingContext.transferImageBitmap (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressing final comments. Created 4 years, 3 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
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/html/HTMLCanvasElement.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 <!DOCTYPE html>
2 <script src="../../../resources/testharness.js"></script>
3 <script src="../../../resources/testharnessreport.js"></script>
4 <script>
5
6 function testCanvas_0f0(ctx) {
7 var colorData = ctx.getImageData(50, 50, 1, 1).data;
8 assert_equals(colorData[0], 0);
9 assert_equals(colorData[1], 255);
10 assert_equals(colorData[2], 0);
11 assert_equals(colorData[3], 255);
12 }
13
14 function testCanvasReset(ctx) {
15 var colorData = ctx.getImageData(50, 50, 1, 1).data;
16 assert_equals(colorData[0], 0);
17 assert_equals(colorData[1], 0);
18 assert_equals(colorData[2], 0);
19 assert_equals(colorData[3], 0);
20 }
21
22 function testTransferFromImageBitmapNullability(image) {
23 var bitmapCanvas = document.createElement('canvas');
24 bitmapCanvas.width = bitmapCanvas.height = 100;
25 var bitmapCtx = bitmapCanvas.getContext('bitmaprenderer');
26 bitmapCtx.transferFromImageBitmap(image);
27
28 // Make sure the bitmap renderer canvas is filled correctly.
29 var myCanvas = document.createElement('canvas');
30 myCanvas.width = myCanvas.height = 100;
31 var myCtx = myCanvas.getContext('2d');
32 myCtx.drawImage(bitmapCanvas, 0, 0);
33 testCanvas_0f0(myCtx);
34
35 // Test if passing null resets the bitmap renderer canvas.
36 // Drawing the resetted canvas cannot change the destination canvas.
37 bitmapCtx.transferFromImageBitmap(null);
38 var myCanvas2 = document.createElement('canvas');
39 myCanvas2.width = myCanvas2.height = 100;
40 var myCtx2 = myCanvas2.getContext('2d');
41 myCtx2.drawImage(bitmapCanvas, 0, 0);
42 testCanvasReset(myCtx2);
43
44 // Test if we can redraw the bitmap canvas correctly after reset.
45 bitmapCtx.transferFromImageBitmap(image);
46 var myCanvas3 = document.createElement('canvas');
47 myCanvas3.width = myCanvas3.height = 100;
48 var myCtx3 = myCanvas3.getContext('2d');
49 myCtx3.drawImage(bitmapCanvas, 0, 0);
50 testCanvas_0f0(myCtx3);
51 }
52
53 promise_test(function() {
54 var canvas = document.createElement('canvas');
55 canvas.width = canvas.height = 100;
56 var ctx = canvas.getContext('2d');
57 ctx.fillStyle = '#0f0';
58 ctx.fillRect(0, 0, 100, 100);
59 testCanvas_0f0(ctx);
60
61 return createImageBitmap(canvas).then(testTransferFromImageBitmapNullability) ;
62 }, 'testTransferFromImageBitmapNullability should not return any error');
63
64 </script>
65
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/html/HTMLCanvasElement.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698