default-texture-draw-bug.html (2030B)
1 <!-- 2 Copyright (c) 2019 The Khronos Group Inc. 3 Use of this source code is governed by an MIT-style license that can be 4 found in the LICENSE.txt file. 5 --> 6 7 <html> 8 <head> 9 <meta charset="utf-8"> 10 <title>WebGL Default Texture Draw Bug Conformance Tests</title> 11 <link rel="stylesheet" href="../../resources/js-test-style.css"/> 12 <script src="../../js/js-test-pre.js"></script> 13 <script src="../../js/webgl-test-utils.js"></script> 14 15 </head> 16 <body> 17 <canvas id="c"></canvas> 18 <div id="description"></div> 19 <div id="console"></div> 20 <script> 21 "use strict"; 22 description("This test attempts to provoke a Chrome bug that occured when drawing with textures when one was never bound. <a href='http://crbug.com/524144'>crbug.com/524144</a>"); 23 24 debug(""); 25 26 var wtu = WebGLTestUtils; 27 var gl = wtu.create3DContext("c"); 28 var canvas = gl.canvas; 29 30 if (!gl) { 31 testFailed("WebGL context does not exist"); 32 } else { 33 testPassed("WebGL context exists"); 34 35 runDrawTests(); 36 37 wtu.glErrorShouldBe(gl, gl.NO_ERROR, "there should be no errors"); 38 } 39 40 function runDrawTests(drawType) { 41 debug("Test that drawing with a texture when no textures have been bound gives the expected black output"); 42 canvas.width = 50; canvas.height = 50; 43 gl.viewport(0, 0, canvas.width, canvas.height); 44 45 // Set up a program that will draw with a texture 46 var program = wtu.setupNoTexCoordTextureProgram(gl); 47 48 wtu.setupIndexedQuad(gl); 49 for (var i = 0 ; i < 100 && _bufferedConsoleLogs != null; ++i) { 50 // Clear to white. 51 gl.clearColor(1.0, 1.0, 1.0, 1.0); 52 gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT); 53 54 // Draw without binding any textures. 55 gl.drawElements(gl.TRIANGLES, 6, gl.UNSIGNED_SHORT, 0); 56 57 // Check to ensure the entire canvas is black. 58 wtu.checkCanvasRect(gl, 0.0, 0.0, canvas.width, canvas.height, 59 [0.0, 0.0, 0.0], "Draw should pass", 2); 60 } 61 } 62 63 debug(""); 64 var successfullyParsed = true; 65 </script> 66 <script src="../../js/js-test-post.js"></script> 67 68 </body> 69 </html>