4 ** Copyright (c) 2012 The Khronos Group Inc.
6 ** Permission is hereby granted, free of charge, to any person obtaining a
7 ** copy of this software and/or associated documentation files (the
8 ** "Materials"), to deal in the Materials without restriction, including
9 ** without limitation the rights to use, copy, modify, merge, publish,
10 ** distribute, sublicense, and/or sell copies of the Materials, and to
11 ** permit persons to whom the Materials are furnished to do so, subject to
12 ** the following conditions:
14 ** The above copyright notice and this permission notice shall be included
15 ** in all copies or substantial portions of the Materials.
17 ** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18 ** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19 ** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
20 ** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
21 ** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
22 ** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
23 ** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
30 <meta charset="utf-8">
31 <title>WebGL Constants and Properties Test</title>
32 <link rel="stylesheet" href="../../resources/js-test-style.css"/>
33 <script src="../../resources/js-test-pre.js"></script>
34 <script src="../resources/webgl-test-utils.js"></script>
37 <div id="description"></div>
38 <div id="console"></div>
39 <canvas id="canvas" style="width: 50px; height: 50px;"> </canvas>
42 description("This test ensures that the WebGL context has all the constants and (non-function) properties in the specification.");
46 DEPTH_BUFFER_BIT : 0x00000100,
47 STENCIL_BUFFER_BIT : 0x00000400,
48 COLOR_BUFFER_BIT : 0x00004000,
56 TRIANGLE_STRIP : 0x0005,
57 TRIANGLE_FAN : 0x0006,
59 /* AlphaFunction (not supported in ES20) */
69 /* BlendingFactorDest */
73 ONE_MINUS_SRC_COLOR : 0x0301,
75 ONE_MINUS_SRC_ALPHA : 0x0303,
77 ONE_MINUS_DST_ALPHA : 0x0305,
79 /* BlendingFactorSrc */
83 ONE_MINUS_DST_COLOR : 0x0307,
84 SRC_ALPHA_SATURATE : 0x0308,
86 /* ONE_MINUS_SRC_ALPHA */
88 /* ONE_MINUS_DST_ALPHA */
90 /* BlendEquationSeparate */
92 BLEND_EQUATION : 0x8009,
93 BLEND_EQUATION_RGB : 0x8009, /* same as BLEND_EQUATION */
94 BLEND_EQUATION_ALPHA : 0x883D,
97 FUNC_SUBTRACT : 0x800A,
98 FUNC_REVERSE_SUBTRACT : 0x800B,
100 /* Separate Blend Functions */
101 BLEND_DST_RGB : 0x80C8,
102 BLEND_SRC_RGB : 0x80C9,
103 BLEND_DST_ALPHA : 0x80CA,
104 BLEND_SRC_ALPHA : 0x80CB,
105 CONSTANT_COLOR : 0x8001,
106 ONE_MINUS_CONSTANT_COLOR : 0x8002,
107 CONSTANT_ALPHA : 0x8003,
108 ONE_MINUS_CONSTANT_ALPHA : 0x8004,
109 BLEND_COLOR : 0x8005,
112 ARRAY_BUFFER : 0x8892,
113 ELEMENT_ARRAY_BUFFER : 0x8893,
114 ARRAY_BUFFER_BINDING : 0x8894,
115 ELEMENT_ARRAY_BUFFER_BINDING : 0x8895,
117 STREAM_DRAW : 0x88E0,
118 STATIC_DRAW : 0x88E4,
119 DYNAMIC_DRAW : 0x88E8,
121 BUFFER_SIZE : 0x8764,
122 BUFFER_USAGE : 0x8765,
124 CURRENT_VERTEX_ATTRIB : 0x8626,
129 FRONT_AND_BACK : 0x0408,
146 STENCIL_TEST : 0x0B90,
148 SCISSOR_TEST : 0x0C11,
149 POLYGON_OFFSET_FILL : 0x8037,
150 SAMPLE_ALPHA_TO_COVERAGE : 0x809E,
151 SAMPLE_COVERAGE : 0x80A0,
155 INVALID_ENUM : 0x0500,
156 INVALID_VALUE : 0x0501,
157 INVALID_OPERATION : 0x0502,
158 OUT_OF_MEMORY : 0x0505,
160 /* FrontFaceDirection */
166 ALIASED_POINT_SIZE_RANGE : 0x846D,
167 ALIASED_LINE_WIDTH_RANGE : 0x846E,
168 CULL_FACE_MODE : 0x0B45,
170 DEPTH_RANGE : 0x0B70,
171 DEPTH_WRITEMASK : 0x0B72,
172 DEPTH_CLEAR_VALUE : 0x0B73,
174 STENCIL_CLEAR_VALUE : 0x0B91,
175 STENCIL_FUNC : 0x0B92,
176 STENCIL_FAIL : 0x0B94,
177 STENCIL_PASS_DEPTH_FAIL : 0x0B95,
178 STENCIL_PASS_DEPTH_PASS : 0x0B96,
179 STENCIL_REF : 0x0B97,
180 STENCIL_VALUE_MASK : 0x0B93,
181 STENCIL_WRITEMASK : 0x0B98,
182 STENCIL_BACK_FUNC : 0x8800,
183 STENCIL_BACK_FAIL : 0x8801,
184 STENCIL_BACK_PASS_DEPTH_FAIL : 0x8802,
185 STENCIL_BACK_PASS_DEPTH_PASS : 0x8803,
186 STENCIL_BACK_REF : 0x8CA3,
187 STENCIL_BACK_VALUE_MASK : 0x8CA4,
188 STENCIL_BACK_WRITEMASK : 0x8CA5,
190 SCISSOR_BOX : 0x0C10,
192 COLOR_CLEAR_VALUE : 0x0C22,
193 COLOR_WRITEMASK : 0x0C23,
194 UNPACK_ALIGNMENT : 0x0CF5,
195 PACK_ALIGNMENT : 0x0D05,
196 MAX_TEXTURE_SIZE : 0x0D33,
197 MAX_VIEWPORT_DIMS : 0x0D3A,
198 SUBPIXEL_BITS : 0x0D50,
204 STENCIL_BITS : 0x0D57,
205 POLYGON_OFFSET_UNITS : 0x2A00,
206 /* POLYGON_OFFSET_FILL */
207 POLYGON_OFFSET_FACTOR : 0x8038,
208 TEXTURE_BINDING_2D : 0x8069,
209 SAMPLE_BUFFERS : 0x80A8,
211 SAMPLE_COVERAGE_VALUE : 0x80AA,
212 SAMPLE_COVERAGE_INVERT : 0x80AB,
214 /* GetTextureParameter */
215 /* TEXTURE_MAG_FILTER */
216 /* TEXTURE_MIN_FILTER */
220 COMPRESSED_TEXTURE_FORMATS : 0x86A3,
228 GENERATE_MIPMAP_HINT : 0x8192,
232 UNSIGNED_BYTE : 0x1401,
234 UNSIGNED_SHORT : 0x1403,
236 UNSIGNED_INT : 0x1405,
240 DEPTH_COMPONENT : 0x1902,
245 LUMINANCE_ALPHA : 0x190A,
249 UNSIGNED_SHORT_4_4_4_4 : 0x8033,
250 UNSIGNED_SHORT_5_5_5_1 : 0x8034,
251 UNSIGNED_SHORT_5_6_5 : 0x8363,
254 FRAGMENT_SHADER : 0x8B30,
255 VERTEX_SHADER : 0x8B31,
256 MAX_VERTEX_ATTRIBS : 0x8869,
257 MAX_VERTEX_UNIFORM_VECTORS : 0x8DFB,
258 MAX_VARYING_VECTORS : 0x8DFC,
259 MAX_COMBINED_TEXTURE_IMAGE_UNITS : 0x8B4D,
260 MAX_VERTEX_TEXTURE_IMAGE_UNITS : 0x8B4C,
261 MAX_TEXTURE_IMAGE_UNITS : 0x8872,
262 MAX_FRAGMENT_UNIFORM_VECTORS : 0x8DFD,
263 SHADER_TYPE : 0x8B4F,
264 DELETE_STATUS : 0x8B80,
265 LINK_STATUS : 0x8B82,
266 VALIDATE_STATUS : 0x8B83,
267 ATTACHED_SHADERS : 0x8B85,
268 ACTIVE_UNIFORMS : 0x8B86,
269 ACTIVE_ATTRIBUTES : 0x8B89,
270 SHADING_LANGUAGE_VERSION : 0x8B8C,
271 CURRENT_PROGRAM : 0x8B8D,
273 /* StencilFunction */
298 /* TextureMagFilter */
302 /* TextureMinFilter */
305 NEAREST_MIPMAP_NEAREST : 0x2700,
306 LINEAR_MIPMAP_NEAREST : 0x2701,
307 NEAREST_MIPMAP_LINEAR : 0x2702,
308 LINEAR_MIPMAP_LINEAR : 0x2703,
310 /* TextureParameterName */
311 TEXTURE_MAG_FILTER : 0x2800,
312 TEXTURE_MIN_FILTER : 0x2801,
313 TEXTURE_WRAP_S : 0x2802,
314 TEXTURE_WRAP_T : 0x2803,
320 TEXTURE_CUBE_MAP : 0x8513,
321 TEXTURE_BINDING_CUBE_MAP : 0x8514,
322 TEXTURE_CUBE_MAP_POSITIVE_X : 0x8515,
323 TEXTURE_CUBE_MAP_NEGATIVE_X : 0x8516,
324 TEXTURE_CUBE_MAP_POSITIVE_Y : 0x8517,
325 TEXTURE_CUBE_MAP_NEGATIVE_Y : 0x8518,
326 TEXTURE_CUBE_MAP_POSITIVE_Z : 0x8519,
327 TEXTURE_CUBE_MAP_NEGATIVE_Z : 0x851A,
328 MAX_CUBE_MAP_TEXTURE_SIZE : 0x851C,
363 ACTIVE_TEXTURE : 0x84E0,
365 /* TextureWrapMode */
367 CLAMP_TO_EDGE : 0x812F,
368 MIRRORED_REPEAT : 0x8370,
385 SAMPLER_CUBE : 0x8B60,
388 VERTEX_ATTRIB_ARRAY_ENABLED : 0x8622,
389 VERTEX_ATTRIB_ARRAY_SIZE : 0x8623,
390 VERTEX_ATTRIB_ARRAY_STRIDE : 0x8624,
391 VERTEX_ATTRIB_ARRAY_TYPE : 0x8625,
392 VERTEX_ATTRIB_ARRAY_NORMALIZED : 0x886A,
393 VERTEX_ATTRIB_ARRAY_POINTER : 0x8645,
394 VERTEX_ATTRIB_ARRAY_BUFFER_BINDING : 0x889F,
397 IMPLEMENTATION_COLOR_READ_TYPE : 0x8B9A,
398 IMPLEMENTATION_COLOR_READ_FORMAT : 0x8B9B,
401 COMPILE_STATUS : 0x8B81,
403 /* Shader Precision-Specified Types */
405 MEDIUM_FLOAT : 0x8DF1,
411 /* Framebuffer Object. */
412 FRAMEBUFFER : 0x8D40,
413 RENDERBUFFER : 0x8D41,
418 DEPTH_COMPONENT16 : 0x81A5,
419 STENCIL_INDEX : 0x1901,
420 STENCIL_INDEX8 : 0x8D48,
421 DEPTH_STENCIL : 0x84F9,
423 RENDERBUFFER_WIDTH : 0x8D42,
424 RENDERBUFFER_HEIGHT : 0x8D43,
425 RENDERBUFFER_INTERNAL_FORMAT : 0x8D44,
426 RENDERBUFFER_RED_SIZE : 0x8D50,
427 RENDERBUFFER_GREEN_SIZE : 0x8D51,
428 RENDERBUFFER_BLUE_SIZE : 0x8D52,
429 RENDERBUFFER_ALPHA_SIZE : 0x8D53,
430 RENDERBUFFER_DEPTH_SIZE : 0x8D54,
431 RENDERBUFFER_STENCIL_SIZE : 0x8D55,
433 FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE : 0x8CD0,
434 FRAMEBUFFER_ATTACHMENT_OBJECT_NAME : 0x8CD1,
435 FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL : 0x8CD2,
436 FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE : 0x8CD3,
438 COLOR_ATTACHMENT0 : 0x8CE0,
439 DEPTH_ATTACHMENT : 0x8D00,
440 STENCIL_ATTACHMENT : 0x8D20,
441 DEPTH_STENCIL_ATTACHMENT : 0x821A,
445 FRAMEBUFFER_COMPLETE : 0x8CD5,
446 FRAMEBUFFER_INCOMPLETE_ATTACHMENT : 0x8CD6,
447 FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT : 0x8CD7,
448 FRAMEBUFFER_INCOMPLETE_DIMENSIONS : 0x8CD9,
449 FRAMEBUFFER_UNSUPPORTED : 0x8CDD,
451 FRAMEBUFFER_BINDING : 0x8CA6,
452 RENDERBUFFER_BINDING : 0x8CA7,
453 MAX_RENDERBUFFER_SIZE : 0x84E8,
455 INVALID_FRAMEBUFFER_OPERATION : 0x0506,
457 /* WebGL-specific enums */
458 UNPACK_FLIP_Y_WEBGL : 0x9240,
459 UNPACK_PREMULTIPLY_ALPHA_WEBGL : 0x9241,
460 CONTEXT_LOST_WEBGL : 0x9242,
461 UNPACK_COLORSPACE_CONVERSION_WEBGL : 0x9243,
462 BROWSER_DEFAULT_WEBGL : 0x9244
465 // Other non-function properties on the WebGL object
466 var otherProperties = {
467 drawingBufferWidth : "number",
468 drawingBufferHeight : "number",
469 canvas : "implementation-dependent"
472 // Properties to be ignored (as a list of strings) because they were
473 // added in versions of the spec that are backward-compatible with
475 var ignoredProperties = [
478 // Constants removed from the WebGL spec compared to ES 2.0
479 var removedConstants = {
480 NUM_COMPRESSED_TEXTURE_FORMATS : 0x86A2,
482 ACTIVE_UNIFORM_MAX_LENGTH : 0x8B87,
483 ACTIVE_ATTRIBUTE_MAX_LENGTH : 0x8B8A,
485 INFO_LOG_LENGTH : 0x8B84,
486 SHADER_SOURCE_LENGTH : 0x8B88,
487 SHADER_COMPILER : 0x8DFA,
488 SHADER_BINARY_FORMATS : 0x8DF8,
489 NUM_SHADER_BINARY_FORMATS : 0x8DF9,
492 function assertProperty(v, p) {
496 testFailed("Property does not exist: " + p)
501 function assertNoProperty(v, p) {
503 testFailed("Property is defined and should not be: " + p)
510 function assertMsg_(bool, msg) {
511 if (!bool) // show only failures to avoid spamming result list
512 assertMsg(bool, msg);
517 debug("Canvas.getContext");
519 var canvas = document.getElementById("canvas");
520 var wtu = WebGLTestUtils;
521 var gl = wtu.create3DContext(canvas);
523 for (var i in constants) {
524 var r = assertProperty(gl, i) && assertMsg_(gl[i] == constants[i], "Property "+i+" value test "+gl[i]+" == "+constants[i]);
525 passed = passed && r;
528 testPassed("All WebGL constants found to have correct values.");
531 for (var i in removedConstants) {
532 var r = assertNoProperty(gl, i);
533 passed = passed && r;
536 testPassed("All constants removed from WebGL spec were absent from WebGL context.");
538 var extended = false;
540 if (constants[i] !== undefined) {
541 // OK; known constant
542 } else if (ignoredProperties.indexOf(i) != -1) {
543 // OK; constant that should be ignored because it was added in a later version of the spec
544 } else if (otherProperties[i] !== undefined &&
545 (otherProperties[i] == "implementation-dependent" || typeof gl[i] == otherProperties[i])) {
546 // OK; known property of known type
547 } else if (typeof gl[i] != "function") {
550 testFailed("Also found the following extra properties:");
557 testPassed("No extra properties found on WebGL context.");
561 var successfullyParsed = true;
563 <script src="../../resources/js-test-post.js"></script>