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

Unified Diff: third_party/WebKit/LayoutTests/fast/canvas/imagebitmap/transferFromImageBitmap-nullability-harness.html

Issue 2251493003: Adding nullability support to ImageBitmapRenderingContext.transferImageBitmap (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Layout tests and code update for resetting the canvas Created 4 years, 4 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/LayoutTests/fast/canvas/imagebitmap/transferFromImageBitmap-nullability-harness.html
diff --git a/third_party/WebKit/LayoutTests/fast/canvas/imagebitmap/transferFromImageBitmap-nullability-harness.html b/third_party/WebKit/LayoutTests/fast/canvas/imagebitmap/transferFromImageBitmap-nullability-harness.html
new file mode 100644
index 0000000000000000000000000000000000000000..a47b8c2604a20ad62ed096217c3c19f59f4ad210
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/fast/canvas/imagebitmap/transferFromImageBitmap-nullability-harness.html
@@ -0,0 +1,56 @@
+<!DOCTYPE html>
Justin Novosad 2016/08/18 15:27:27 the "-harness" in the filename is not great. The
zakerinasab 2016/08/24 15:31:11 Done.
+<canvas id = 'dstCanvas' width='100' height='100'></canvas>
Justin Novosad 2016/08/18 15:27:27 These canvases do not need to be in the HTML marku
zakerinasab 2016/08/24 15:31:10 Done.
+<canvas id = 'myCanvas' width='100' height='100'></canvas>
+<script src="../../../resources/testharness.js"></script>
+<script src="../../../resources/testharnessreport.js"></script>
+<script>
+
+function testCanvasReset(ctx) {
+ var colorData = ctx.getImageData(50, 50, 1, 1).data;
+ assert_equals(colorData[0], 0);
+ assert_equals(colorData[1], 0);
+ assert_equals(colorData[2], 0);
+ assert_equals(colorData[3], 0);
+}
+
+function testCanvas_0f0(ctx) {
+ var colorData = ctx.getImageData(50, 50, 1, 1).data;
+ assert_equals(colorData[0], 0);
+ assert_equals(colorData[1], 255);
+ assert_equals(colorData[2], 0);
+ assert_equals(colorData[3], 255);
+}
+
+function promiseCreateImage(ctx) {
Justin Novosad 2016/08/18 15:27:27 This function is pointless. Just use createImageB
zakerinasab 2016/08/24 15:31:11 Done.
+ return createImageBitmap(ctx);
+}
+
+function testTransferFromImageBitmapNullability(image) {
+ var dstCanvas = document.getElementById('dstCanvas');
+ var dstCtx = dstCanvas.getContext('bitmaprenderer');
+ dstCtx.transferFromImageBitmap(image);
+
+ var myCanvas = document.getElementById('myCanvas');
+ var myCtx = myCanvas.getContext('2d');
+ myCtx.drawImage(image, 0, 0);
+ //This should give the same results, but it doesn't.
+ //myCtx.drawImage(dstCanvas, 0, 0);
Justin Novosad 2016/08/18 15:27:27 Do not commit the test in this state. It looks li
zakerinasab 2016/08/24 15:31:10 Done.
+ testCanvas_0f0(myCtx);
+
+ //dstCtx.transferFromImageBitmap(null);
+ //ctx.drawImage(dstCanvas, 0, 0);
+ //testCanvasReset(ctx);
+}
+
+promise_test(function() {
+ var canvas = document.createElement('canvas');
+ canvas.width = canvas.height = 100;
+ var ctx = canvas.getContext('2d');
+ ctx.fillStyle = '#0f0';
+ ctx.fillRect(0, 0, 100, 100);
+ testCanvas_0f0(ctx);
+
+ return promiseCreateImage(canvas).then(testTransferFromImageBitmapNullability);
+}, 'testNullParameterTransferFromImageBitmap should not return any error');
+
+</script>

Powered by Google App Engine
This is Rietveld 408576698