Backed out changeset b462e7b742d8 (bug 1908261) for causing multiple reftest failures...
[gecko.git] / dom / canvas / test / webgl-conf / checkout / conformance / state / gl-get-calls.html
bloba1a27d8e6c586ae60e0192556502770c9ad97037
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 -->
7 <!DOCTYPE html>
8 <html>
9 <head>
10 <meta charset="utf-8">
11 <title>WebGL gl calls Conformance Tests</title>
12 <link rel="stylesheet" href="../../resources/js-test-style.css"/>
13 <script src="../../js/js-test-pre.js"></script>
14 <script src="../../js/webgl-test-utils.js"></script>
15 </head>
16 <body>
17 <div id="description"></div>
18 <div id="console"></div>
19 <canvas id="canvas" width="2" height="2"> </canvas>
20 <script>
21 "use strict";
22 description("This test ensures basic functionality of the underlying graphics library");
24 debug("");
25 debug("Canvas.getContext");
27 var minimumRequiredStencilMask = 0;
28 var wtu = WebGLTestUtils;
29 var context = wtu.create3DContext("canvas");
30 if (!context)
31 testFailed("context does not exist");
32 else {
33 testPassed("context exists");
35 debug("");
36 debug("Context contains getError");
37 if ("getError" in context)
38 testPassed("context contains getError");
39 else
40 testFailed("context does not contains getError");
42 debug("");
43 debug("Check default values");
44 shouldBe('context.getParameter(context.ACTIVE_TEXTURE)', 'context.TEXTURE0');
45 shouldBe('(context.getParameter(context.ALIASED_LINE_WIDTH_RANGE)[0] <= 1) && (context.getParameter(context.ALIASED_LINE_WIDTH_RANGE)[0] > 0) && (context.getParameter(context.ALIASED_LINE_WIDTH_RANGE)[1] >= 1)', 'true');
46 shouldBe('(context.getParameter(context.ALIASED_POINT_SIZE_RANGE)[0] <= 1) && (context.getParameter(context.ALIASED_POINT_SIZE_RANGE)[0] > 0) && (context.getParameter(context.ALIASED_POINT_SIZE_RANGE)[1] >= 1)', 'true');
47 shouldBeType('context.getParameter(context.ALIASED_LINE_WIDTH_RANGE)', 'Float32Array');
48 shouldBeType('context.getParameter(context.ALIASED_POINT_SIZE_RANGE)', 'Float32Array');
49 shouldBe('context.getParameter(context.ARRAY_BUFFER_BINDING)', 'null');
50 shouldBe('context.getParameter(context.BLEND)', 'false');
51 shouldBe('context.getParameter(context.BLEND_COLOR)', '[0, 0, 0, 0]');
52 shouldBeType('context.getParameter(context.BLEND_COLOR)', 'Float32Array');
53 shouldBe('context.getParameter(context.BLEND_DST_ALPHA)', '0');
54 shouldBe('context.getParameter(context.BLEND_DST_RGB)', '0');
55 shouldBe('context.getParameter(context.BLEND_EQUATION_ALPHA)', 'context.FUNC_ADD');
56 shouldBe('context.getParameter(context.BLEND_EQUATION_RGB)', 'context.FUNC_ADD');
57 shouldBe('context.getParameter(context.BLEND_SRC_ALPHA)', '1');
58 shouldBe('context.getParameter(context.BLEND_SRC_RGB)', '1');
59 shouldBe('context.getParameter(context.COLOR_CLEAR_VALUE)', '[0, 0, 0, 0]');
60 shouldBeType('context.getParameter(context.COLOR_CLEAR_VALUE)', 'Float32Array');
61 shouldBe('context.getParameter(context.COLOR_WRITEMASK)', '[true, true, true, true]');
62 shouldBeType('context.getParameter(context.COMPRESSED_TEXTURE_FORMATS)', 'Uint32Array');
63 shouldBe('context.getParameter(context.CULL_FACE)', 'false');
64 shouldBe('context.getParameter(context.CULL_FACE_MODE)', 'context.BACK');
65 shouldBe('context.getParameter(context.CURRENT_PROGRAM)', 'null');
66 shouldBe('context.getParameter(context.DEPTH_CLEAR_VALUE)', '1');
67 shouldBe('context.getParameter(context.DEPTH_FUNC)', 'context.LESS');
68 shouldBe('context.getParameter(context.DEPTH_RANGE)', '[0, 1]');
69 shouldBeType('context.getParameter(context.DEPTH_RANGE)', 'Float32Array');
70 shouldBe('context.getParameter(context.DEPTH_TEST)', 'false');
71 shouldBe('context.getParameter(context.DEPTH_WRITEMASK)', 'true');
72 shouldBe('context.getParameter(context.DITHER)', 'true');
73 shouldBe('context.getParameter(context.ELEMENT_ARRAY_BUFFER_BINDING)', 'null');
74 shouldBe('context.getParameter(context.FRONT_FACE)', 'context.CCW');
75 shouldBe('context.getParameter(context.GENERATE_MIPMAP_HINT)', 'context.DONT_CARE');
76 shouldBe('context.getParameter(context.LINE_WIDTH)', '1');
77 shouldBe('context.getParameter(context.PACK_ALIGNMENT)', '4');
78 shouldBe('context.getParameter(context.POLYGON_OFFSET_FACTOR)', '0');
79 shouldBe('context.getParameter(context.POLYGON_OFFSET_FILL)', 'false');
80 shouldBe('context.getParameter(context.POLYGON_OFFSET_UNITS)', '0');
81 shouldBe('context.getParameter(context.RENDERBUFFER_BINDING)', 'null');
82 shouldBe('context.getParameter(context.SAMPLE_COVERAGE_INVERT)', 'false');
83 shouldBe('context.getParameter(context.SAMPLE_COVERAGE_VALUE)', '1');
84 shouldBe('context.getParameter(context.SCISSOR_BOX)[0]', '0');
85 shouldBe('context.getParameter(context.SCISSOR_BOX)[1]', '0');
86 shouldBe('context.getParameter(context.SCISSOR_BOX)[2]', 'context.getParameter(context.VIEWPORT)[2]');
87 shouldBe('context.getParameter(context.SCISSOR_BOX)[3]', 'context.getParameter(context.VIEWPORT)[3]');
88 shouldBeType('context.getParameter(context.SCISSOR_BOX)', Int32Array);
89 shouldBe('context.getParameter(context.SCISSOR_TEST)', 'false');
90 shouldBe('context.getParameter(context.STENCIL_BACK_FAIL)', 'context.KEEP');
91 shouldBe('context.getParameter(context.STENCIL_BACK_FUNC)', 'context.ALWAYS');
92 shouldBe('context.getParameter(context.STENCIL_BACK_PASS_DEPTH_FAIL)', 'context.KEEP');
93 shouldBe('context.getParameter(context.STENCIL_BACK_PASS_DEPTH_PASS)', 'context.KEEP');
94 shouldBe('context.getParameter(context.STENCIL_BACK_REF)', '0');
96 // WebGL 1.0.2 - 5.14.3 types / ES 2.0.25 - 6.2 State tables - 6.18 page 152
97 shouldBeType('context.getParameter(context.SUBPIXEL_BITS)', 'Number');
98 shouldBeGreaterThanOrEqual('context.getParameter(context.SUBPIXEL_BITS)', '4');
100 shouldBeType('context.getParameter(context.SAMPLE_BUFFERS)', 'Number');
101 shouldBeGreaterThanOrEqual('context.getParameter(context.SAMPLE_BUFFERS)', '0');
103 shouldBeType('context.getParameter(context.SAMPLES)', 'Number');
104 shouldBeGreaterThanOrEqual('context.getParameter(context.SAMPLES)', '0');
106 shouldBeType('context.getParameter(context.DEPTH_BITS)', 'Number');
107 shouldBeGreaterThanOrEqual('context.getParameter(context.DEPTH_BITS)', '0');
108 shouldBeType('context.getParameter(context.RED_BITS)', 'Number');
109 shouldBeGreaterThanOrEqual('context.getParameter(context.RED_BITS)', '0');
110 shouldBeType('context.getParameter(context.GREEN_BITS)', 'Number');
111 shouldBeGreaterThanOrEqual('context.getParameter(context.GREEN_BITS)', '0');
112 shouldBeType('context.getParameter(context.BLUE_BITS)', 'Number');
113 shouldBeGreaterThanOrEqual('context.getParameter(context.BLUE_BITS)', '0');
114 shouldBeType('context.getParameter(context.ALPHA_BITS)', 'Number');
115 shouldBeGreaterThanOrEqual('context.getParameter(context.ALPHA_BITS)', '0');
116 shouldBeType('context.getParameter(context.STENCIL_BITS)', 'Number');
118 var stencilBits = context.getParameter(context.STENCIL_BITS);
119 minimumRequiredStencilMask = (1 << stencilBits) - 1;
121 shouldBe('context.getParameter(context.STENCIL_BACK_VALUE_MASK) & minimumRequiredStencilMask', 'minimumRequiredStencilMask');
122 shouldBe('context.getParameter(context.STENCIL_BACK_WRITEMASK) & minimumRequiredStencilMask', 'minimumRequiredStencilMask');
124 // If EXT_packed_depth_stencil is supported, STENCIL_BITS > 0; otherwise, STENCIL_BITS == 0.
125 shouldBe('context.getParameter(context.STENCIL_BITS) >= 0', 'true');
126 shouldBe('context.getParameter(context.STENCIL_CLEAR_VALUE)', '0');
127 shouldBe('context.getParameter(context.STENCIL_FAIL)', 'context.KEEP');
128 shouldBe('context.getParameter(context.STENCIL_FUNC)', 'context.ALWAYS');
129 shouldBe('context.getParameter(context.STENCIL_PASS_DEPTH_FAIL)', 'context.KEEP');
130 shouldBe('context.getParameter(context.STENCIL_PASS_DEPTH_PASS)', 'context.KEEP');
131 shouldBe('context.getParameter(context.STENCIL_REF)', '0');
132 shouldBe('context.getParameter(context.STENCIL_TEST)', 'false');
134 shouldBe('context.getParameter(context.STENCIL_VALUE_MASK) & minimumRequiredStencilMask', 'minimumRequiredStencilMask');
135 shouldBe('context.getParameter(context.STENCIL_WRITEMASK) & minimumRequiredStencilMask', 'minimumRequiredStencilMask');
137 shouldBe('context.getParameter(context.TEXTURE_BINDING_2D)', 'null');
138 shouldBe('context.getParameter(context.TEXTURE_BINDING_CUBE_MAP)', 'null');
139 shouldBe('context.getParameter(context.UNPACK_ALIGNMENT)', '4');
140 shouldBe('context.getParameter(context.UNPACK_FLIP_Y_WEBGL)', 'false');
141 shouldBe('context.getParameter(context.UNPACK_PREMULTIPLY_ALPHA_WEBGL)', 'false');
142 shouldBe('context.getParameter(context.VIEWPORT)', '[0, 0, 2, 2]');
143 shouldBeType('context.getParameter(context.VIEWPORT)', 'Int32Array');
145 shouldBeGreaterThanOrEqual('context.getParameter(context.MAX_COMBINED_TEXTURE_IMAGE_UNITS)', '8');
146 shouldBeGreaterThanOrEqual('context.getParameter(context.MAX_CUBE_MAP_TEXTURE_SIZE)', '16');
147 shouldBeGreaterThanOrEqual('context.getParameter(context.MAX_FRAGMENT_UNIFORM_VECTORS)', '16');
148 shouldBeGreaterThanOrEqual('context.getParameter(context.MAX_RENDERBUFFER_SIZE)', '1');
149 shouldBeGreaterThanOrEqual('context.getParameter(context.MAX_TEXTURE_IMAGE_UNITS)', '8');
150 shouldBeGreaterThanOrEqual('context.getParameter(context.MAX_TEXTURE_SIZE)', '64');
151 shouldBeGreaterThanOrEqual('context.getParameter(context.MAX_VARYING_VECTORS)', '8');
152 shouldBeGreaterThanOrEqual('context.getParameter(context.MAX_VERTEX_ATTRIBS)', '8');
153 shouldBeGreaterThanOrEqual('context.getParameter(context.MAX_VERTEX_TEXTURE_IMAGE_UNITS)', '0');
154 shouldBeGreaterThanOrEqual('context.getParameter(context.MAX_VERTEX_UNIFORM_VECTORS)', '128');
155 // Note: This requirement should be removed from the spec IMO. Many impelementations
156 // will be based on FBOs and FBOs might have a restriction smaller than the current screen size.
157 // especially if there are multiple screens.
158 shouldBeTrue('context.getParameter(context.MAX_VIEWPORT_DIMS)[0] >= window.screen.width');
159 shouldBeTrue('context.getParameter(context.MAX_VIEWPORT_DIMS)[1] >= window.screen.height');
160 shouldBeType('context.getParameter(context.MAX_VIEWPORT_DIMS)', 'Int32Array');
162 debug("");
163 debug("check texture values");
164 var maxTextures = context.getParameter(context.MAX_TEXTURE_IMAGE_UNITS);
165 for (var ii = 0; ii < maxTextures; ++ii) {
166 context.activeTexture(context.TEXTURE0 + ii);
167 debug("check texture unit: " + ii);
168 shouldBe('context.getParameter(context.TEXTURE_BINDING_2D)', 'null');
169 shouldBe('context.getParameter(context.TEXTURE_BINDING_CUBE_MAP)', 'null');
172 debug("");
173 debug("check attrib values");
174 var maxAttribs = context.getParameter(context.MAX_VERTEX_ATTRIBS);
175 for (var ii = 0; ii < maxAttribs; ++ii) {
176 debug("check attrib: " + ii);
177 shouldBe('context.getVertexAttrib(ii, context.VERTEX_ATTRIB_ARRAY_BUFFER_BINDING)', 'null');
178 shouldBe('context.getVertexAttrib(ii, context.VERTEX_ATTRIB_ARRAY_ENABLED)', 'false');
179 shouldBe('context.getVertexAttrib(ii, context.VERTEX_ATTRIB_ARRAY_SIZE)', '4');
180 shouldBe('context.getVertexAttrib(ii, context.VERTEX_ATTRIB_ARRAY_STRIDE)', '0');
181 shouldBe('context.getVertexAttrib(ii, context.VERTEX_ATTRIB_ARRAY_TYPE)', 'context.FLOAT');
182 shouldBe('context.getVertexAttrib(ii, context.VERTEX_ATTRIB_ARRAY_NORMALIZED)', 'false');
183 shouldBe('context.getVertexAttrib(ii, context.CURRENT_VERTEX_ATTRIB)', '[0, 0, 0, 1]');
184 shouldBeType('context.getVertexAttrib(ii, context.CURRENT_VERTEX_ATTRIB)', 'Float32Array');
185 shouldBe('context.getVertexAttribOffset(ii, context.VERTEX_ATTRIB_ARRAY_POINTER)', '0');
188 shouldBe('context.getError()', 'context.NO_ERROR');
191 debug("");
192 var successfullyParsed = true;
194 </script>
195 <script src="../../js/js-test-post.js"></script>
197 </body>
198 </html>