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

Unified Diff: LayoutTests/fast/canvas/canvas-createImageBitmap-webgl.html

Issue 766333003: canvas: fix bugs on HTMLCanvasElement::copiedImage() (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: rephrase this test so that the expectations don't contain failure Created 6 years 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 | LayoutTests/fast/canvas/canvas-createImageBitmap-webgl-expected.txt » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: LayoutTests/fast/canvas/canvas-createImageBitmap-webgl.html
diff --git a/LayoutTests/fast/canvas/canvas-createImageBitmap-webgl.html b/LayoutTests/fast/canvas/canvas-createImageBitmap-webgl.html
index 5d919c3f7673d88773836f7b5ab69c3cc60cb4b1..71cc8f6588c80434301d61169db9a8d145b7fce0 100644
--- a/LayoutTests/fast/canvas/canvas-createImageBitmap-webgl.html
+++ b/LayoutTests/fast/canvas/canvas-createImageBitmap-webgl.html
@@ -3,7 +3,14 @@
<script src="../../resources/js-test.js"></script>
</head>
<body onload="start();">
+<canvas id="webgl" width="200" height="200"></canvas>
<script>
+/*
+ * crbug.com/438986
+ * window.createImageBitmap(HTMLCanvasElement) copies the back buffer of WebGL.
+ * So createImageBitmap(HTMLCanvasElement) must create transparent ImageBuffer
+ * 1 frame after WebGL draws contents.
+ */
window.jsTestIsAsync = true;
var canvas = document.createElement("canvas");
@@ -18,24 +25,53 @@
shouldBeTrue("d[3] == 255");
}
+ function shouldBeTransparent(x, y) {
+ d = ctx.getImageData(x, y, 1, 1).data;
+ shouldBeTrue("d[0] == 0");
+ shouldBeTrue("d[1] == 0");
+ shouldBeTrue("d[2] == 0");
+ shouldBeTrue("d[3] == 0");
+ }
+
function start() {
- var aCanvas = document.createElement("canvas");
- aCanvas.width = 200;
- aCanvas.height = 200;
- var gl = aCanvas.getContext("webgl");
+ debug("Check the imageBitmap of webgl.")
+ var webgl_canvas = document.getElementById("webgl");
+ var gl = webgl_canvas.getContext("webgl", {preserveDrawingBuffer: false});
gl.clearColor(0.0, 1.0, 0.0, 1.0);
gl.clear(gl.COLOR_BUFFER_BIT);
+ createImageBitmapAndCheck(webgl_canvas, false).then(function() {
+ if (window.testRunner) {
+ testRunner.displayAsyncThen(asyncTest);
+ } else {
+ window.requestAnimationFrame(asyncTest);
+ }
+ });
+ }
- createImageBitmap(aCanvas).then(function (imageBitmap) {
+ function createImageBitmapAndCheck(webgl_canvas, discarded) {
+ return createImageBitmap(webgl_canvas).then(function (imageBitmap) {
+ ctx.clearRect(0, 0, 200, 200);
ctx.drawImage(imageBitmap, 0, 0);
- shouldBeGreen(50, 50);
- shouldBeGreen(150, 150);
- finishJSTest();
+ if (!discarded) {
+ shouldBeGreen(50, 50);
+ shouldBeGreen(150, 150);
+ } else {
+ shouldBeTransparent(50, 50);
+ shouldBeTransparent(150, 150);
+ }
}, function() {
testFailed("Promise was rejected.");
finishJSTest();
});
}
+
+ function asyncTest() {
+ debug("Check the imageBitmap of webgl in the next frame. drawingBuffer is discarded.")
+ var webgl_canvas = document.getElementById("webgl");
+ createImageBitmapAndCheck(webgl_canvas, true).then(function() {
+ finishJSTest();
+ });
+ }
</script>
</body>
</html>
« no previous file with comments | « no previous file | LayoutTests/fast/canvas/canvas-createImageBitmap-webgl-expected.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698