error-reporting.html (2807B)
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 <!DOCTYPE html> 7 <html> 8 <head> 9 <meta charset="utf-8"> 10 <link rel="stylesheet" href="../../resources/js-test-style.css"/> 11 <script src="../../js/js-test-pre.js"></script> 12 <script src="../../js/webgl-test-utils.js"></script> 13 </head> 14 <body> 15 <div id="description"></div> 16 <div id="console"></div> 17 18 <script> 19 "use strict"; 20 description("Tests generation of synthetic and real GL errors"); 21 22 var wtu = WebGLTestUtils; 23 var context = wtu.create3DContext(); 24 var program = wtu.loadStandardProgram(context); 25 26 // Other tests like incorrect-context-object-behaviour already test the raising 27 // of many synthetic GL errors. This test verifies the raising of certain 28 // known real GL errors, and contains a few regression tests for bugs 29 // discovered in the synthetic error generation and in the WebGL 30 // implementation itself. 31 32 wtu.glErrorShouldBe(context, context.NO_ERROR); 33 34 debug("Testing getActiveAttrib"); 35 shouldThrow("context.getActiveAttrib(null, 2)"); 36 wtu.glErrorShouldBe(context, context.NO_ERROR); 37 // Error state should be clear by this point 38 wtu.glErrorShouldBe(context, context.NO_ERROR); 39 // Real OpenGL error 40 shouldBeNull("context.getActiveAttrib(program, 2)"); 41 wtu.glErrorShouldBe(context, context.INVALID_VALUE); 42 // Error state should be clear by this point 43 wtu.glErrorShouldBe(context, context.NO_ERROR); 44 45 debug("Testing getActiveUniform"); 46 shouldThrow("context.getActiveUniform(null, 0)"); 47 wtu.glErrorShouldBe(context, context.NO_ERROR); 48 // Error state should be clear by this point 49 wtu.glErrorShouldBe(context, context.NO_ERROR); 50 // Real OpenGL error 51 shouldBeNull("context.getActiveUniform(program, 50)"); 52 wtu.glErrorShouldBe(context, context.INVALID_VALUE); 53 // Error state should be clear by this point 54 wtu.glErrorShouldBe(context, context.NO_ERROR); 55 56 debug("Testing attempts to manipulate the default framebuffer"); 57 shouldBeUndefined("context.bindFramebuffer(context.FRAMEBUFFER, null)"); 58 wtu.glErrorShouldBe(context, context.NO_ERROR); 59 shouldBeUndefined("context.framebufferRenderbuffer(context.FRAMEBUFFER, context.DEPTH_ATTACHMENT, context.RENDERBUFFER, null)"); 60 // Synthetic OpenGL error 61 wtu.glErrorShouldBe(context, context.INVALID_OPERATION); 62 // Error state should be clear by this point 63 wtu.glErrorShouldBe(context, context.NO_ERROR); 64 shouldBeUndefined("context.framebufferTexture2D(context.FRAMEBUFFER, context.COLOR_ATTACHMENT0, context.TEXTURE_2D, null, 0)"); 65 // Synthetic OpenGL error 66 wtu.glErrorShouldBe(context, context.INVALID_OPERATION); 67 // Error state should be clear by this point 68 wtu.glErrorShouldBe(context, context.NO_ERROR); 69 70 var successfullyParsed = true; 71 </script> 72 73 <script src="../../js/js-test-post.js"></script> 74 </body> 75 </html>