content/canvas/test/webgl-conformance/conformance/buffers/index-validation-verifies-too-many-indices.html

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/content/canvas/test/webgl-conformance/conformance/buffers/index-validation-verifies-too-many-indices.html	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,47 @@
     1.4 +<!--
     1.5 +Copyright (c) 2011 The Chromium Authors. All rights reserved.
     1.6 +Use of this source code is governed by a BSD-style license that can be
     1.7 +found in the LICENSE file.
     1.8 + -->
     1.9 +<!DOCTYPE html>
    1.10 +<html>
    1.11 +<head>
    1.12 +<meta charset="utf-8">
    1.13 +<link rel="stylesheet" href="../../resources/js-test-style.css"/>
    1.14 +<script src="../../resources/js-test-pre.js"></script>
    1.15 +<script src="../resources/webgl-test.js"></script>
    1.16 +</head>
    1.17 +<body>
    1.18 +<div id="description"></div>
    1.19 +<div id="console"></div>
    1.20 +
    1.21 +<script>
    1.22 +description('Tests that index validation for drawElements does not examine too many indices');
    1.23 +
    1.24 +var context = create3DContext();
    1.25 +var program = loadStandardProgram(context);
    1.26 +
    1.27 +context.useProgram(program);
    1.28 +var vertexObject = context.createBuffer();
    1.29 +context.enableVertexAttribArray(0);
    1.30 +context.bindBuffer(context.ARRAY_BUFFER, vertexObject);
    1.31 +// 4 vertices -> 2 triangles
    1.32 +context.bufferData(context.ARRAY_BUFFER, new Float32Array([ 0,0,0, 0,1,0, 1,0,0, 1,1,0 ]), context.STATIC_DRAW);
    1.33 +context.vertexAttribPointer(0, 3, context.FLOAT, false, 0, 0);
    1.34 +
    1.35 +var indexObject = context.createBuffer();
    1.36 +
    1.37 +debug("Test out of range indices")
    1.38 +context.bindBuffer(context.ELEMENT_ARRAY_BUFFER, indexObject);
    1.39 +context.bufferData(context.ELEMENT_ARRAY_BUFFER, new Uint16Array([ 10000, 0, 1, 2, 3, 10000 ]), context.STATIC_DRAW);
    1.40 +shouldGenerateGLError(context, context.NO_ERROR, "context.drawElements(context.TRIANGLE_STRIP, 4, context.UNSIGNED_SHORT, 2)");
    1.41 +shouldGenerateGLError(context, context.INVALID_OPERATION, "context.drawElements(context.TRIANGLE_STRIP, 4, context.UNSIGNED_SHORT, 0)");
    1.42 +shouldGenerateGLError(context, context.INVALID_OPERATION, "context.drawElements(context.TRIANGLE_STRIP, 4, context.UNSIGNED_SHORT, 4)");
    1.43 +
    1.44 +debug("")
    1.45 +successfullyParsed = true;
    1.46 +</script>
    1.47 +
    1.48 +<script>finishTest();</script>
    1.49 +</body>
    1.50 +</html>

mercurial