How to use shouldGenerateGLError method in wpt

Best JavaScript code snippet using wpt

out-of-bounds-test.js

Source:out-of-bounds-test.js Github

copy

Full Screen

...22*/23'use strict';24var OutOfBoundsTest = (function() {25var runCommonInvalidValueTests = function(callTemplate, gl, wtu, ext) {26 wtu.shouldGenerateGLError(gl, gl.INVALID_VALUE, wtu.replaceParams(callTemplate, {count: -1, type: 'gl.UNSIGNED_BYTE', offset: 0}));27 wtu.shouldGenerateGLError(gl, gl.INVALID_VALUE, wtu.replaceParams(callTemplate, {count: 0, type: 'gl.UNSIGNED_BYTE', offset: -1}));28 wtu.shouldGenerateGLError(gl, gl.INVALID_VALUE, wtu.replaceParams(callTemplate, {count: -1, type: 'gl.UNSIGNED_BYTE', offset: 1}));29 wtu.shouldGenerateGLError(gl, gl.INVALID_VALUE, wtu.replaceParams(callTemplate, {count: 1, type: 'gl.UNSIGNED_BYTE', offset: -1}));30 wtu.shouldGenerateGLError(gl, gl.INVALID_VALUE, wtu.replaceParams(callTemplate, {count: '0xffffffff', type: 'gl.UNSIGNED_BYTE', offset: 0}));31};32var setupProgramAndBindVertexArray = function(gl, wtu) {33 var program = wtu.loadStandardProgram(gl);34 gl.useProgram(program);35 var vertexObject = gl.createBuffer();36 gl.bindBuffer(gl.ARRAY_BUFFER, vertexObject);37 gl.enableVertexAttribArray(0);38 return program;39};40var setupProgram2 = function(gl, wtu) {41 var vshader = [42 '#version 300 es',43 'in vec3 aOne;',44 'in vec2 aTwo;',45 'void main() {',46 ' gl_Position = vec4(aOne, 1.0) + vec4(aTwo, 0.0, 1.0);',47 '}'48 ].join('\n');49 var fshader = [50 '#version 300 es',51 'out vec4 my_FragColor;',52 'void main() {',53 ' my_FragColor = vec4(1.0, 0.0, 0.0, 1.0);',54 '}'55 ].join('\n');56 var program = wtu.setupProgram(gl, [vshader, fshader], [ "aOne", "aTwo" ]);57 if (!program) {58 testFailed("failed to create test program");59 }60 return program;61};62var runDrawArraysTest = function(callTemplate, gl, wtu, ext) {63 var program = setupProgramAndBindVertexArray(gl, wtu);64 debug("Test empty buffer")65 gl.bufferData(gl.ARRAY_BUFFER, new Float32Array([ ]), gl.STATIC_DRAW);66 gl.vertexAttribPointer(0, 3, gl.FLOAT, false, 0, 0);67 wtu.shouldGenerateGLError(gl, gl.INVALID_OPERATION, wtu.replaceParams(callTemplate, {offset: 0, count: 1}));68 wtu.shouldGenerateGLError(gl, gl.INVALID_OPERATION, wtu.replaceParams(callTemplate, {offset: 0, count: 10000}));69 wtu.shouldGenerateGLError(gl, gl.INVALID_OPERATION, wtu.replaceParams(callTemplate, {offset: 0, count: 10000000000000}));70 wtu.shouldGenerateGLError(gl, gl.NO_ERROR, wtu.replaceParams(callTemplate, {offset: 1, count: 0}));71 wtu.shouldGenerateGLError(gl, gl.NO_ERROR, wtu.replaceParams(callTemplate, {offset: 0, count: 0}));72 wtu.shouldGenerateGLError(gl, gl.NO_ERROR, wtu.replaceParams(callTemplate, {offset: 100, count: 0}));73 runCommonInvalidValueTests(callTemplate, gl, wtu, ext);74 debug("")75 debug("Test buffer with 3 float vectors")76 gl.bufferData(gl.ARRAY_BUFFER, new Float32Array([ 0,0.5,0, -0.5,-0.5,0, 0.5,-0.5,0 ]), gl.STATIC_DRAW);77 gl.vertexAttribPointer(0, 3, gl.FLOAT, false, 0, 0);78 wtu.shouldGenerateGLError(gl, gl.NO_ERROR, wtu.replaceParams(callTemplate, {offset: 0, count: 3}));79 wtu.shouldGenerateGLError(gl, gl.INVALID_OPERATION, wtu.replaceParams(callTemplate, {offset: 3, count: 2}));80 wtu.shouldGenerateGLError(gl, gl.INVALID_OPERATION, wtu.replaceParams(callTemplate, {offset: 0, count: 10000}));81 wtu.shouldGenerateGLError(gl, gl.INVALID_OPERATION, wtu.replaceParams(callTemplate, {offset: 0, count: 10000000000000}));82 wtu.shouldGenerateGLError(gl, gl.NO_ERROR, wtu.replaceParams(callTemplate, {offset: 0, count: 0}));83 wtu.shouldGenerateGLError(gl, gl.NO_ERROR, wtu.replaceParams(callTemplate, {offset: 100, count: 0}));84 runCommonInvalidValueTests(callTemplate, gl, wtu, ext);85 debug("")86 debug("Test buffer with interleaved (3+2) float vectors")87 setupProgram2(gl, wtu);88 var vbo = gl.createBuffer();89 gl.bindBuffer(gl.ARRAY_BUFFER, vbo);90 // enough for 9 vertices, so 3 triangles91 gl.bufferData(gl.ARRAY_BUFFER, new Float32Array(9*5), gl.STATIC_DRAW);92 // bind first 3 elements, with a stride of 5 float elements93 gl.vertexAttribPointer(0, 3, gl.FLOAT, false, 5*4, 0);94 // bind 2 elements, starting after the first 3; same stride of 5 float elements95 gl.vertexAttribPointer(1, 2, gl.FLOAT, false, 5*4, 3*4);96 gl.enableVertexAttribArray(0);97 gl.enableVertexAttribArray(1);98 wtu.shouldGenerateGLError(gl, gl.NO_ERROR, wtu.replaceParams(callTemplate, {offset: 0, count: 9}));99 // negative values must generate INVALID_VALUE; they can never be valid100 wtu.shouldGenerateGLError(gl, gl.INVALID_VALUE, wtu.replaceParams(callTemplate, {offset: 0, count: -500}));101 wtu.shouldGenerateGLError(gl, gl.INVALID_VALUE, wtu.replaceParams(callTemplate, {offset: -200, count: 1}));102 wtu.shouldGenerateGLError(gl, gl.INVALID_VALUE, wtu.replaceParams(callTemplate, {offset: -200, count: -500}));103 // 0xffffffff needs to convert to a 'long' IDL argument as -1, as per104 // WebIDL 4.1.7. JS ToInt32(0xffffffff) == -1. Thus INVALID_VALUE.105 wtu.shouldGenerateGLError(gl, gl.INVALID_VALUE, wtu.replaceParams(callTemplate, {offset: 0, count: '0xffffffff'}));106 wtu.shouldGenerateGLError(gl, gl.INVALID_VALUE, wtu.replaceParams(callTemplate, {offset: '0xffffffff', count: '0xffffffff'}));107 wtu.shouldGenerateGLError(gl, gl.INVALID_VALUE, wtu.replaceParams(callTemplate, {offset: '0xffffffff', count: 1}));108 // values that could otherwise be valid but aren't due to bindings generate109 // INVALID_OPERATION110 wtu.shouldGenerateGLError(gl, gl.INVALID_OPERATION, wtu.replaceParams(callTemplate, {offset: 0, count: 200}));111 wtu.shouldGenerateGLError(gl, gl.INVALID_OPERATION, wtu.replaceParams(callTemplate, {offset: 0, count: '0x7fffffff'}));112 wtu.shouldGenerateGLError(gl, gl.INVALID_OPERATION, wtu.replaceParams(callTemplate, {offset: '0x7fffffff', count: 1}));113 wtu.shouldGenerateGLError(gl, gl.INVALID_OPERATION, wtu.replaceParams(callTemplate, {offset: '0x7fffffff', count: '0x7fffffff'}));114};115var runDrawElementsTest = function(callTemplate, gl, wtu, ext) {116 var program = setupProgramAndBindVertexArray(gl, wtu);117 var contextVersion = wtu.getDefault3DContextVersion();118 gl.bufferData(gl.ARRAY_BUFFER, new Float32Array([ 0,0.5,0, -0.5,-0.5,0, 0.5,-0.5,0 ]), gl.STATIC_DRAW);119 gl.vertexAttribPointer(0, 3, gl.FLOAT, false, 0, 0);120 var indexObject = gl.createBuffer();121 debug('Test empty index buffer');122 gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, indexObject);123 gl.bufferData(gl.ELEMENT_ARRAY_BUFFER, new Uint8Array([ ]), gl.STATIC_DRAW);124 wtu.shouldGenerateGLError(gl, gl.NO_ERROR, wtu.replaceParams(callTemplate, {count: 0, type: 'gl.UNSIGNED_BYTE', offset: 0}));125 wtu.shouldGenerateGLError(gl, gl.INVALID_OPERATION, wtu.replaceParams(callTemplate, {count: 3, type: 'gl.UNSIGNED_BYTE', offset: 0}));126 wtu.shouldGenerateGLError(gl, gl.INVALID_OPERATION, wtu.replaceParams(callTemplate, {count: 10000, type: 'gl.UNSIGNED_BYTE', offset: 0}));127 wtu.shouldGenerateGLError(gl, gl.INVALID_OPERATION, wtu.replaceParams(callTemplate, {count: 10000000000000, type: 'gl.UNSIGNED_BYTE', offset: 0}));128 wtu.shouldGenerateGLError(gl, gl.INVALID_OPERATION, wtu.replaceParams(callTemplate, {count: 1, type: 'gl.UNSIGNED_BYTE', offset: 0}));129 runCommonInvalidValueTests(callTemplate, gl, wtu, ext);130 debug('');131 debug('Test buffer with 3 byte indexes');132 gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, indexObject);133 gl.bufferData(gl.ELEMENT_ARRAY_BUFFER, new Uint8Array([ 0, 1, 2 ]), gl.STATIC_DRAW);134 wtu.shouldGenerateGLError(gl, gl.NO_ERROR, wtu.replaceParams(callTemplate, {count: 3, type: 'gl.UNSIGNED_BYTE', offset: 0}));135 wtu.shouldGenerateGLError(gl, gl.INVALID_OPERATION, wtu.replaceParams(callTemplate, {count: 3, type: 'gl.UNSIGNED_BYTE', offset: 2}));136 wtu.shouldGenerateGLError(gl, gl.INVALID_OPERATION, wtu.replaceParams(callTemplate, {count: 10000, type: 'gl.UNSIGNED_BYTE', offset: 0}));137 wtu.shouldGenerateGLError(gl, gl.INVALID_OPERATION, wtu.replaceParams(callTemplate, {count: 10000000000000, type: 'gl.UNSIGNED_BYTE', offset: 0}));138 runCommonInvalidValueTests(callTemplate, gl, wtu, ext);139 wtu.shouldGenerateGLError(gl, gl.NO_ERROR, wtu.replaceParams(callTemplate, {count: 0, type: 'gl.UNSIGNED_BYTE', offset: 4}));140 wtu.shouldGenerateGLError(gl, gl.INVALID_OPERATION, wtu.replaceParams(callTemplate, {count: '0x7fffffff', type: 'gl.UNSIGNED_BYTE', offset: 0}));141 wtu.shouldGenerateGLError(gl, gl.INVALID_OPERATION, wtu.replaceParams(callTemplate, {count: '0x7fffffff', type: 'gl.UNSIGNED_BYTE', offset: '0x7fffffff'}));142 wtu.shouldGenerateGLError(gl, gl.NO_ERROR, 'gl.bufferData(gl.ELEMENT_ARRAY_BUFFER, (new Uint8Array([ 3, 0, 1, 2 ])).subarray(1), gl.STATIC_DRAW)');143 wtu.shouldGenerateGLError(gl, gl.NO_ERROR, wtu.replaceParams(callTemplate, {count: 3, type: 'gl.UNSIGNED_BYTE', offset: 0}));144 wtu.shouldGenerateGLError(gl, gl.NO_ERROR, 'gl.bufferSubData(gl.ELEMENT_ARRAY_BUFFER, 0, new Uint8Array([ 3, 0, 1]))');145 var indexValidationError = wtu.shouldGenerateGLError(gl, [gl.INVALID_OPERATION, gl.NO_ERROR], wtu.replaceParams(callTemplate, {count: 3, type: 'gl.UNSIGNED_BYTE', offset: 0}));146 wtu.shouldGenerateGLError(gl, gl.NO_ERROR, 'gl.bufferSubData(gl.ELEMENT_ARRAY_BUFFER, 0, (new Uint8Array([ 3, 0, 1, 2 ])).subarray(1))');147 wtu.shouldGenerateGLError(gl, gl.NO_ERROR, wtu.replaceParams(callTemplate, {count: 3, type: 'gl.UNSIGNED_BYTE', offset: 0}));148 wtu.shouldGenerateGLError(gl, gl.NO_ERROR, wtu.replaceParams(callTemplate, {count: 0, type: 'gl.UNSIGNED_BYTE', offset: 0}));149 debug('');150 debug('Test buffer with interleaved (3+2) float vectors');151 setupProgram2(gl, wtu);152 var vbo = gl.createBuffer();153 gl.bindBuffer(gl.ARRAY_BUFFER, vbo);154 // enough for 9 vertices, so 3 triangles155 gl.bufferData(gl.ARRAY_BUFFER, new Float32Array(9*5), gl.STATIC_DRAW);156 // bind first 3 elements, with a stride of 5 float elements157 gl.vertexAttribPointer(0, 3, gl.FLOAT, false, 5*4, 0);158 // bind 2 elements, starting after the first 3; same stride of 5 float elements159 gl.vertexAttribPointer(1, 2, gl.FLOAT, false, 5*4, 3*4);160 gl.enableVertexAttribArray(0);161 gl.enableVertexAttribArray(1);162 var ebo = gl.createBuffer();163 gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, ebo);164 // For WebGL 2, PRIMITIVE_RESTART_FIXED_INDEX is always enabled.165 // 0xffff will be handled as a primitive restart.166 if (contextVersion <= 1) {167 gl.bufferData(gl.ELEMENT_ARRAY_BUFFER, new Uint16Array(168 [ 0, 1, 2,169 1, 2, 0,170 2, 0, 1,171 201, 202, 203,172 0x7fff, 0x7fff, 0x7fff,173 0xffff, 0xffff, 0xffff ]),174 gl.STATIC_DRAW);175 } else {176 gl.bufferData(gl.ELEMENT_ARRAY_BUFFER, new Uint16Array(177 [ 0, 1, 2,178 1, 2, 0,179 2, 0, 1,180 201, 202, 203,181 0x7fff, 0x7fff, 0x7fff,182 0xffff - 1, 0xffff - 1, 0xffff - 1 ]),183 gl.STATIC_DRAW);184 }185 wtu.shouldGenerateGLError(gl, gl.NO_ERROR, wtu.replaceParams(callTemplate, {count: 9, type: 'gl.UNSIGNED_SHORT', offset: 0}));186 // invalid operation with indices that would be valid with correct bindings187 wtu.shouldGenerateGLError(gl, gl.INVALID_OPERATION, wtu.replaceParams(callTemplate, {count: 9, type: 'gl.UNSIGNED_SHORT', offset: 1000}));188 wtu.shouldGenerateGLError(gl, indexValidationError, wtu.replaceParams(callTemplate, {count: 12, type: 'gl.UNSIGNED_SHORT', offset: 0}));189 wtu.shouldGenerateGLError(gl, indexValidationError, wtu.replaceParams(callTemplate, {count: 15, type: 'gl.UNSIGNED_SHORT', offset: 0}));190 wtu.shouldGenerateGLError(gl, indexValidationError, wtu.replaceParams(callTemplate, {count: 18, type: 'gl.UNSIGNED_SHORT', offset: 0}));191 wtu.shouldGenerateGLError(gl, indexValidationError, wtu.replaceParams(callTemplate, {count: 3, type: 'gl.UNSIGNED_SHORT', offset: 2*15}));192 // 0xffffffff needs to convert to a 'long' IDL argument as -1, as per193 // WebIDL 4.1.7. JS ToInt32(0xffffffff) == -1. Thus INVALID_VALUE.194 wtu.shouldGenerateGLError(gl, gl.INVALID_VALUE, wtu.replaceParams(callTemplate, {count: '0xffffffff', type: 'gl.UNSIGNED_SHORT', offset: 0}));195 // offset is defined as GLintptr, which is long long in IDL (64-bit).196 // 2^32 - 1 should not overflow, and only result in INVALID_OPERATION.197 wtu.shouldGenerateGLError(gl, gl.INVALID_OPERATION, wtu.replaceParams(callTemplate, {count: 1, type: 'gl.UNSIGNED_SHORT', offset: '0xffffffff'}));198 wtu.shouldGenerateGLError(gl, gl.INVALID_OPERATION, wtu.replaceParams(callTemplate, {count: '0x7fffffff', type: 'gl.UNSIGNED_SHORT', offset: 0}));199 wtu.shouldGenerateGLError(gl, gl.NO_ERROR, wtu.replaceParams(callTemplate, {count: 0, type: 'gl.UNSIGNED_SHORT', offset: 0}));200 // invalid operation with offset that's not a multiple of the type size201 wtu.shouldGenerateGLError(gl, gl.NO_ERROR, wtu.replaceParams(callTemplate, {count: 6, type: 'gl.UNSIGNED_SHORT', offset: 0}));202 wtu.shouldGenerateGLError(gl, gl.INVALID_OPERATION, wtu.replaceParams(callTemplate, {count: 6, type: 'gl.UNSIGNED_SHORT', offset: 1}));203 wtu.shouldGenerateGLError(gl, gl.NO_ERROR, wtu.replaceParams(callTemplate, {count: 6, type: 'gl.UNSIGNED_SHORT', offset: 2}));204 // invalid operation if no buffer is bound to ELEMENT_ARRAY_BUFFER205 gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, null);206 wtu.shouldGenerateGLError(gl, gl.INVALID_OPERATION, wtu.replaceParams(callTemplate, {count: 6, type: 'gl.UNSIGNED_SHORT', offset: 0}));207 gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, ebo);208 debug('');209 debug('Test buffer setting attrib 0 to a buffer too small and disable it.');210 var smallVBO = gl.createBuffer();211 gl.bindBuffer(gl.ARRAY_BUFFER, smallVBO);212 gl.bufferData(gl.ARRAY_BUFFER, 1, gl.STATIC_DRAW);213 gl.vertexAttribPointer(0, 3, gl.FLOAT, false, 0, 0x10);214 gl.disableVertexAttribArray(0);215 wtu.shouldGenerateGLError(gl, gl.NO_ERROR, wtu.replaceParams(callTemplate, {count: 6, type: 'gl.UNSIGNED_SHORT', offset: 2}));216 gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, null);217 wtu.shouldGenerateGLError(gl, gl.INVALID_OPERATION, wtu.replaceParams(callTemplate, {count: 6, type: 'gl.UNSIGNED_SHORT', offset: 2}));218};219var runInstancedTest = function(callTemplate, gl, wtu, ext) {220 setupProgram2(gl, wtu);221 // Initialize non-instanced attribute data.222 // Enough for 9 vertices, so 3 triangles.223 var vbo = gl.createBuffer();224 gl.bindBuffer(gl.ARRAY_BUFFER, vbo);225 gl.bufferData(gl.ARRAY_BUFFER, new Float32Array(9*3), gl.STATIC_DRAW);226 gl.vertexAttribPointer(0, 3, gl.FLOAT, false, 0, 0);227 // Setup buffer for instanced attribute data.228 var vbo2 = gl.createBuffer();229 gl.bindBuffer(gl.ARRAY_BUFFER, vbo2);230 gl.vertexAttribPointer(1, 2, gl.FLOAT, false, 0, 0);231 gl.enableVertexAttribArray(0);232 gl.enableVertexAttribArray(1);233 debug('Test out-of-range instanced attributes');234 debug('');235 debug('Test with an empty buffer for the instanced attribute');236 ext.vertexAttribDivisorANGLE(1, 1);237 wtu.shouldGenerateGLError(gl, gl.NO_ERROR, wtu.replaceParams(callTemplate, {offset: 0, count: 9, primcount: 0}));238 wtu.shouldGenerateGLError(gl, gl.NO_ERROR, wtu.replaceParams(callTemplate, {offset: 0, count: 10000, primcount: 0}));239 wtu.shouldGenerateGLError(gl, gl.INVALID_OPERATION, wtu.replaceParams(callTemplate, {offset: 0, count: 9, primcount: 1}));240 debug('Test with a buffer with 1 float for the instanced attribute');241 gl.bufferData(gl.ARRAY_BUFFER, new Float32Array(1), gl.STATIC_DRAW);242 wtu.shouldGenerateGLError(gl, gl.NO_ERROR, wtu.replaceParams(callTemplate, {offset: 0, count: 9, primcount: 0}));243 wtu.shouldGenerateGLError(gl, gl.NO_ERROR, wtu.replaceParams(callTemplate, {offset: 0, count: 10000, primcount: 0}));244 wtu.shouldGenerateGLError(gl, gl.INVALID_OPERATION, wtu.replaceParams(callTemplate, {offset: 0, count: 9, primcount: 1}));245 debug('');246 debug('Test with a buffer with 2 floats for the instanced attribute');247 gl.bufferData(gl.ARRAY_BUFFER, new Float32Array(2), gl.STATIC_DRAW);248 debug('Divisor 1');249 ext.vertexAttribDivisorANGLE(1, 1);250 wtu.shouldGenerateGLError(gl, gl.NO_ERROR, wtu.replaceParams(callTemplate, {offset: 0, count: 9, primcount: 1}));251 wtu.shouldGenerateGLError(gl, gl.INVALID_OPERATION, wtu.replaceParams(callTemplate, {offset: 0, count: 9, primcount: 2}));252 debug('Divisor 3');253 ext.vertexAttribDivisorANGLE(1, 3);254 wtu.shouldGenerateGLError(gl, gl.NO_ERROR, wtu.replaceParams(callTemplate, {offset: 0, count: 9, primcount: 3}));255 wtu.shouldGenerateGLError(gl, gl.INVALID_OPERATION, wtu.replaceParams(callTemplate, {offset: 0, count: 9, primcount: 4}));256 wtu.shouldGenerateGLError(gl, gl.INVALID_OPERATION, wtu.replaceParams(callTemplate, {offset: 0, count: 9, primcount: 10000}));257 wtu.shouldGenerateGLError(gl, gl.INVALID_OPERATION, wtu.replaceParams(callTemplate, {offset: 0, count: 9, primcount: '0x7fffffff'}));258 debug('');259 debug('Test with a buffer with 4 floats for the instanced attribute');260 gl.bufferData(gl.ARRAY_BUFFER, new Float32Array(4), gl.STATIC_DRAW);261 debug('Divisor 1');262 ext.vertexAttribDivisorANGLE(1, 1);263 wtu.shouldGenerateGLError(gl, gl.NO_ERROR, wtu.replaceParams(callTemplate, {offset: 0, count: 9, primcount: 2}));264 wtu.shouldGenerateGLError(gl, gl.INVALID_OPERATION, wtu.replaceParams(callTemplate, {offset: 0, count: 9, primcount: 3}));265 debug('Divisor 2');266 ext.vertexAttribDivisorANGLE(1, 2);267 wtu.shouldGenerateGLError(gl, gl.NO_ERROR, wtu.replaceParams(callTemplate, {offset: 0, count: 9, primcount: 4}));268 wtu.shouldGenerateGLError(gl, gl.INVALID_OPERATION, wtu.replaceParams(callTemplate, {offset: 0, count: 9, primcount: 5}));269};270var runDrawArraysInstancedTest = function(callTemplate, gl, wtu, ext) {271 runInstancedTest(callTemplate, gl, wtu, ext);272};273var runDrawElementsInstancedTest = function(callTemplate, gl, wtu, ext) {274 var ebo = gl.createBuffer();275 gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, ebo);276 gl.bufferData(gl.ELEMENT_ARRAY_BUFFER, new Uint8Array(277 [ 0, 1, 2,278 5, 4, 3,279 6, 7, 8 ]),280 gl.STATIC_DRAW);281 callTemplate = wtu.replaceParams(callTemplate, {type: 'gl.UNSIGNED_BYTE', offset: '$(offset)', count: '$(count)', primcount: '$(primcount)'});282 runInstancedTest(callTemplate, gl, wtu, ext);...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1function testGLError()2{3 var canvas = document.getElementById('canvas');4 var gl = canvas.getContext('experimental-webgl');5 var program = gl.createProgram();6 var shader = gl.createShader(gl.VERTEX_SHADER);7 gl.shaderSource(shader, "bad shader source");8 gl.compileShader(shader);9 gl.attachShader(program, shader);10 gl.linkProgram(program);11 gl.useProgram(program);12 gl.getAttribLocation(program, "badAttrib");13 gl.getError();14 if (shouldGenerateGLError(gl))15 testPassed("shouldGenerateGLError generated an error");16 testFailed("shouldGenerateGLError did not generate an error");17}18<body onload="testGLError()">

Full Screen

Using AI Code Generation

copy

Full Screen

1shouldGenerateGLError(gl, gl.INVALID_ENUM, "gl.getError()",2 "gl.getError() should return gl.INVALID_ENUM");3shouldGenerateGLError(gl, gl.INVALID_ENUM, "gl.getError()",4 "gl.getError() should return gl.INVALID_ENUM");5shouldGenerateGLError(gl, gl.NO_ERROR, "gl.getError()",6 "gl.getError() should return gl.NO_ERROR");7importScripts("wpt.js");8shouldGenerateGLError(gl, gl.INVALID_ENUM, "gl.getError()",9 "gl.getError() should return gl.INVALID_ENUM");

Full Screen

Using AI Code Generation

copy

Full Screen

1var wpt = require('wptdriver');2wpt.shouldGenerateGLError(true);3var gl = document.getElementById("canvas").getContext("webgl");4gl.clearColor(0,0,0,0);5gl.clear(gl.COLOR_BUFFER_BIT);6gl.getError();7var wpt = require('wptdriver');8wpt.shouldGenerateGLError(false);9var gl = document.getElementById("canvas").getContext("webgl");10if (gl.getError() != 0) {11}12var wpt = require('wptdriver');13wpt.shouldGenerateGLError(true);14var gl = document.getElementById("canvas").getContext("webgl");15gl.clearColor(0,0,0,0);16gl.clear(gl.COLOR_BUFFER_BIT);17gl.getError();18var wpt = require('wptdriver');19wpt.shouldGenerateGLError(false);20var gl = document.getElementById("canvas").getContext("webgl");21if (gl.getError() != 0) {22}

Full Screen

Using AI Code Generation

copy

Full Screen

1function shouldGenerateGLError(gl, func, opt_msg) {2 var msg = opt_msg ? opt_msg : func + " should generate GL error";3 if (typeof func == 'string') {4 func = gl[func];5 }6 var oldError = gl.getError();7 func();8 var error = gl.getError();9 if (error == gl.NO_ERROR) {10 testFailed(msg);11 } else if (error != oldError) {12 testFailed(msg + " but got " + wtu.glEnumToString(gl, error));13 } else {14 testPassed(msg);15 }16}

Full Screen

Using AI Code Generation

copy

Full Screen

1function shouldGenerateGLError() {2 var gl = wtu.create3DContext();3 gl.getError();4 gl.getError();5 return gl.getError() != gl.NO_ERROR;6}7 test(function() {8 assert_true(shouldGenerateGLError());9 }, "Should generate GL error");10function shouldGenerateGLError() {11 var gl = wtu.create3DContext();12 gl.getError();13 gl.getError();14 return gl.getError() != gl.NO_ERROR;15}16 setup(function() {17 shouldGenerateGLError();18 });19 test(function() {20 assert_true(shouldGenerateGLError());21 }, "Should generate GL error");22function shouldGenerateGLError() {23 var gl = wtu.create3DContext();24 gl.getError();25 gl.getError();

Full Screen

Using AI Code Generation

copy

Full Screen

1function runTest()2{3 test_driver.shouldGenerateGLError("test", "test", 0, "test");4}5function shouldGenerateGLError(errorName, description, glErrorCode, glErrorMessage) {6 return new Promise(function(resolve, reject) {7 sendCommand('shouldGenerateGLError', {errorName: errorName, description: description, glErrorCode: glErrorCode, glErrorMessage: glErrorMessage}, resolve);8 });9}10function shouldGenerateGLError(errorName, description, glErrorCode, glErrorMessage) {11 return new Promise(function(resolve, reject) {12 sendCommand('shouldGenerateGLError', {errorName: errorName, description: description, glErrorCode: glErrorCode, glErrorMessage: glErrorMessage}, resolve);13 });14}15function shouldGenerateGLError(errorName, description, glErrorCode, glErrorMessage) {16 return new Promise(function(resolve, reject) {17 sendCommand('shouldGenerateGLError', {errorName: errorName, description: description, glErrorCode: glErrorCode, glErrorMessage: glErrorMessage}, resolve);18 });19}20function shouldGenerateGLError(errorName, description, glErrorCode, glErrorMessage) {21 return new Promise(function(resolve, reject) {22 sendCommand('shouldGenerateGLError', {errorName: errorName, description: description, glErrorCode: glErrorCode, glErrorMessage: glErrorMessage}, resolve);23 });24}25function shouldGenerateGLError(errorName, description, glErrorCode, glErrorMessage) {26 return new Promise(function(resolve, reject) {27 sendCommand('shouldGenerateGLError', {errorName: errorName, description: description, glErrorCode: glErrorCode, glErrorMessage: glErrorMessage}, resolve);28 });29}30function shouldGenerateGLError(errorName, description, glErrorCode, glErrorMessage) {31 return new Promise(function(resolve, reject) {32 sendCommand('shouldGenerateGLError', {errorName:

Full Screen

Using AI Code Generation

copy

Full Screen

1function setup() {2}3function draw() {4}5function shouldGenerateGLError() {6}7function shouldGenerateGLError() {8 var gl = getWebGLContext();9 if (!gl) {10 return false;11 }12 var error = gl.getError();13 return error != gl.NO_ERROR;14}

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run wpt automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful