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

Unified Diff: third_party/WebKit/LayoutTests/fast/canvas/OffscreenCanvas-commit-frameless-doc.html

Issue 2644653003: Make OffscreenCanvas animation in sync with its placeholder canvas's parent frame rate (Closed)
Patch Set: rebase again Created 3 years, 11 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-commit-frameless-doc.html
diff --git a/third_party/WebKit/LayoutTests/fast/canvas/OffscreenCanvas-commit-frameless-doc.html b/third_party/WebKit/LayoutTests/fast/canvas/OffscreenCanvas-commit-frameless-doc.html
new file mode 100644
index 0000000000000000000000000000000000000000..10542b104c4ec607a5ba51fcbfc7e6fbe1ab70d0
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/fast/canvas/OffscreenCanvas-commit-frameless-doc.html
@@ -0,0 +1,53 @@
+<!DOCTYPE html>
+<script src="../../resources/testharness.js"></script>
+<script src="../../resources/testharnessreport.js"></script>
+<script>
+// This test aims to ensure that OffscreenCanvas.commit() does not
+// crash for a placeholder canvas under frameless document.
+// Since the document is invisible, the resultant image should be
+// not visible too. But users must be able to draw to the OffscreenCanvas
+// and do canvas-operations on the frameless placeholder canvas.
+// TODO(crbug.com/683172): Modify this test after handling for
+// frameless canvas is done.
+function createFramelessCanvas() {
+ var framelessDoc = document.implementation.createHTMLDocument("frameless");
+ var canvas = framelessDoc.createElement("canvas");
+ canvas.width = 50;
+ canvas.height = 50;
+ return canvas;
+}
+
+function transferControlAndCommit(canvas) {
+ var offscreenCanvas = canvas.transferControlToOffscreen();
+ var ctx = offscreenCanvas.getContext("2d");
+ ctx.fillStyle = "blue";
+ ctx.fillRect(0, 0, 50, 50);
+ ctx.commit();
+ return offscreenCanvas;
+}
+
+test(function() {
+ var offscreenCanvas = transferControlAndCommit(createFramelessCanvas());
+ var ctx = offscreenCanvas.getContext("2d");
+ var pixels = ctx.getImageData(0, 0, 1, 1).data;
+ assert_array_equals(pixels, [0, 0, 255, 255]);
+}, "Verify that the getImageData() works on the OffscreenCanvas context of a frameless canvas");
+
+async_test(function(t) {
+ var canvas = createFramelessCanvas();
+ var offscreenCanvas = transferControlAndCommit(canvas);
+
+ var c = document.createElement("canvas");
+ c.width = 50;
+ c.height = 50;
+ var ctx2 = c.getContext("2d");
+ setTimeout(function() {
+ ctx2.drawImage(canvas, 0, 0);
+ var pixels = ctx2.getImageData(0, 0, 1, 1).data;
+ t.step(function() {
+ assert_array_equals(pixels, [0, 0, 255, 255]);
+ });
+ t.done();
+ }, 0);
+}, "Verify that the placeholder canvas can be used as an image source");
+</script>

Powered by Google App Engine
This is Rietveld 408576698