3 <script src=
"../../../resources/js-test.js"></script>
4 <script src=
"resources/webgl-test.js"></script>
5 <script src=
"resources/webgl-test-utils.js"> </script>
8 <div id=
"description"></div>
9 <div id=
"console"></div>
11 description("Checks that painting WebGL contents doesn't pollute the context state.");
13 var wtu
= WebGLTestUtils
;
15 if (window
.testRunner
) {
16 testRunner
.dumpAsText();
17 testRunner
.waitUntilDone();
21 window
.internals
.settings
.setWebGLErrorsToConsoleEnabled(false);
27 // Draw a blue quad to the screen. The compositor should have executed
28 // before reaching this point. If the texture state was corrupted, then
29 // a red quad will be drawn. See crbug.com/105045.
30 wtu
.drawQuad(context
);
32 wtu
.checkCanvasRect(context
, 0, 0, 1, 1, [0, 0, 255, 255], "Should have rendered blue.", 1);
33 if (window
.testRunner
)
34 testRunner
.notifyDone();
37 window
.onload = function()
39 if (window
.initNonKhronosFramework
) {
40 window
.initNonKhronosFramework(false);
43 canvas
= document
.getElementById("webgl-canvas");
44 context
= create3DContext(canvas
);
46 var program
= wtu
.setupTexturedQuad(context
);
47 var bufferObjects
= wtu
.setupUnitQuad(context
);
48 var texture
= wtu
.createColoredTexture(context
, 1, 1, [0, 0, 255, 255]);
50 context
.uniform1i(context
.getUniformLocation(program
, "tex"), 0);
52 context
.activeTexture(context
.TEXTURE_0
+ 5);
53 context
.bindTexture(context
.TEXTURE_2D
, texture
);
55 context
.viewport(0, 0, canvas
.width
, canvas
.height
);
57 context
.clearColor(255, 0, 0, 255);
58 context
.clear(context
.COLOR_BUFFER_BIT
| context
.DEPTH_BUFFER_BIT
);
60 // We need to ensure that the compositor has run before the drawing
61 // takes place. requestAnimationFrame was tried for this purpose,
62 // but it did not produce the failing behaviour in crbug.com/105045.
63 // A timeout of 100 ms was found to consistently reproduce the problem.
64 setTimeout(draw
, 100);
67 <canvas id=
"webgl-canvas" width=
"32px" height=
"32px"></canvas>