4 <canvas id=
"example" width=
"50" height=
"50">
6 <div id=
"description"></div>
7 <div id=
"console"></div>
8 <script src=
"../../../resources/js-test.js"></script>
9 <script src=
"resources/webgl-test.js"></script>
10 <script src=
"resources/webgl-test-utils.js"></script>
13 var wtu
= WebGLTestUtils
;
14 description("toDataURL() causes side effect for framebuffer binding. crbug.com/445848");
17 var glCanvas
= document
.getElementById("example");
18 // crbug.com/445848 bug occurs only on the following webgl configuration.
19 var gl
= wtu
.create3DContext(glCanvas
, {preserveDrawingBuffer
: true, premultipliedAlpha
: true});
20 // FIXME: context.getContextAttributes().antialias is always false on
21 // content shell with --run-layout-test option. See http://crbug.com/375682
22 // If antialias is supported, test can be much shorter for crbug.com/445848.
24 var program
= wtu
.setupColorQuad(gl
);
26 // Clear backbuffer in red.
27 gl
.clearColor(1.0, 0.0, 0.0, 1.0);
28 gl
.clear(gl
.COLOR_BUFFER_BIT
);
29 wtu
.checkCanvas(gl
, [255, 0, 0, 255], "should be red");
31 var fbo
= gl
.createFramebuffer();
32 var tex
= gl
.createTexture();
33 gl
.bindTexture(gl
.TEXTURE_2D
, tex
);
34 gl
.texImage2D(gl
.TEXTURE_2D
, 0, gl
.RGBA
, 50, 50, 0, gl
.RGBA
, gl
.UNSIGNED_BYTE
, null);
35 gl
.texParameteri(gl
.TEXTURE_2D
, gl
.TEXTURE_MIN_FILTER
, gl
.NEAREST
);
36 gl
.texParameteri(gl
.TEXTURE_2D
, gl
.TEXTURE_MAG_FILTER
, gl
.NEAREST
);
37 gl
.texParameteri(gl
.TEXTURE_2D
, gl
.TEXTURE_WRAP_S
, gl
.CLAMP_TO_EDGE
);
38 gl
.texParameteri(gl
.TEXTURE_2D
, gl
.TEXTURE_WRAP_T
, gl
.CLAMP_TO_EDGE
);
39 gl
.bindFramebuffer(gl
.FRAMEBUFFER
, fbo
);
40 gl
.framebufferTexture2D(gl
.FRAMEBUFFER
, gl
.COLOR_ATTACHMENT0
, gl
.TEXTURE_2D
, tex
, 0);
41 if (gl
.checkFramebufferStatus(gl
.FRAMEBUFFER
) != gl
.FRAMEBUFFER_COMPLETE
) {
46 // Clear the FBO in green.
47 gl
.clearColor(0.0, 1.0, 0.0, 1.0);
48 gl
.clear(gl
.COLOR_BUFFER_BIT
);
50 // backbuffer is still in red.
51 gl
.bindFramebuffer(gl
.FRAMEBUFFER
, null);
52 wtu
.checkCanvas(gl
, [255, 0, 0, 255], "should be red");
53 gl
.bindFramebuffer(gl
.FRAMEBUFFER
, fbo
);
56 // The second toDataURL binds backbuffer in crbug.com/445848
58 // It applies to backbuffer, not the FBO.
59 gl
.clear(gl
.COLOR_BUFFER_BIT
);
61 // backbuffer must be in red, not green.
62 gl
.bindFramebuffer(gl
.FRAMEBUFFER
, null);
63 wtu
.checkCanvas(gl
, [255, 0, 0, 255], "should be red");
69 var successfullyParsed
= true;