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

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

Issue 2506043002: Allow ImageBitmap objects to be created from placeholder canvases. (Closed)
Patch Set: add test 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/frame/ImageBitmap.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/LayoutTests/fast/canvas/OffscreenCanvas-placeholder-createImageBitmap.html
diff --git a/third_party/WebKit/LayoutTests/fast/canvas/OffscreenCanvas-placeholder-createImageBitmap.html b/third_party/WebKit/LayoutTests/fast/canvas/OffscreenCanvas-placeholder-createImageBitmap.html
new file mode 100644
index 0000000000000000000000000000000000000000..398869ec2b225f6233a635a05c968309ac7079c8
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/fast/canvas/OffscreenCanvas-placeholder-createImageBitmap.html
@@ -0,0 +1,45 @@
+<!DOCTYPE HTML>
+<html>
+<head>
+<script src="../../resources/testharness.js"></script>
+<script src="../../resources/testharnessreport.js"></script>
+</head>
+<body>
+<script>
+async_test(function(t) {
+ var canvas = document.createElement('canvas');
+ var offscreen = canvas.transferControlToOffscreen();
+ var ctx = offscreen.getContext('2d');
+ ctx.fillStyle = '#0f0';
+ ctx.fillRect(0, 0, canvas.width, canvas.height);
+ ctx.commit();
+
+ var testCanvas = document.createElement('canvas');
+ var testCtx = testCanvas.getContext('2d');
+
+ createImageBitmap(canvas).then(image => {
+ testCtx.drawImage(image, 0, 0);
+ t.step( function() {
+ var pixel = testCtx.getImageData(0, 0, 1, 1).data;
+ var expectedValue = [0, 0, 0, 0]; // pixel is blank because commit() is async
+ assert_array_equals(pixel, expectedValue, "Verify that commit() is not synchronous.");
+ });
+
+ // The call to setTimeout acts as a synchronization barrier to guarantee that
+ // the commit has propagated.
+ setTimeout(function() {
+ createImageBitmap(canvas).then(image => {
+ testCtx.drawImage(image, 0, 0);
+ t.step( function() {
+ var pixel = testCtx.getImageData(0, 0, 1, 1).data;
+ var expectedValue = [0, 255, 0, 255];
+ assert_array_equals(pixel, expectedValue, "Verify that async update of placeholder propagated through createImageData");
+ });
+ t.done();
+ });
+ }, 0);
+ });
+}, "Test whether createImageBitmap on a placeholder canvas captures the image committed to the associated OffscreenCanvas.");
+</script>
+</body>
+</html>
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/frame/ImageBitmap.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698