Backed out changeset 7272b7396c78 (bug 1932758) for causing fenix debug failures...
[gecko.git] / dom / canvas / test / webgl-conf / checkout / deqp / functional / gles3 / es3fNegativeBufferApiTests.js
blob2a8910eb0d3d9cca27fcf5513c604bbc92d47088
1 'use strict';
2 goog.provide('functional.gles3.es3fNegativeBufferApiTests');
3 goog.require('framework.common.tcuTestCase');
4 goog.require('framework.opengl.gluStrUtil');
5 goog.require('functional.gles3.es3fApiCase');
7 goog.scope(function() {
9     var es3fNegativeBufferApiTests = functional.gles3.es3fNegativeBufferApiTests;
10     var es3fApiCase = functional.gles3.es3fApiCase;
11     var gluStrUtil = framework.opengl.gluStrUtil;
12     var tcuTestCase = framework.common.tcuTestCase;
14     /**
15     * @param {WebGL2RenderingContext} gl
16     */
17     es3fNegativeBufferApiTests.init = function(gl) {
19         var testGroup = tcuTestCase.runner.testCases;
20         testGroup.addChild(new es3fApiCase.ApiCaseCallback(
21             'bind_buffer', 'Invalid gl.bindBuffer() usage', gl,
22             function() {
23                 bufferedLogToConsole('gl.INVALID_ENUM is generated if target is not one of the allowable values.');
24                 gl.bindBuffer(-1, null);
25                 this.expectError(gl.INVALID_ENUM);
26             }
27         ));
29         testGroup.addChild(new es3fApiCase.ApiCaseCallback(
30             'buffer_data', 'Invalid gl.bufferData() usage', gl,
31             function() {
32                 var buffer = gl.createBuffer();
33                 gl.bindBuffer(gl.ARRAY_BUFFER, buffer);
35                 bufferedLogToConsole('gl.INVALID_ENUM is generated if target is not gl.ARRAY_BUFFER or gl.ELEMENT_ARRAY_BUFFER.');
36                 gl.bufferData(-1, 0, gl.STREAM_DRAW);
37                 this.expectError(gl.INVALID_ENUM);
39                 bufferedLogToConsole('gl.INVALID_ENUM is generated if usage is not gl.STREAM_DRAW, gl.STATIC_DRAW, or gl.DYNAMIC_DRAW.');
40                 gl.bufferData(gl.ARRAY_BUFFER, 0, -1);
41                 this.expectError(gl.INVALID_ENUM);
43                 bufferedLogToConsole('gl.INVALID_VALUE is generated if size is negative.');
44                 gl.bufferData(gl.ARRAY_BUFFER, -1, gl.STREAM_DRAW);
45                 this.expectError(gl.INVALID_VALUE);
47                 bufferedLogToConsole('gl.INVALID_OPERATION is generated if the reserved buffer object name 0 is bound to target.');
48                 gl.bindBuffer(gl.ARRAY_BUFFER, null);
49                 gl.bufferData(gl.ARRAY_BUFFER, 0, gl.STREAM_DRAW);
50                 this.expectError(gl.INVALID_OPERATION);
52                 gl.deleteBuffer(buffer);
53             }
54         ));
56         testGroup.addChild(new es3fApiCase.ApiCaseCallback(
57             'buffer_sub_data', 'Invalid gl.bufferSubData() usage', gl,
58             function() {
59                 var buffer = gl.createBuffer();
60                 var data = new ArrayBuffer(5);
61                 gl.bindBuffer(gl.ARRAY_BUFFER, buffer);
62                 gl.bufferData(gl.ARRAY_BUFFER, 10, gl.STREAM_DRAW);
64                 bufferedLogToConsole('gl.INVALID_ENUM is generated if target is not gl.ARRAY_BUFFER or gl.ELEMENT_ARRAY_BUFFER.');
65                 gl.bufferSubData(-1, 1, data);
66                 this.expectError(gl.INVALID_ENUM);
68                 bufferedLogToConsole('gl.INVALID_OPERATION is generated if the reserved buffer object name 0 is bound to target.');
69                 gl.bindBuffer(gl.ARRAY_BUFFER, null);
70                 gl.bufferSubData(gl.ARRAY_BUFFER, 0, data);
71                 this.expectError(gl.INVALID_OPERATION);
73                 gl.deleteBuffer(buffer);
74             }
75         ));
77         testGroup.addChild(new es3fApiCase.ApiCaseCallback(
78             'buffer_sub_data_size_offset', 'Invalid gl.bufferSubData() usage', gl,
79             function() {
80                 var buffer = gl.createBuffer();
81                 var data = new ArrayBuffer(5);
82                 gl.bindBuffer(gl.ARRAY_BUFFER, buffer);
83                 gl.bufferData(gl.ARRAY_BUFFER, 10, gl.STREAM_DRAW);
85                 bufferedLogToConsole('gl.INVALID_VALUE is generated if offset is negative');
86                 gl.bufferSubData(gl.ARRAY_BUFFER, -1, data);
87                 this.expectError(gl.INVALID_VALUE);
89                 bufferedLogToConsole('gl.INVALID_VALUE is generated if the data would be written past the end of the buffer.');
90                 gl.bufferSubData(gl.ARRAY_BUFFER, 7, data);
91                 this.expectError(gl.INVALID_VALUE);
92                 gl.bufferSubData(gl.ARRAY_BUFFER, 15, data);
93                 this.expectError(gl.INVALID_VALUE);
95                 bufferedLogToConsole('An exception is thrown if data is null.');
96                 this.expectThrowNoError(function() {
97                     gl.bufferSubData(gl.ARRAY_BUFFER, 0, null);
98                 });
100                 gl.deleteBuffer(buffer);
101             }
102         ));
104         testGroup.addChild(new es3fApiCase.ApiCaseCallback(
105             'clear', 'Invalid gl.clear() usage', gl,
106             function() {
107                 bufferedLogToConsole('gl.INVALID_VALUE is generated if any bit other than the three defined bits is set in mask.');
108                 gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT | gl.STENCIL_BUFFER_BIT);
109                 this.expectError(gl.NO_ERROR);
110                 gl.clear(0x0200);
111                 this.expectError(gl.INVALID_VALUE);
112                 gl.clear(0x1000);
113                 this.expectError(gl.INVALID_VALUE);
114                 gl.clear(0x0010);
115                 this.expectError(gl.INVALID_VALUE);
116             }
117         ));
119         testGroup.addChild(new es3fApiCase.ApiCaseCallback(
120             'read_pixels', 'Invalid gl.readPixels() usage', gl,
121             function() {
122                 var buffer = new ArrayBuffer(8);
123                 var ubyteData = new Uint8Array(buffer);
124                 var ushortData = new Uint16Array(buffer);
126                 bufferedLogToConsole('gl.INVALID_OPERATION is generated if the combination of format and type is unsupported.');
127                 gl.readPixels(0, 0, 1, 1, gl.RGBA, gl.UNSIGNED_SHORT_4_4_4_4, ushortData);
128                 this.expectError(gl.INVALID_OPERATION);
130                 bufferedLogToConsole('gl.INVALID_OPERATION is generated if the ArrayBuffer type does not match the type parameter.');
131                 gl.readPixels(0, 0, 1, 1, gl.RGBA, gl.UNSIGNED_BYTE, ushortData);
132                 this.expectError(gl.INVALID_OPERATION);
134                 bufferedLogToConsole('gl.INVALID_VALUE is generated if either width or height is negative.');
135                 gl.readPixels(0, 0, -1, 1, gl.RGBA, gl.UNSIGNED_BYTE, ubyteData);
136                 this.expectError(gl.INVALID_VALUE);
137                 gl.readPixels(0, 0, 1, -1, gl.RGBA, gl.UNSIGNED_BYTE, ubyteData);
138                 this.expectError(gl.INVALID_VALUE);
139                 gl.readPixels(0, 0, -1, -1, gl.RGBA, gl.UNSIGNED_BYTE, ubyteData);
140                 this.expectError(gl.INVALID_VALUE);
142                 bufferedLogToConsole('gl.INVALID_FRAMEBUFFER_OPERATION is generated if the currently bound framebuffer is not framebuffer complete.');
143                 var fbo = gl.createFramebuffer();
144                 gl.bindFramebuffer(gl.FRAMEBUFFER, fbo);
145                 gl.checkFramebufferStatus(gl.FRAMEBUFFER);
146                 gl.readPixels(0, 0, 1, 1, gl.RGBA, gl.UNSIGNED_BYTE, ubyteData);
147                 this.expectError(gl.INVALID_FRAMEBUFFER_OPERATION);
148                 gl.bindFramebuffer(gl.FRAMEBUFFER, null);
149                 gl.deleteFramebuffer(fbo);
150             }
151         ));
153         testGroup.addChild(new es3fApiCase.ApiCaseCallback(
154             'read_pixels_format_mismatch', 'Invalid glReadPixels() usage', gl,
155             function() {
156                 var buffer = new ArrayBuffer(8);
157                 var ubyteData = new Uint8Array(buffer);
158                 var ushortData = new Uint16Array(buffer);
160                 bufferedLogToConsole('Unsupported combinations of format and type will generate a gl.INVALID_OPERATION error.');
161                 gl.readPixels(0, 0, 1, 1, gl.RGBA, gl.UNSIGNED_SHORT_5_6_5, ushortData);
162                 this.expectError(gl.INVALID_OPERATION);
163                 gl.readPixels(0, 0, 1, 1, gl.ALPHA, gl.UNSIGNED_SHORT_5_6_5, ushortData);
164                 this.expectError(gl.INVALID_OPERATION);
165                 gl.readPixels(0, 0, 1, 1, gl.RGB, gl.UNSIGNED_SHORT_4_4_4_4, ushortData);
166                 this.expectError(gl.INVALID_OPERATION);
167                 gl.readPixels(0, 0, 1, 1, gl.ALPHA, gl.UNSIGNED_SHORT_4_4_4_4, ushortData);
168                 this.expectError(gl.INVALID_OPERATION);
169                 gl.readPixels(0, 0, 1, 1, gl.RGB, gl.UNSIGNED_SHORT_5_5_5_1, ushortData);
170                 this.expectError(gl.INVALID_OPERATION);
171                 gl.readPixels(0, 0, 1, 1, gl.ALPHA, gl.UNSIGNED_SHORT_5_5_5_1, ushortData);
172                 this.expectError(gl.INVALID_OPERATION);
174                 bufferedLogToConsole('gl.RGBA/gl.UNSIGNED_BYTE is always accepted and the other acceptable pair can be discovered by querying gl.IMPLEMENTATION_COLOR_READ_FORMAT and gl.IMPLEMENTATION_COLOR_READ_TYPE.');
175                 gl.readPixels(0, 0, 1, 1, gl.RGBA, gl.UNSIGNED_BYTE, ubyteData);
176                 this.expectError(gl.NO_ERROR);
177                 var readFormat = /** @type {number} */ (gl.getParameter(gl.IMPLEMENTATION_COLOR_READ_FORMAT));
178                 var readType = /** @type {number} */ (gl.getParameter(gl.IMPLEMENTATION_COLOR_READ_TYPE));
179                 gl.readPixels(0, 0, 1, 1, readFormat, readType, ubyteData);
180                 this.expectError(gl.NO_ERROR);
181             }
182         ));
184         testGroup.addChild(new es3fApiCase.ApiCaseCallback(
185             'read_pixels_fbo_format_mismatch', 'Invalid gl.readPixels() usage', gl,
186             function() {
187                 var ubyteData = new Uint8Array(4);
188                 var floatData = new Float32Array(4);
190                 var texture = gl.createTexture();
191                 gl.bindTexture(gl.TEXTURE_2D, texture);
192                 gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, 32, 32, 0, gl.RGBA, gl.UNSIGNED_BYTE, null);
194                 var fbo = gl.createFramebuffer();
195                 gl.bindFramebuffer(gl.FRAMEBUFFER, fbo);
196                 gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, texture, 0);
197                 this.expectError(gl.NO_ERROR);
199                 bufferedLogToConsole('gl.INVALID_OPERATION is generated if currently bound framebuffer format is incompatible with format and type.');
201                 gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, 32, 32, 0, gl.RGBA, gl.UNSIGNED_BYTE, null);
202                 gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, texture, 0);
203                 gl.checkFramebufferStatus(gl.FRAMEBUFFER);
204                 this.expectError(gl.NO_ERROR);
205                 gl.readPixels(0, 0, 1, 1, gl.RGBA, gl.FLOAT, floatData);
206                 this.expectError(gl.INVALID_OPERATION);
208                 gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA32I, 32, 32, 0, gl.RGBA_INTEGER, gl.INT, null);
209                 gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, texture, 0);
210                 gl.checkFramebufferStatus(gl.FRAMEBUFFER);
211                 this.expectError(gl.NO_ERROR);
212                 gl.readPixels(0, 0, 1, 1, gl.RGBA, gl.FLOAT, floatData);
213                 this.expectError(gl.INVALID_OPERATION);
215                 gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA32UI, 32, 32, 0, gl.RGBA_INTEGER, gl.UNSIGNED_INT, null);
216                 gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, texture, 0);
217                 gl.checkFramebufferStatus(gl.FRAMEBUFFER);
218                 this.expectError(gl.NO_ERROR);
219                 gl.readPixels(0, 0, 1, 1, gl.RGBA, gl.FLOAT, floatData);
220                 this.expectError(gl.INVALID_OPERATION);
222                 bufferedLogToConsole('gl.INVALID_OPERATION is generated if gl.READ_FRAMEBUFFER_BINDING is non-zero, the read framebuffer is complete, and the value of gl.SAMPLE_BUFFERS for the read framebuffer is greater than zero.');
224                 var rbo = gl.createRenderbuffer();
225                 gl.bindRenderbuffer(gl.RENDERBUFFER, rbo);
226                 gl.renderbufferStorageMultisample(gl.RENDERBUFFER, 4, gl.RGBA8, 32, 32);
227                 gl.framebufferRenderbuffer(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.RENDERBUFFER, rbo);
229                 var binding = /** @type {WebGLFramebuffer} */ (gl.getParameter(gl.READ_FRAMEBUFFER_BINDING));
230                 bufferedLogToConsole('gl.READ_FRAMEBUFFER_BINDING: ' + binding);
231                 gl.checkFramebufferStatus(gl.FRAMEBUFFER);
232                 var sampleBuffers = /** @type {number} */ (gl.getParameter(gl.SAMPLE_BUFFERS));
233                 bufferedLogToConsole('gl.SAMPLE_BUFFERS: ' + sampleBuffers);
234                 this.expectError(gl.NO_ERROR);
236                 if (binding == null || sampleBuffers <= 0) {
237                     this.testFailed('expected gl.READ_FRAMEBUFFER_BINDING to be non-zero and gl.SAMPLE_BUFFERS to be greater than zero');
238                 } else {
239                     gl.readPixels(0, 0, 1, 1, gl.RGBA, gl.UNSIGNED_BYTE, ubyteData);
240                     this.expectError(gl.INVALID_OPERATION);
241                 }
243                 gl.bindRenderbuffer(gl.RENDERBUFFER, null);
244                 gl.deleteRenderbuffer(rbo);
245                 gl.bindFramebuffer(gl.FRAMEBUFFER, null);
246                 gl.deleteFramebuffer(fbo);
247                 gl.bindTexture(gl.TEXTURE_2D, null);
248                 gl.deleteTexture(texture);
249             }
250         ));
252         testGroup.addChild(new es3fApiCase.ApiCaseCallback(
253             'bind_buffer_range', 'Invalid glBindBufferRange() usage', gl,
254             function() {
255                 var bufEmpty = new ArrayBuffer(16);
257                 var bufUniform = gl.createBuffer();
258                 gl.bindBuffer(gl.UNIFORM_BUFFER, bufUniform);
259                 gl.bufferData(gl.UNIFORM_BUFFER, bufEmpty, gl.STREAM_DRAW);
261                 var bufTF = gl.createBuffer();
262                 gl.bindBuffer(gl.TRANSFORM_FEEDBACK_BUFFER, bufTF);
263                 gl.bufferData(gl.TRANSFORM_FEEDBACK_BUFFER, bufEmpty, gl.STREAM_DRAW);
265                 bufferedLogToConsole('gl.INVALID_ENUM is generated if target is not gl.TRANSFORM_FEEDBACK_BUFFER or gl.UNIFORM_BUFFER.');
266                 gl.bindBufferRange(gl.ARRAY_BUFFER, 0, bufUniform, 0, 4);
267                 this.expectError(gl.INVALID_ENUM);
269                 bufferedLogToConsole('gl.INVALID_VALUE is generated if target is gl.TRANSFORM_FEEDBACK_BUFFER and index is greater than or equal to gl.MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS.');
270                 var maxTFSize = /** @type {number} */ (gl.getParameter(gl.MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS));
271                 gl.bindBufferRange(gl.TRANSFORM_FEEDBACK_BUFFER, maxTFSize, bufTF, 0, 4);
272                 this.expectError(gl.INVALID_VALUE);
274                 bufferedLogToConsole('gl.INVALID_VALUE is generated if target is gl.UNIFORM_BUFFER and index is greater than or equal to gl.MAX_UNIFORM_BUFFER_BINDINGS.');
275                 var maxUSize = /** @type {number} */ (gl.getParameter(gl.MAX_UNIFORM_BUFFER_BINDINGS));
276                 gl.bindBufferRange(gl.UNIFORM_BUFFER, maxUSize, bufUniform, 0, 4);
277                 this.expectError(gl.INVALID_VALUE);
279                 bufferedLogToConsole('gl.INVALID_VALUE is generated if size is less than or equal to zero.');
280                 gl.bindBufferRange(gl.UNIFORM_BUFFER, 0, bufUniform, 0, -1);
281                 this.expectError(gl.INVALID_VALUE);
282                 gl.bindBufferRange(gl.UNIFORM_BUFFER, 0, bufUniform, 0, 0);
283                 this.expectError(gl.INVALID_VALUE);
285                 bufferedLogToConsole('gl.INVALID_VALUE is generated if target is gl.TRANSFORM_FEEDBACK_BUFFER and size or offset are not multiples of 4.');
286                 gl.bindBufferRange(gl.TRANSFORM_FEEDBACK_BUFFER, 0, bufTF, 4, 5);
287                 this.expectError(gl.INVALID_VALUE);
288                 gl.bindBufferRange(gl.TRANSFORM_FEEDBACK_BUFFER, 0, bufTF, 5, 4);
289                 this.expectError(gl.INVALID_VALUE);
290                 gl.bindBufferRange(gl.TRANSFORM_FEEDBACK_BUFFER, 0, bufTF, 5, 7);
291                 this.expectError(gl.INVALID_VALUE);
293                 bufferedLogToConsole('gl.INVALID_VALUE is generated if target is gl.UNIFORM_BUFFER and offset is not a multiple of gl.UNIFORM_BUFFER_OFFSET_ALIGNMENT.');
294                 var alignment = /** @type {number} */ (gl.getParameter(gl.UNIFORM_BUFFER_OFFSET_ALIGNMENT));
295                 gl.bindBufferRange(gl.UNIFORM_BUFFER, 0, bufUniform, alignment + 1, 4);
296                 this.expectError(gl.INVALID_VALUE);
298                 gl.deleteBuffer(bufUniform);
299                 gl.deleteBuffer(bufTF);
300             }
301         ));
303         testGroup.addChild(new es3fApiCase.ApiCaseCallback(
304             'bind_buffer_base', 'Invalid glBindBufferBase() usage', gl,
305             function() {
306                 var bufEmpty = new ArrayBuffer(16);
308                 var bufUniform = gl.createBuffer();
309                 gl.bindBuffer(gl.UNIFORM_BUFFER, bufUniform);
310                 gl.bufferData(gl.UNIFORM_BUFFER, bufEmpty, gl.STREAM_DRAW);
312                 var bufTF = gl.createBuffer();
313                 gl.bindBuffer(gl.TRANSFORM_FEEDBACK_BUFFER, bufTF);
314                 gl.bufferData(gl.TRANSFORM_FEEDBACK_BUFFER, bufEmpty, gl.STREAM_DRAW);
316                 bufferedLogToConsole('gl.INVALID_ENUM is generated if target is not gl.TRANSFORM_FEEDBACK_BUFFER or gl.UNIFORM_BUFFER.');
317                 gl.bindBufferBase(-1, 0, bufUniform);
318                 this.expectError(gl.INVALID_ENUM);
319                 gl.bindBufferBase(gl.ARRAY_BUFFER, 0, bufUniform);
320                 this.expectError(gl.INVALID_ENUM);
322                 bufferedLogToConsole('gl.INVALID_VALUE is generated if target is gl.UNIFORM_BUFFER and index is greater than or equal to gl.MAX_UNIFORM_BUFFER_BINDINGS.');
323                 var maxUSize = /** @type {number} */ (gl.getParameter(gl.MAX_UNIFORM_BUFFER_BINDINGS));
324                 gl.bindBufferBase(gl.UNIFORM_BUFFER, maxUSize, bufUniform);
325                 this.expectError(gl.INVALID_VALUE);
327                 bufferedLogToConsole('gl.INVALID_VALUE is generated if target is gl.TRANSFORM_FEEDBACK_BUFFER andindex is greater than or equal to gl.MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS.');
328                 var maxTFSize = /** @type {number} */ (gl.getParameter(gl.MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS));
329                 gl.bindBufferBase(gl.TRANSFORM_FEEDBACK_BUFFER, maxTFSize, bufTF);
330                 this.expectError(gl.INVALID_VALUE);
332                 gl.deleteBuffer(bufUniform);
333                 gl.deleteBuffer(bufTF);
334             }
335         ));
337         testGroup.addChild(new es3fApiCase.ApiCaseCallback(
338             'clear_bufferiv', 'Invalid gl.clearBufferiv() usage', gl,
339             function() {
340                 var data = new Int32Array(32 * 32);
342                 var texture = gl.createTexture();
343                 gl.bindTexture(gl.TEXTURE_2D, texture);
344                 gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA32I, 32, 32, 0, gl.RGBA_INTEGER, gl.INT, null);
346                 var fbo = gl.createFramebuffer();
347                 gl.bindFramebuffer(gl.FRAMEBUFFER, fbo);
348                 gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, texture, 0);
349                 gl.checkFramebufferStatus(gl.FRAMEBUFFER);
350                 this.expectError(gl.NO_ERROR);
352                 bufferedLogToConsole('gl.INVALID_ENUM is generated if buffer is not an accepted value.');
353                 gl.clearBufferiv(-1, 0, data);
354                 this.expectError(gl.INVALID_ENUM);
355                 gl.clearBufferiv(gl.FRAMEBUFFER, 0, data);
356                 this.expectError(gl.INVALID_ENUM);
358                 bufferedLogToConsole('gl.INVALID_VALUE is generated if buffer is gl.COLOR, gl.FRONT, gl.BACK, gl.LEFT, gl.RIGHT, or gl.FRONT_AND_BACK and drawBuffer is greater than or equal to gl.MAX_DRAW_BUFFERS.');
359                 var maxDrawBuffers = /** @type {number} */ (gl.getParameter(gl.MAX_DRAW_BUFFERS));
360                 gl.clearBufferiv(gl.COLOR, maxDrawBuffers, data);
361                 this.expectError(gl.INVALID_VALUE);
363                 bufferedLogToConsole('gl.INVALID_ENUM is generated if buffer is gl.DEPTH or gl.DEPTH_STENCIL.');
364                 gl.clearBufferiv(gl.DEPTH, 1, data);
365                 this.expectError(gl.INVALID_ENUM);
366                 gl.clearBufferiv(gl.DEPTH_STENCIL, 1, data);
367                 this.expectError(gl.INVALID_ENUM);
369                 bufferedLogToConsole('gl.INVALID_VALUE is generated if buffer is gl.STENCIL and drawBuffer is not zero.');
370                 gl.clearBufferiv(gl.STENCIL, 1, data);
371                 this.expectError(gl.INVALID_VALUE);
373                 gl.deleteFramebuffer(fbo);
374                 gl.deleteTexture(texture);
375             }
376         ));
378         testGroup.addChild(new es3fApiCase.ApiCaseCallback(
379             'clear_bufferuiv', 'Invalid gl.clearBufferuiv() usage', gl,
380             function() {
381                 var data = new Uint32Array(32 * 32);
383                 var texture = gl.createTexture();
384                 gl.bindTexture(gl.TEXTURE_2D, texture);
385                 gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA32UI, 32, 32, 0, gl.RGBA_INTEGER, gl.UNSIGNED_INT, null);
387                 var fbo = gl.createFramebuffer();
388                 gl.bindFramebuffer(gl.FRAMEBUFFER, fbo);
389                 gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, texture, 0);
390                 gl.checkFramebufferStatus(gl.FRAMEBUFFER);
391                 this.expectError(gl.NO_ERROR);
393                 bufferedLogToConsole('gl.INVALID_ENUM is generated if buffer is not an accepted value.');
394                 gl.clearBufferuiv(-1, 0, data);
395                 this.expectError(gl.INVALID_ENUM);
396                 gl.clearBufferuiv(gl.FRAMEBUFFER, 0, data);
397                 this.expectError(gl.INVALID_ENUM);
399                 bufferedLogToConsole('gl.INVALID_VALUE is generated if buffer is gl.COLOR, gl.FRONT, gl.BACK, gl.LEFT, gl.RIGHT, or gl.FRONT_AND_BACK and drawBuffer is greater than or equal to gl.MAX_DRAW_BUFFERS.');
400                 var maxDrawBuffers = /** @type {number} */ (gl.getParameter(gl.MAX_DRAW_BUFFERS));
401                 gl.clearBufferuiv(gl.COLOR, maxDrawBuffers, data);
402                 this.expectError(gl.INVALID_VALUE);
404                 bufferedLogToConsole('gl.INVALID_ENUM is generated if buffer is gl.DEPTH, gl.STENCIL or gl.DEPTH_STENCIL.');
405                 gl.clearBufferuiv(gl.DEPTH, 1, data);
406                 this.expectError(gl.INVALID_ENUM);
407                 gl.clearBufferuiv(gl.STENCIL, 1, data);
408                 this.expectError(gl.INVALID_ENUM);
409                 gl.clearBufferuiv(gl.DEPTH_STENCIL, 1, data);
410                 this.expectError(gl.INVALID_ENUM);
412                 gl.deleteFramebuffer(fbo);
413                 gl.deleteTexture(texture);
414             }
415         ));
417         testGroup.addChild(new es3fApiCase.ApiCaseCallback(
418             'clear_bufferfv', 'Invalid gl.clearBufferfv() usage', gl,
419             function() {
420                 var data = new Float32Array(32 * 32);
422                 var texture = gl.createTexture();
423                 // Float type texture isn't color-renderable without EXT_color_buffer_float extension.
424                 if (gl.getExtension('EXT_color_buffer_float')) {
425                     gl.bindTexture(gl.TEXTURE_2D, texture);
426                     gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA32F, 32, 32, 0, gl.RGBA, gl.FLOAT, null);
428                     var fbo = gl.createFramebuffer();
429                     gl.bindFramebuffer(gl.FRAMEBUFFER, fbo);
430                     gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, texture, 0);
431                     gl.checkFramebufferStatus(gl.FRAMEBUFFER);
432                     this.expectError(gl.NO_ERROR);
434                     bufferedLogToConsole('gl.INVALID_ENUM is generated if buffer is not an accepted value.');
435                     gl.clearBufferfv(-1, 0, data);
436                     this.expectError(gl.INVALID_ENUM);
437                     gl.clearBufferfv(gl.FRAMEBUFFER, 0, data);
438                     this.expectError(gl.INVALID_ENUM);
440                     bufferedLogToConsole('gl.INVALID_VALUE is generated if buffer is gl.COLOR, gl.FRONT, gl.BACK, gl.LEFT, gl.RIGHT, or gl.FRONT_AND_BACK and drawBuffer is greater than or equal to gl.MAX_DRAW_BUFFERS.');
441                     var maxDrawBuffers = /** @type {number} */ (gl.getParameter(gl.MAX_DRAW_BUFFERS));
442                     gl.clearBufferfv(gl.COLOR, maxDrawBuffers, data);
443                     this.expectError(gl.INVALID_VALUE);
445                     bufferedLogToConsole('gl.INVALID_ENUM is generated if buffer is gl.STENCIL or gl.DEPTH_STENCIL.');
446                     gl.clearBufferfv(gl.STENCIL, 1, data);
447                     this.expectError(gl.INVALID_ENUM);
448                     gl.clearBufferfv(gl.DEPTH_STENCIL, 1, data);
449                     this.expectError(gl.INVALID_ENUM);
451                     bufferedLogToConsole('gl.INVALID_VALUE is generated if buffer is gl.DEPTH and drawBuffer is not zero.');
452                     gl.clearBufferfv(gl.DEPTH, 1, data);
453                     this.expectError(gl.INVALID_VALUE);
454                 }
456                 gl.deleteFramebuffer(fbo);
457                 gl.deleteTexture(texture);
458             }
459         ));
461         testGroup.addChild(new es3fApiCase.ApiCaseCallback(
462             'clear_bufferfi', 'Invalid gl.clearBufferfi() usage', gl,
463             function() {
464                 bufferedLogToConsole('gl.INVALID_ENUM is generated if buffer is not an accepted value.');
465                 gl.clearBufferfi(-1, 0, 1.0, 1);
466                 this.expectError(gl.INVALID_ENUM);
467                 gl.clearBufferfi(gl.FRAMEBUFFER, 0, 1.0, 1);
468                 this.expectError(gl.INVALID_ENUM);
470                 bufferedLogToConsole('gl.INVALID_ENUM is generated if buffer is not gl.DEPTH_STENCIL.');
471                 gl.clearBufferfi(gl.DEPTH, 0, 1.0, 1);
472                 this.expectError(gl.INVALID_ENUM);
473                 gl.clearBufferfi(gl.STENCIL, 0, 1.0, 1);
474                 this.expectError(gl.INVALID_ENUM);
475                 gl.clearBufferfi(gl.COLOR, 0, 1.0, 1);
476                 this.expectError(gl.INVALID_ENUM);
478                 bufferedLogToConsole('gl.INVALID_VALUE is generated if buffer is gl.DEPTH_STENCIL and drawBuffer is not zero.');
479                 gl.clearBufferfi(gl.DEPTH_STENCIL, 1, 1.0, 1);
480                 this.expectError(gl.INVALID_VALUE);
482             }
483         ));
485         testGroup.addChild(new es3fApiCase.ApiCaseCallback(
486             'copy_buffer_sub_data', 'Invalid gl.copyBufferSubData() usage', gl,
487             function() {
488                 var buf = {
489                     r: gl.createBuffer(),
490                     w: gl.createBuffer()
491                 };
493                 gl.bindBuffer(gl.COPY_READ_BUFFER, buf.r);
494                 gl.bufferData(gl.COPY_READ_BUFFER, 32, gl.DYNAMIC_COPY);
495                 gl.bindBuffer(gl.COPY_WRITE_BUFFER, buf.w);
496                 gl.bufferData(gl.COPY_WRITE_BUFFER, 32, gl.DYNAMIC_COPY);
497                 this.expectError(gl.NO_ERROR);
499                 bufferedLogToConsole('gl.INVALID_VALUE is generated if any of readoffset, writeoffset or size is negative.');
500                 gl.copyBufferSubData(gl.COPY_READ_BUFFER, gl.COPY_WRITE_BUFFER, 0, 0, -4);
501                 this.expectError(gl.INVALID_VALUE);
502                 gl.copyBufferSubData(gl.COPY_READ_BUFFER, gl.COPY_WRITE_BUFFER, -1, 0, 4);
503                 this.expectError(gl.INVALID_VALUE);
504                 gl.copyBufferSubData(gl.COPY_READ_BUFFER, gl.COPY_WRITE_BUFFER, 0, -1, 4);
505                 this.expectError(gl.INVALID_VALUE);
507                 bufferedLogToConsole('gl.INVALID_VALUE is generated if readoffset + size exceeds the size of the buffer object bound to readtarget.');
508                 gl.copyBufferSubData(gl.COPY_READ_BUFFER, gl.COPY_WRITE_BUFFER, 0, 0, 36);
509                 this.expectError(gl.INVALID_VALUE);
510                 gl.copyBufferSubData(gl.COPY_READ_BUFFER, gl.COPY_WRITE_BUFFER, 24, 0, 16);
511                 this.expectError(gl.INVALID_VALUE);
512                 gl.copyBufferSubData(gl.COPY_READ_BUFFER, gl.COPY_WRITE_BUFFER, 36, 0, 4);
513                 this.expectError(gl.INVALID_VALUE);
515                 bufferedLogToConsole('gl.INVALID_VALUE is generated if writeoffset + size exceeds the size of the buffer object bound to writetarget.');
516                 gl.copyBufferSubData(gl.COPY_READ_BUFFER, gl.COPY_WRITE_BUFFER, 0, 0, 36);
517                 this.expectError(gl.INVALID_VALUE);
518                 gl.copyBufferSubData(gl.COPY_READ_BUFFER, gl.COPY_WRITE_BUFFER, 0, 24, 16);
519                 this.expectError(gl.INVALID_VALUE);
520                 gl.copyBufferSubData(gl.COPY_READ_BUFFER, gl.COPY_WRITE_BUFFER, 0, 36, 4);
521                 this.expectError(gl.INVALID_VALUE);
523                 bufferedLogToConsole('gl.INVALID_VALUE is generated if the same buffer object is bound to both readtarget and writetarget and the ranges [readoffset, readoffset + size) and [writeoffset, writeoffset + size) overlap.');
524                 gl.bindBuffer(gl.COPY_WRITE_BUFFER, buf.r);
525                 gl.copyBufferSubData(gl.COPY_READ_BUFFER, gl.COPY_WRITE_BUFFER, 0, 16, 4);
526                 this.expectError(gl.NO_ERROR);
527                 gl.copyBufferSubData(gl.COPY_READ_BUFFER, gl.COPY_WRITE_BUFFER, 0, 0, 4);
528                 this.expectError(gl.INVALID_VALUE);
529                 gl.copyBufferSubData(gl.COPY_READ_BUFFER, gl.COPY_WRITE_BUFFER, 0, 16, 18);
530                 this.expectError(gl.INVALID_VALUE);
531                 gl.bindBuffer(gl.COPY_WRITE_BUFFER, buf.w);
533                 bufferedLogToConsole('gl.INVALID_OPERATION is generated if null is bound to readtarget or writetarget.');
534                 gl.bindBuffer(gl.COPY_READ_BUFFER, null);
535                 gl.copyBufferSubData(gl.COPY_READ_BUFFER, gl.COPY_WRITE_BUFFER, 0, 0, 16);
536                 this.expectError(gl.INVALID_OPERATION);
537                 gl.bindBuffer(gl.COPY_READ_BUFFER, buf.r);
539                 gl.bindBuffer(gl.COPY_WRITE_BUFFER, null);
540                 gl.copyBufferSubData(gl.COPY_READ_BUFFER, gl.COPY_WRITE_BUFFER, 0, 0, 16);
541                 this.expectError(gl.INVALID_OPERATION);
542                 gl.bindBuffer(gl.COPY_WRITE_BUFFER, buf.w);
544                 gl.deleteBuffer(buf.w);
545                 gl.deleteBuffer(buf.r);
546             }
547         ));
549         testGroup.addChild(new es3fApiCase.ApiCaseCallback(
550             'draw_buffers', 'Invalid glDrawBuffers() usage', gl,
551             function() {
552                 var maxDrawBuffers = /** @type {number} */ (gl.getParameter(gl.MAX_DRAW_BUFFERS));
553                 var values = [
554                     gl.NONE,
555                     gl.BACK,
556                     gl.COLOR_ATTACHMENT0,
557                     gl.DEPTH_ATTACHMENT
558                 ];
560                 var texture = gl.createTexture();
561                 gl.bindTexture(gl.TEXTURE_2D, texture);
562                 gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA8, 32, 32, 0, gl.RGBA, gl.UNSIGNED_BYTE, null);
564                 var fbo = gl.createFramebuffer();
565                 gl.bindFramebuffer(gl.FRAMEBUFFER, fbo);
566                 gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, texture, 0);
567                 gl.checkFramebufferStatus(gl.FRAMEBUFFER);
568                 this.expectError(gl.NO_ERROR);
570                 bufferedLogToConsole('gl.INVALID_ENUM is generated if one of the values in bufs is not an accepted value.');
571                 gl.drawBuffers(values.slice(2, 4));
572                 this.expectError(gl.INVALID_ENUM);
574                 bufferedLogToConsole('gl.INVALID_OPERATION is generated if the GL is bound to the default framebuffer and the number of queried buffers is not 1.');
575                 gl.bindFramebuffer(gl.FRAMEBUFFER, null);
576                 gl.drawBuffers(values.slice(0, 2));
577                 this.expectError(gl.INVALID_OPERATION);
579                 bufferedLogToConsole('gl.INVALID_OPERATION is generated if the GL is bound to the default framebuffer and the value in bufs is one of the gl.COLOR_ATTACHMENTn tokens.');
580                 gl.bindFramebuffer(gl.FRAMEBUFFER, null);
581                 gl.drawBuffers(values.slice(2, 3));
582                 this.expectError(gl.INVALID_OPERATION);
584                 bufferedLogToConsole('gl.INVALID_OPERATION is generated if the GL is bound to a framebuffer object and the ith buffer listed in bufs is anything other than gl.NONE or gl.COLOR_ATTACHMENTSi.');
585                 gl.bindFramebuffer(gl.FRAMEBUFFER, fbo);
586                 gl.drawBuffers(values.slice(1, 2));
587                 this.expectError(gl.INVALID_OPERATION);
589                 gl.deleteTexture(texture);
590                 gl.deleteFramebuffer(fbo);
591             }
592         ));
594         // Framebuffer Objects
596         testGroup.addChild(new es3fApiCase.ApiCaseCallback(
597             'bind_framebuffer', 'Invalid glBindFramebuffer() usage', gl,
598             function() {
599                 bufferedLogToConsole('gl.INVALID_ENUM is generated if target is not gl.FRAMEBUFFER.');
600                 gl.bindFramebuffer(-1, null);
601                 this.expectError(gl.INVALID_ENUM);
602                 gl.bindFramebuffer(gl.RENDERBUFFER, null);
603                 this.expectError(gl.INVALID_ENUM);
604             }
605         ));
607         testGroup.addChild(new es3fApiCase.ApiCaseCallback(
608             'bind_renderbuffer', 'Invalid glBindRenderbuffer() usage', gl,
609             function() {
610                 bufferedLogToConsole('glINVALID_ENUM is generated if target is not gl.RENDERBUFFER.');
611                 gl.bindRenderbuffer(-1, null);
612                 this.expectError(gl.INVALID_ENUM);
613                 gl.bindRenderbuffer(gl.FRAMEBUFFER, null);
614                 this.expectError(gl.INVALID_ENUM);
615             }
616         ));
618         testGroup.addChild(new es3fApiCase.ApiCaseCallback(
619             'check_framebuffer_status', 'Invalid glCheckFramebufferStatus() usage', gl,
620             function() {
621                 bufferedLogToConsole('gl.INVALID_ENUM is generated if target is not gl.FRAMEBUFFER.');
622                     gl.checkFramebufferStatus(-1);
623                     this.expectError(gl.INVALID_ENUM);
624                     gl.checkFramebufferStatus(gl.RENDERBUFFER);
625                     this.expectError(gl.INVALID_ENUM);
626             }
627         ));
629         testGroup.addChild(new es3fApiCase.ApiCaseCallback(
630             'framebuffer_renderbuffer', 'Invalid glFramebufferRenderbuffer() usage', gl,
631             function() {
632                 var rbo = gl.createRenderbuffer();
633                 var fbo = gl.createFramebuffer();
634                 gl.bindFramebuffer(gl.FRAMEBUFFER, fbo);
636                 bufferedLogToConsole('gl.INVALID_ENUM is generated if target is not one of the accepted tokens.');
637                 gl.framebufferRenderbuffer(-1, gl.COLOR_ATTACHMENT0, gl.RENDERBUFFER, null);
638                 this.expectError(gl.INVALID_ENUM);
640                 bufferedLogToConsole('gl.INVALID_ENUM is generated if renderbuffertarget is not gl.RENDERBUFFER.');
641                 gl.bindRenderbuffer(gl.RENDERBUFFER, rbo);
642                 gl.framebufferRenderbuffer(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, -1, rbo);
643                 this.expectError(gl.INVALID_ENUM);
644                 gl.bindRenderbuffer(gl.RENDERBUFFER, null);
646                 bufferedLogToConsole('gl.INVALID_OPERATION is generated if zero is bound to target.');
647                 gl.bindFramebuffer(gl.FRAMEBUFFER, null);
648                 gl.framebufferRenderbuffer(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.RENDERBUFFER, null);
649                 this.expectError(gl.INVALID_OPERATION);
651                 gl.deleteRenderbuffer(rbo);
652                 gl.deleteFramebuffer(fbo);
653             }
654         ));
656         testGroup.addChild(new es3fApiCase.ApiCaseCallback(
657             'framebuffer_texture2d', 'Invalid glFramebufferTexture2D() usage', gl,
658             function() {
660                 var fbo = gl.createFramebuffer();
661                 var tex2D = gl.createTexture();
662                 var texCube = gl.createTexture();
663                 gl.bindFramebuffer(gl.FRAMEBUFFER, fbo);
664                 gl.bindTexture(gl.TEXTURE_2D, tex2D);
665                 gl.bindTexture(gl.TEXTURE_CUBE_MAP, texCube);
666                 this.expectError(gl.NO_ERROR);
668                 bufferedLogToConsole('gl.INVALID_ENUM is generated if target is not one of the accepted tokens.');
669                 gl.framebufferTexture2D(-1, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, null, 0);
670                 this.expectError(gl.INVALID_ENUM);
672                 bufferedLogToConsole('gl.INVALID_ENUM is generated if textarget is not an accepted texture target.');
673                 gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, -1, tex2D, 0);
674                 this.expectError(gl.INVALID_ENUM);
676                 bufferedLogToConsole('gl.INVALID_VALUE is generated if level is less than 0 or larger than log_2 of maximum texture size.');
677                 var maxTexSize = /** @type {number} */ (gl.getParameter(gl.MAX_TEXTURE_SIZE));
678                 var maxCubeTexSize = /** @type {number} */ (gl.getParameter(gl.MAX_CUBE_MAP_TEXTURE_SIZE));
679                 var maxSizePlane = Math.floor(Math.log2(maxTexSize)) + 1;
680                 var maxSizeCube = Math.floor(Math.log2(maxCubeTexSize)) + 1;
681                 gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, tex2D, -1);
682                 this.expectError(gl.INVALID_VALUE);
683                 gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, tex2D, maxSizePlane);
684                 this.expectError(gl.INVALID_VALUE);
685                 gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_CUBE_MAP_POSITIVE_X, texCube, maxSizeCube);
686                 this.expectError(gl.INVALID_VALUE);
688                 bufferedLogToConsole('gl.INVALID_OPERATION is generated if textarget and texture are not compatible.');
689                 gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_CUBE_MAP_POSITIVE_X, tex2D, 0);
690                 this.expectError(gl.INVALID_OPERATION);
691                 gl.deleteTexture(tex2D);
693                 gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, texCube, 0);
694                 this.expectError(gl.INVALID_OPERATION);
695                 gl.deleteTexture(texCube);
697                 bufferedLogToConsole('gl.INVALID_OPERATION is generated if zero is bound to target.');
698                 gl.bindFramebuffer(gl.FRAMEBUFFER, null);
699                 gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, null, 0);
700                 this.expectError(gl.INVALID_OPERATION);
702                 gl.deleteFramebuffer(fbo);
703             }
704         ));
706         testGroup.addChild(new es3fApiCase.ApiCaseCallback(
707             'renderbuffer_storage', 'Invalid glRenderbufferStorage() usage', gl,
708             function() {
709                 var rbo = gl.createRenderbuffer();
710                 gl.bindRenderbuffer(gl.RENDERBUFFER, rbo);
712                 bufferedLogToConsole('gl.INVALID_ENUM is generated if target is not gl.RENDERBUFFER.');
713                 gl.renderbufferStorage(-1, gl.RGBA4, 1, 1);
714                 this.expectError(gl.INVALID_ENUM);
715                 gl.renderbufferStorage(gl.FRAMEBUFFER, gl.RGBA4, 1, 1);
716                 this.expectError(gl.INVALID_ENUM);
718                 bufferedLogToConsole('gl.INVALID_ENUM is generated if internalformat is not a color-renderable, depth-renderable, or stencil-renderable format.');
719                 gl.renderbufferStorage(gl.RENDERBUFFER, -1, 1, 1);
720                 this.expectError(gl.INVALID_ENUM);
722                 // EXT_color_buffer_half_float disables error
723                 if (gl.getExtension('EXT_color_buffer_half_float') === null) {
724                     gl.renderbufferStorage(gl.RENDERBUFFER, gl.RGB16F, 1, 1);
725                     this.expectError(gl.INVALID_ENUM);
726                 }
728                 gl.renderbufferStorage(gl.RENDERBUFFER, gl.RGBA8_SNORM, 1, 1);
729                 this.expectError(gl.INVALID_ENUM);
731                 bufferedLogToConsole('gl.INVALID_VALUE is generated if width or height is less than zero.');
732                 gl.renderbufferStorage(gl.RENDERBUFFER, gl.RGBA4, -1, 1);
733                 this.expectError(gl.INVALID_VALUE);
734                 gl.renderbufferStorage(gl.RENDERBUFFER, gl.RGBA4, 1, -1);
735                 this.expectError(gl.INVALID_VALUE);
736                 gl.renderbufferStorage(gl.RENDERBUFFER, gl.RGBA4, -1, -1);
737                 this.expectError(gl.INVALID_VALUE);
739                 bufferedLogToConsole('gl.INVALID_VALUE is generated if width or height is greater than gl.MAX_RENDERBUFFER_SIZE.');
740                 var maxSize = /** @type {number} */ (gl.getParameter(gl.MAX_RENDERBUFFER_SIZE));
741                 gl.renderbufferStorage(gl.RENDERBUFFER, gl.RGBA4, 1, maxSize + 1);
742                 this.expectError(gl.INVALID_VALUE);
743                 gl.renderbufferStorage(gl.RENDERBUFFER, gl.RGBA4, maxSize + 1, 1);
744                 this.expectError(gl.INVALID_VALUE);
745                 gl.renderbufferStorage(gl.RENDERBUFFER, gl.RGBA4, maxSize + 1, maxSize + 1);
746                 this.expectError(gl.INVALID_VALUE);
747                 gl.deleteRenderbuffer(rbo);
748             }
749         ));
751         testGroup.addChild(new es3fApiCase.ApiCaseCallback(
752             'blit_framebuffer', 'Invalid glBlitFramebuffer() usage', gl,
753             function() {
755                 /** @type {Array<WebGLTexture>} */
756                 var texture = [
757                     gl.createTexture(), gl.createTexture()
758                 ];
759                 gl.bindTexture(gl.TEXTURE_2D, texture[0]);
761                 /** @type {Array<WebGLRenderbuffer>} */
762                 var rbo = [
763                     gl.createRenderbuffer(), gl.createRenderbuffer()
764                 ];
765                 gl.bindRenderbuffer(gl.RENDERBUFFER, rbo[0]);
767                 /** @type {Array<WebGLFramebuffer>} */
768                 var fbo = [
769                     gl.createFramebuffer(), gl.createFramebuffer()
770                 ];
771                 gl.bindFramebuffer(gl.READ_FRAMEBUFFER, fbo[0]);
773                 gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA8, 32, 32, 0, gl.RGBA, gl.UNSIGNED_BYTE, null);
774                 gl.renderbufferStorage(gl.RENDERBUFFER, gl.DEPTH24_STENCIL8, 32, 32);
775                 gl.framebufferTexture2D(gl.READ_FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, texture[0], 0);
776                 gl.framebufferRenderbuffer(gl.READ_FRAMEBUFFER, gl.DEPTH_STENCIL_ATTACHMENT, gl.RENDERBUFFER, rbo[0]);
777                 gl.checkFramebufferStatus(gl.READ_FRAMEBUFFER);
778                 gl.bindTexture(gl.TEXTURE_2D, texture[1]);
779                 gl.bindRenderbuffer(gl.RENDERBUFFER, rbo[1]);
780                 gl.bindFramebuffer(gl.DRAW_FRAMEBUFFER, fbo[1]);
782                 gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA8, 32, 32, 0, gl.RGBA, gl.UNSIGNED_BYTE, null);
783                 gl.renderbufferStorage(gl.RENDERBUFFER, gl.DEPTH24_STENCIL8, 32, 32);
784                 gl.framebufferTexture2D(gl.DRAW_FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, texture[1], 0);
785                 gl.framebufferRenderbuffer(gl.DRAW_FRAMEBUFFER, gl.DEPTH_STENCIL_ATTACHMENT, gl.RENDERBUFFER, rbo[1]);
786                 gl.checkFramebufferStatus(gl.DRAW_FRAMEBUFFER);
787                 this.expectError(gl.NO_ERROR);
789                 bufferedLogToConsole('gl.INVALID_OPERATION is generated if mask contains any of the gl.DEPTH_BUFFER_BIT or gl.STENCIL_BUFFER_BIT and filter is not gl.NEAREST.');
790                 gl.blitFramebuffer(0, 0, 16, 16, 0, 0, 16, 16, gl.COLOR_BUFFER_BIT | gl.STENCIL_BUFFER_BIT, gl.LINEAR);
791                 this.expectError(gl.INVALID_OPERATION);
792                 gl.blitFramebuffer(0, 0, 16, 16, 0, 0, 16, 16, gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT, gl.LINEAR);
793                 this.expectError(gl.INVALID_OPERATION);
794                 gl.blitFramebuffer(0, 0, 16, 16, 0, 0, 16, 16, gl.DEPTH_BUFFER_BIT | gl.STENCIL_BUFFER_BIT, gl.LINEAR);
795                 this.expectError(gl.INVALID_OPERATION);
797                 bufferedLogToConsole('gl.INVALID_OPERATION is generated if mask contains gl.COLOR_BUFFER_BIT and read buffer format is incompatible with draw buffer format.');
798                 gl.bindTexture(gl.TEXTURE_2D, texture[0]);
800                 gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA32UI, 32, 32, 0, gl.RGBA_INTEGER, gl.UNSIGNED_INT, null);
801                 gl.framebufferTexture2D(gl.READ_FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, texture[0], 0);
802                 bufferedLogToConsole('// Read buffer: gl.RGBA32UI, draw buffer: gl.RGBA');
803                 gl.blitFramebuffer(0, 0, 16, 16, 0, 0, 16, 16, gl.COLOR_BUFFER_BIT, gl.NEAREST);
804                 this.expectError(gl.INVALID_OPERATION);
806                 gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA32I, 32, 32, 0, gl.RGBA_INTEGER, gl.INT, null);
807                 gl.framebufferTexture2D(gl.READ_FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, texture[0], 0);
808                 bufferedLogToConsole('// Read buffer: gl.RGBA32I, draw buffer: gl.RGBA');
809                 gl.blitFramebuffer(0, 0, 16, 16, 0, 0, 16, 16, gl.COLOR_BUFFER_BIT, gl.NEAREST);
810                 this.expectError(gl.INVALID_OPERATION);
812                 gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA8, 32, 32, 0, gl.RGBA, gl.UNSIGNED_BYTE, null);
813                 gl.framebufferTexture2D(gl.READ_FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, texture[0], 0);
814                 gl.bindTexture(gl.TEXTURE_2D, texture[1]);
815                 gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA32I, 32, 32, 0, gl.RGBA_INTEGER, gl.INT, null);
816                 gl.framebufferTexture2D(gl.DRAW_FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, texture[1], 0);
817                 bufferedLogToConsole('// Read buffer: gl.RGBA8, draw buffer: gl.RGBA32I');
818                 gl.blitFramebuffer(0, 0, 16, 16, 0, 0, 16, 16, gl.COLOR_BUFFER_BIT, gl.NEAREST);
819                 this.expectError(gl.INVALID_OPERATION);
821                 bufferedLogToConsole('gl.INVALID_OPERATION is generated if filter is gl.LINEAR and the read buffer contains integer data.');
822                 gl.bindTexture(gl.TEXTURE_2D, texture[0]);
823                 gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA32UI, 32, 32, 0, gl.RGBA_INTEGER, gl.UNSIGNED_INT, null);
824                 gl.framebufferTexture2D(gl.READ_FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, texture[0], 0);
825                 gl.bindTexture(gl.TEXTURE_2D, texture[1]);
826                 gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA32UI, 32, 32, 0, gl.RGBA_INTEGER, gl.UNSIGNED_INT, null);
827                 gl.framebufferTexture2D(gl.DRAW_FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, texture[1], 0);
828                 bufferedLogToConsole('// Read buffer: gl.RGBA32UI, filter: gl.LINEAR');
829                 gl.blitFramebuffer(0, 0, 16, 16, 0, 0, 16, 16, gl.COLOR_BUFFER_BIT, gl.LINEAR);
830                 this.expectError(gl.INVALID_OPERATION);
832                 bufferedLogToConsole('gl.INVALID_OPERATION is generated if mask contains gl.DEPTH_BUFFER_BIT or gl.STENCIL_BUFFER_BIT and the source and destination depth and stencil formats do not match.');
833                 gl.bindRenderbuffer(gl.RENDERBUFFER, rbo[0]);
834                 gl.renderbufferStorage(gl.RENDERBUFFER, gl.DEPTH32F_STENCIL8, 32, 32);
835                 gl.framebufferRenderbuffer(gl.READ_FRAMEBUFFER, gl.DEPTH_STENCIL_ATTACHMENT, gl.RENDERBUFFER, rbo[0]);
836                 gl.blitFramebuffer(0, 0, 16, 16, 0, 0, 16, 16, gl.DEPTH_BUFFER_BIT, gl.NEAREST);
837                 this.expectError(gl.INVALID_OPERATION);
838                 gl.blitFramebuffer(0, 0, 16, 16, 0, 0, 16, 16, gl.STENCIL_BUFFER_BIT, gl.NEAREST);
839                 this.expectError(gl.INVALID_OPERATION);
841                 gl.bindFramebuffer(gl.FRAMEBUFFER, null);
842                 gl.deleteFramebuffer(fbo[1]);
843                 gl.deleteFramebuffer(fbo[0]);
844                 gl.deleteTexture(texture[1]);
845                 gl.deleteTexture(texture[0]);
846                 gl.deleteRenderbuffer(rbo[1]);
847                 gl.deleteRenderbuffer(rbo[0]);
848             }
849         ));
851         testGroup.addChild(new es3fApiCase.ApiCaseCallback(
852             'blit_framebuffer_multisample', 'Invalid glBlitFramebuffer() usage', gl,
853             function() {
855                 /** @type {Array<WebGLRenderbuffer>} */
856                 var rbo = [
857                     gl.createRenderbuffer(), gl.createRenderbuffer()
858                 ];
859                 /** @type {Array<WebGLFramebuffer>} */
860                 var fbo = [
861                     gl.createFramebuffer(), gl.createFramebuffer()
862                 ];
864                 gl.bindRenderbuffer(gl.RENDERBUFFER, rbo[0]);
865                 gl.bindFramebuffer(gl.READ_FRAMEBUFFER, fbo[0]);
866                 gl.renderbufferStorageMultisample(gl.RENDERBUFFER, 4, gl.RGBA8, 32, 32);
867                 gl.framebufferRenderbuffer(gl.READ_FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.RENDERBUFFER, rbo[0]);
868                 gl.checkFramebufferStatus(gl.READ_FRAMEBUFFER);
870                 gl.bindRenderbuffer(gl.RENDERBUFFER, rbo[1]);
871                 gl.bindFramebuffer(gl.DRAW_FRAMEBUFFER, fbo[1]);
872                 this.expectError(gl.NO_ERROR);
874                 bufferedLogToConsole('gl.INVALID_OPERATION is generated if the value of gl.SAMPLE_BUFFERS for the draw buffer is greater than zero.');
875                 gl.renderbufferStorageMultisample(gl.RENDERBUFFER, 4, gl.RGBA8, 32, 32);
876                 gl.framebufferRenderbuffer(gl.DRAW_FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.RENDERBUFFER, rbo[1]);
877                 gl.blitFramebuffer(0, 0, 16, 16, 0, 0, 16, 16, gl.COLOR_BUFFER_BIT, gl.NEAREST);
878                 this.expectError(gl.INVALID_OPERATION);
880                 bufferedLogToConsole('gl.INVALID_OPERATION is generated if gl.SAMPLE_BUFFERS for the read buffer is greater than zero and the formats of draw and read buffers are not identical.');
881                 gl.renderbufferStorage(gl.RENDERBUFFER, gl.RGBA4, 32, 32);
882                 gl.framebufferRenderbuffer(gl.DRAW_FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.RENDERBUFFER, rbo[1]);
883                 gl.blitFramebuffer(0, 0, 16, 16, 0, 0, 16, 16, gl.COLOR_BUFFER_BIT, gl.NEAREST);
884                 this.expectError(gl.INVALID_OPERATION);
886                 bufferedLogToConsole('gl.INVALID_OPERATION is generated if gl.SAMPLE_BUFFERS for the read buffer is greater than zero and the source and destination rectangles are not defined with the same (X0, Y0) and (X1, Y1) bounds.');
887                 gl.renderbufferStorage(gl.RENDERBUFFER, gl.RGBA8, 32, 32);
888                 gl.framebufferRenderbuffer(gl.DRAW_FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.RENDERBUFFER, rbo[1]);
889                 gl.blitFramebuffer(0, 0, 16, 16, 2, 2, 18, 18, gl.COLOR_BUFFER_BIT, gl.NEAREST);
890                 this.expectError(gl.INVALID_OPERATION);
892                 gl.bindFramebuffer(gl.FRAMEBUFFER, null);
893                 gl.deleteRenderbuffer(rbo[0]);
894                 gl.deleteRenderbuffer(rbo[1]);
895                 gl.deleteFramebuffer(fbo[0]);
896                 gl.deleteFramebuffer(fbo[1]);
897             }
898         ));
900         testGroup.addChild(new es3fApiCase.ApiCaseCallback(
901             'framebuffer_texture_layer', 'Invalid glFramebufferTextureLayer() usage', gl,
902             function() {
904                 var fbo = gl.createFramebuffer();
905                 var tex3D = gl.createTexture();
906                 var tex2DArray = gl.createTexture();
907                 var tex2D = gl.createTexture();
908                 gl.bindFramebuffer(gl.FRAMEBUFFER, fbo);
910                 gl.bindTexture(gl.TEXTURE_3D, tex3D);
911                 gl.texImage3D(gl.TEXTURE_3D, 0, gl.RGBA, 4, 4, 4, 0, gl.RGBA, gl.UNSIGNED_BYTE, null);
912                 gl.bindTexture(gl.TEXTURE_2D_ARRAY, tex2DArray);
913                 gl.texImage3D(gl.TEXTURE_2D_ARRAY, 0, gl.RGBA, 4, 4, 4, 0, gl.RGBA, gl.UNSIGNED_BYTE, null);
914                 gl.bindTexture(gl.TEXTURE_2D, tex2D);
915                 gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, 4, 4, 0, gl.RGBA, gl.UNSIGNED_BYTE, null);
916                 this.expectError(gl.NO_ERROR);
918                 bufferedLogToConsole('gl.INVALID_ENUM is generated if target is not one of the accepted tokens.');
919                 gl.framebufferTextureLayer(-1, gl.COLOR_ATTACHMENT0, tex3D, 0, 1);
920                 this.expectError(gl.INVALID_ENUM);
921                 gl.framebufferTextureLayer(gl.RENDERBUFFER, gl.COLOR_ATTACHMENT0, tex3D, 0, 1);
922                 this.expectError(gl.INVALID_ENUM);
924                 bufferedLogToConsole('gl.INVALID_ENUM is generated if attachment is not one of the accepted tokens.');
925                 gl.framebufferTextureLayer(gl.FRAMEBUFFER, -1, tex3D, 0, 1);
926                 this.expectError(gl.INVALID_ENUM);
927                 gl.framebufferTextureLayer(gl.FRAMEBUFFER, gl.BACK, tex3D, 0, 1);
928                 this.expectError(gl.INVALID_ENUM);
930                 bufferedLogToConsole('gl.INVALID_OPERATION is generated if texture is non-zero and not the name of a 3D texture or 2D array texture.');
931                 gl.framebufferTextureLayer(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, tex2D, 0, 0);
932                 this.expectError(gl.INVALID_OPERATION);
934                 bufferedLogToConsole('gl.INVALID_VALUE is generated if texture is not zero and layer is negative.');
935                 gl.framebufferTextureLayer(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, tex3D, 0, -1);
936                 this.expectError(gl.INVALID_VALUE);
938                 bufferedLogToConsole('gl.INVALID_VALUE is generated if texture is not zero and layer is greater than gl.MAX_3D_TEXTURE_SIZE-1 for a 3D texture.');
939                 var max3DTexSize = /** @type {number} */ (gl.getParameter(gl.MAX_3D_TEXTURE_SIZE));
940                 gl.framebufferTextureLayer(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, tex3D, 0, max3DTexSize);
941                 this.expectError(gl.INVALID_VALUE);
943                 bufferedLogToConsole('gl.INVALID_VALUE is generated if texture is not zero and layer is greater than gl.MAX_ARRAY_TEXTURE_LAYERS-1 for a 2D array texture.');
944                 var maxArrayTexLayers = /** @type {number} */ (gl.getParameter(gl.MAX_ARRAY_TEXTURE_LAYERS));
945                 gl.framebufferTextureLayer(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, tex2DArray, 0, maxArrayTexLayers);
946                 this.expectError(gl.INVALID_VALUE);
948                 bufferedLogToConsole('gl.INVALID_OPERATION is generated if zero is bound to target.');
949                 gl.bindFramebuffer(gl.FRAMEBUFFER, null);
950                 gl.framebufferTextureLayer(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, tex3D, 0, 1);
951                 this.expectError(gl.INVALID_OPERATION);
953                 gl.deleteTexture(tex3D);
954                 gl.deleteTexture(tex2DArray);
955                 gl.deleteTexture(tex2D);
956                 gl.deleteFramebuffer(fbo);
957             }
958         ));
960         testGroup.addChild(new es3fApiCase.ApiCaseCallback(
961             'invalidate_framebuffer', 'Invalid gl.invalidateFramebuffer() usage', gl,
962             function() {
963                 var maxColorAttachments = /** @type {number} */ (gl.getParameter(gl.MAX_COLOR_ATTACHMENTS));
964                 var attachments = [
965                     gl.COLOR_ATTACHMENT0
966                 ];
968                 var fbo = gl.createFramebuffer();
969                 gl.bindFramebuffer(gl.FRAMEBUFFER, fbo);
971                 var texture = gl.createTexture();
972                 gl.bindTexture(gl.TEXTURE_2D, texture);
973                 gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, 32, 32, 0, gl.RGBA, gl.UNSIGNED_BYTE, null);
975                 gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, texture, 0);
976                 gl.checkFramebufferStatus(gl.FRAMEBUFFER);
977                 this.expectError(gl.NO_ERROR);
979                 bufferedLogToConsole('gl.INVALID_ENUM is generated if target is not gl.FRAMEBUFFER, gl.READ_FRAMEBUFFER or gl.DRAW_FRAMEBUFFER.');
980                 gl.invalidateFramebuffer(-1, attachments);
981                 this.expectError(gl.INVALID_ENUM);
982                 gl.invalidateFramebuffer(gl.BACK, attachments);
983                 this.expectError(gl.INVALID_ENUM);
985                 bufferedLogToConsole('gl.INVALID_OPERATION is generated if attachments contains gl.COLOR_ATTACHMENTm and m is greater than or equal to the value of gl.MAX_COLOR_ATTACHMENTS.');
986                 gl.invalidateFramebuffer(gl.FRAMEBUFFER, [gl.COLOR_ATTACHMENT0 + maxColorAttachments]);
987                 this.expectError(gl.INVALID_OPERATION);
989                 gl.deleteTexture(texture);
990                 gl.deleteFramebuffer(fbo);
991             }
992         ));
994         testGroup.addChild(new es3fApiCase.ApiCaseCallback(
995             'invalidate_sub_framebuffer', 'Invalid gl.invalidateSubFramebuffer() usage', gl,
996             function() {
997                 var fbo = gl.createFramebuffer();
998                 gl.bindFramebuffer(gl.FRAMEBUFFER, fbo);
1000                 var texture = gl.createTexture();
1001                 gl.bindTexture(gl.TEXTURE_2D, texture);
1002                 gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, 32, 32, 0, gl.RGBA, gl.UNSIGNED_BYTE, null);
1004                 gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, texture, 0);
1005                 gl.checkFramebufferStatus(gl.FRAMEBUFFER);
1006                 this.expectError(gl.NO_ERROR);
1008                 var maxColorAttachments = /** @type {number} */ (gl.getParameter(gl.MAX_COLOR_ATTACHMENTS));
1009                 var att0 = [gl.COLOR_ATTACHMENT0];
1010                 var attm = [gl.COLOR_ATTACHMENT0 + maxColorAttachments];
1012                 bufferedLogToConsole('gl.INVALID_ENUM is generated if target is not gl.FRAMEBUFFER, gl.READ_FRAMEBUFFER or gl.DRAW_FRAMEBUFFER.');
1013                 gl.invalidateSubFramebuffer(-1, att0, 0, 0, 16, 16);
1014                 this.expectError(gl.INVALID_ENUM);
1015                 gl.invalidateSubFramebuffer(gl.BACK, att0, 0, 0, 16, 16);
1016                 this.expectError(gl.INVALID_ENUM);
1018                 bufferedLogToConsole('gl.INVALID_OPERATION is generated if attachments contains gl.COLOR_ATTACHMENTm and m is greater than or equal to the value of gl.MAX_COLOR_ATTACHMENTS.');
1019                 gl.invalidateSubFramebuffer(gl.FRAMEBUFFER, attm, 0, 0, 16, 16);
1020                 this.expectError(gl.INVALID_OPERATION);
1022                 gl.deleteFramebuffer(fbo);
1023             }
1024         ));
1026         testGroup.addChild(new es3fApiCase.ApiCaseCallback(
1027             'renderbuffer_storage_multisample', 'Invalid glRenderbufferStorageMultisample() usage', gl,
1028             function() {
1030                 var rbo = gl.createRenderbuffer();
1031                 gl.bindRenderbuffer(gl.RENDERBUFFER, rbo);
1032                 /** @type {Int32Array} */ var samplesSupportedRGBA4 = /** @type {Int32Array} */ gl.getInternalformatParameter(gl.RENDERBUFFER, gl.RGBA4, gl.SAMPLES);
1033                 // supported samples are written in descending numeric order, so the first one is the max samples
1034                 var maxSamplesSupportedRGBA4 = samplesSupportedRGBA4[0];
1036                 bufferedLogToConsole('gl.INVALID_ENUM is generated if target is not gl.RENDERBUFFER.');
1037                 gl.renderbufferStorageMultisample(-1, 2, gl.RGBA4, 1, 1);
1038                 this.expectError(gl.INVALID_ENUM);
1039                 gl.renderbufferStorageMultisample(gl.FRAMEBUFFER, 2, gl.RGBA4, 1, 1);
1040                 this.expectError(gl.INVALID_ENUM);
1042                 bufferedLogToConsole('gl.INVALID_OPERATION is generated if samples is greater than the maximum number of samples supported for internalformat.');
1043                 gl.renderbufferStorageMultisample(gl.RENDERBUFFER, maxSamplesSupportedRGBA4 + 1, gl.RGBA4, 1, 1);
1044                 this.expectError(gl.INVALID_OPERATION);
1046                 bufferedLogToConsole('gl.INVALID_ENUM is generated if internalformat is not a color-renderable, depth-renderable, or stencil-renderable format.');
1047                 gl.renderbufferStorageMultisample(gl.RENDERBUFFER, 2, -1, 1, 1);
1048                 this.expectError(gl.INVALID_ENUM);
1050                 // EXT_color_buffer_half_float disables error
1051                 if (gl.getExtension('EXT_color_buffer_half_float') === null) {
1052                     gl.renderbufferStorageMultisample(gl.RENDERBUFFER, 2, gl.RGB16F, 1, 1);
1053                     this.expectError(gl.INVALID_ENUM);
1054                 }
1055                 gl.renderbufferStorageMultisample(gl.RENDERBUFFER, 2, gl.RGBA8_SNORM, 1, 1);
1056                 this.expectError(gl.INVALID_ENUM);
1058                 bufferedLogToConsole('gl.INVALID_VALUE is generated if width or height is less than zero.');
1059                 gl.renderbufferStorageMultisample(gl.RENDERBUFFER, 2, gl.RGBA4, -1, 1);
1060                 this.expectError(gl.INVALID_VALUE);
1061                 gl.renderbufferStorageMultisample(gl.RENDERBUFFER, 2, gl.RGBA4, 1, -1);
1062                 this.expectError(gl.INVALID_VALUE);
1063                 gl.renderbufferStorageMultisample(gl.RENDERBUFFER, 2, gl.RGBA4, -1, -1);
1064                 this.expectError(gl.INVALID_VALUE);
1066                 bufferedLogToConsole('gl.INVALID_VALUE is generated if width or height is greater than gl.MAX_RENDERBUFFER_SIZE.');
1067                 var maxSize = /** @type {number} */ (gl.getParameter(gl.MAX_RENDERBUFFER_SIZE));
1068                 gl.renderbufferStorageMultisample(gl.RENDERBUFFER, 4, gl.RGBA4, 1, maxSize + 1);
1069                 this.expectError(gl.INVALID_VALUE);
1070                 gl.renderbufferStorageMultisample(gl.RENDERBUFFER, 4, gl.RGBA4, maxSize + 1, 1);
1071                 this.expectError(gl.INVALID_VALUE);
1072                 gl.renderbufferStorageMultisample(gl.RENDERBUFFER, 4, gl.RGBA4, maxSize + 1, maxSize + 1);
1073                 this.expectError(gl.INVALID_VALUE);
1075                 gl.deleteRenderbuffer(rbo);
1076             }
1077         ));
1079     };
1081     /**
1082     * @param {WebGL2RenderingContext} gl
1083     */
1084     es3fNegativeBufferApiTests.run = function(gl) {
1085         var testName = 'negativeBufferApi';
1086         var testDescription = 'Negative Buffer API tests';
1087         var state = tcuTestCase.runner;
1089         state.testName = testName;
1090         state.testCases = tcuTestCase.newTest(testName, testDescription, null);
1092         //Set up name and description of this test series.
1093         setCurrentTestName(testName);
1094         description(testDescription);
1095         try {
1096             es3fNegativeBufferApiTests.init(gl);
1097             tcuTestCase.runner.runCallback(tcuTestCase.runTestCases);
1098         } catch (err) {
1099             bufferedLogToConsole(err);
1100             tcuTestCase.runner.terminate();
1101         }
1102     };