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

Unified Diff: third_party/WebKit/LayoutTests/fast/canvas/OffscreenCanvas-transferToImageBitmap.html

Issue 1775153002: Make OffscreenCanvasRenderingContext2D renderable on a worker (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 4 years, 9 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/OffscreenCanvas-transferToImageBitmap.html
diff --git a/third_party/WebKit/LayoutTests/fast/canvas/OffscreenCanvas-transferToImageBitmap.html b/third_party/WebKit/LayoutTests/fast/canvas/OffscreenCanvas-transferToImageBitmap.html
new file mode 100644
index 0000000000000000000000000000000000000000..c0bc6ff8bc1eeced71d8b7cf826b7f3096d1eb9e
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/fast/canvas/OffscreenCanvas-transferToImageBitmap.html
@@ -0,0 +1,41 @@
+<!DOCTYPE html>
+<script src="../../resources/js-test.js"></script>
+<script>
+var aCanvas = new OffscreenCanvas(60, 40);
+
+// TransferToImageBitmap on an OffscreenCanvas with no context
+shouldThrow("aCanvas.transferToImageBitmap()");
+ctx = aCanvas.getContext('2d');
+
+// Verify ImageBitmap is correctly sized
+var image = aCanvas.transferToImageBitmap();
+shouldBe("image.width", "60");
+shouldBe("image.height", "40");
+
+// Verify state is preserved through transferToImageBitmap()
+ctx.lineWidth = 5;
+aCanvas.transferToImageBitmap();
+shouldBe("ctx.lineWidth", "5");
+
+// Verify backing is reset through transferToImageBitmap()
+ctx.fillStyle = '#f00';
+ctx.fillRect(0, 0, aCanvas.width, aCanvas.height);
+var firstImage = aCanvas.transferToImageBitmap();
+var secondImage = aCanvas.transferToImageBitmap();
+var testCanvas = document.createElement('canvas');
+var testCtx = testCanvas.getContext('2d');
+testCtx.drawImage(firstImage, 0, 0);
+var imgData = testCtx.getImageData(0, 0, 1, 1).data;
+shouldBe("imgData[0]", "255");
+shouldBe("imgData[1]", "0");
+shouldBe("imgData[2]", "0");
+shouldBe("imgData[3]", "255");
+testCtx.clearRect(0, 0, testCanvas.width, testCanvas.height);
+testCtx.drawImage(secondImage, 0, 0);
+imgData = testCtx.getImageData(0, 0, 1, 1).data;
+shouldBe("imgData[0]", "0");
+shouldBe("imgData[1]", "0");
+shouldBe("imgData[2]", "0");
+shouldBe("imgData[3]", "0");
+
+</script>

Powered by Google App Engine
This is Rietveld 408576698