3 <script src=
"../../../resources/js-test.js"></script>
4 <script src=
"resources/webgl-test.js"></script>
7 <div id=
"description"></div>
8 <div id=
"console"></div>
11 description('Tests that index validation for drawElements does not examine too many indices');
14 window
.internals
.settings
.setWebGLErrorsToConsoleEnabled(false);
16 var context
= create3DContext();
17 var program
= loadStandardProgram(context
);
19 context
.useProgram(program
);
20 var vertexObject
= context
.createBuffer();
21 context
.enableVertexAttribArray(0);
22 context
.bindBuffer(context
.ARRAY_BUFFER
, vertexObject
);
23 // 4 vertices -> 2 triangles
24 context
.bufferData(context
.ARRAY_BUFFER
, new Float32Array([ 0,0,0, 0,1,0, 1,0,0, 1,1,0 ]), context
.STATIC_DRAW
);
25 context
.vertexAttribPointer(0, 3, context
.FLOAT
, false, 0, 0);
27 var indexObject
= context
.createBuffer();
29 debug("Test out of range indices")
30 context
.bindBuffer(context
.ELEMENT_ARRAY_BUFFER
, indexObject
);
31 context
.bufferData(context
.ELEMENT_ARRAY_BUFFER
, new Uint16Array([ 10000, 0, 1, 2, 3, 10000 ]), context
.STATIC_DRAW
);
32 shouldGenerateGLError(context
, context
.NO_ERROR
, "context.drawElements(context.TRIANGLE_STRIP, 4, context.UNSIGNED_SHORT, 2)");
33 shouldGenerateGLError(context
, context
.INVALID_OPERATION
, "context.drawElements(context.TRIANGLE_STRIP, 4, context.UNSIGNED_SHORT, 0)");
34 shouldGenerateGLError(context
, context
.INVALID_OPERATION
, "context.drawElements(context.TRIANGLE_STRIP, 4, context.UNSIGNED_SHORT, 4)");