content/canvas/test/webgl-conformance/conformance/rendering/draw-arrays-out-of-bounds.html

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

     1 <!--
     2 Copyright (C) 2011 Apple Computer, Inc.  All rights reserved.
     4 Redistribution and use in source and binary forms, with or without
     5 modification, are permitted provided that the following conditions
     6 are met:
     7 1. Redistributions of source code must retain the above copyright
     8    notice, this list of conditions and the following disclaimer.
     9 2. Redistributions in binary form must reproduce the above copyright
    10    notice, this list of conditions and the following disclaimer in the
    11    documentation and/or other materials provided with the distribution.
    13 THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
    14 EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
    15 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
    16 PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE COMPUTER, INC. OR
    17 CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
    18 EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
    19 PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
    20 PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
    21 OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
    22 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
    23 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    24 -->
    25 <!DOCTYPE html>
    26 <html>
    27 <head>
    28 <meta charset="utf-8">
    29 <link rel="stylesheet" href="../../resources/js-test-style.css"/>
    30 <script src="../../resources/js-test-pre.js"></script>
    31 <script src="../resources/webgl-test.js"></script>
    32 </head>
    33 <body>
    34 <div id="description"></div>
    35 <div id="console"></div>
    37 <script>
    38 description("Test of drawArrays with out-of-bounds parameters");
    40 var context = create3DContext();
    41 var program = loadStandardProgram(context);
    43 context.useProgram(program);
    44 var vertexObject = context.createBuffer();
    45 context.bindBuffer(context.ARRAY_BUFFER, vertexObject);
    46 context.enableVertexAttribArray(0);
    48 debug("Test empty buffer")
    49 context.bufferData(context.ARRAY_BUFFER, new Float32Array([  ]), context.STATIC_DRAW);
    50 context.vertexAttribPointer(0, 3, context.FLOAT, false, 0, 0);
    51 shouldGenerateGLError(context, context.INVALID_OPERATION, "context.drawArrays(context.TRIANGLES, 0, 1)");
    52 shouldGenerateGLError(context, context.INVALID_OPERATION, "context.drawArrays(context.TRIANGLES, 0, 10000)");
    53 shouldGenerateGLError(context, context.INVALID_OPERATION, "context.drawArrays(context.TRIANGLES, 0, 10000000000000)");
    54 shouldGenerateGLError(context, context.INVALID_VALUE, "context.drawArrays(context.TRIANGLES, 0, -1)");
    55 shouldGenerateGLError(context, context.NO_ERROR, "context.drawArrays(context.TRIANGLES, 1, 0)");
    56 shouldGenerateGLError(context, context.INVALID_VALUE, "context.drawArrays(context.TRIANGLES, -1, 0)");
    57 shouldGenerateGLError(context, context.NO_ERROR, "context.drawArrays(context.TRIANGLES, 0, 0)");
    58 shouldGenerateGLError(context, context.NO_ERROR, "context.drawArrays(context.TRIANGLES, 100, 0)");
    59 shouldGenerateGLError(context, context.INVALID_VALUE, "context.drawArrays(context.TRIANGLES, 1, -1)");
    60 shouldGenerateGLError(context, context.INVALID_VALUE, "context.drawArrays(context.TRIANGLES, -1, 1)");
    62 debug("")
    63 debug("Test buffer with 3 float vectors")
    64 context.bufferData(context.ARRAY_BUFFER, new Float32Array([ 0,0.5,0, -0.5,-0.5,0, 0.5,-0.5,0 ]), context.STATIC_DRAW);
    65 context.vertexAttribPointer(0, 3, context.FLOAT, false, 0, 0);
    66 shouldGenerateGLError(context, context.NO_ERROR, "context.drawArrays(context.TRIANGLES, 0, 3)");
    67 shouldGenerateGLError(context, context.INVALID_ENUM, "context.drawArrays(0x0009, 0, 3)"); // GL_POLYGON
    68 shouldGenerateGLError(context, context.INVALID_OPERATION, "context.drawArrays(context.TRIANGLES, 3, 2)");
    69 shouldGenerateGLError(context, context.INVALID_OPERATION, "context.drawArrays(context.TRIANGLES, 0, 10000)");
    70 shouldGenerateGLError(context, context.INVALID_OPERATION, "context.drawArrays(context.TRIANGLES, 0, 10000000000000)");
    71 shouldGenerateGLError(context, context.INVALID_VALUE, "context.drawArrays(context.TRIANGLES, 0, -1)");
    72 shouldGenerateGLError(context, context.INVALID_VALUE, "context.drawArrays(context.TRIANGLES, -1, 0)");
    73 shouldGenerateGLError(context, context.NO_ERROR, "context.drawArrays(context.TRIANGLES, 0, 0)");
    74 shouldGenerateGLError(context, context.NO_ERROR, "context.drawArrays(context.TRIANGLES, 100, 0)");
    75 shouldGenerateGLError(context, context.INVALID_VALUE, "context.drawArrays(context.TRIANGLES, 1, -1)");
    76 shouldGenerateGLError(context, context.INVALID_VALUE, "context.drawArrays(context.TRIANGLES, -1, 1)");
    78 debug("")
    79 debug("Test buffer with interleaved (3+2) float vectors")
    81 var program2 = createProgram(context,
    82                              "attribute vec3 aOne;" +
    83                              "attribute vec2 aTwo;" +
    84                              "void main() { gl_Position = vec4(aOne, 1.0) + vec4(aTwo, 0.0, 1.0); }",
    85                              "void main() { gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0); }",
    86                              [ "aOne", "aTwo" ]);
    87 if (!program2) {
    88     testFailed("failed to create test program");
    89 }
    91 context.useProgram(program2);
    93 var vbo = context.createBuffer();
    94 context.bindBuffer(context.ARRAY_BUFFER, vbo);
    95 // enough for 9 vertices, so 3 triangles
    96 context.bufferData(context.ARRAY_BUFFER, new Float32Array(9*5), context.STATIC_DRAW);
    98 // bind first 3 elements, with a stride of 5 float elements
    99 context.vertexAttribPointer(0, 3, context.FLOAT, false, 5*4, 0);
   100 // bind 2 elements, starting after the first 3; same stride of 5 float elements
   101 context.vertexAttribPointer(1, 2, context.FLOAT, false, 5*4, 3*4);
   103 context.enableVertexAttribArray(0);
   104 context.enableVertexAttribArray(1);
   106 shouldGenerateGLError(context, context.NO_ERROR, "context.drawArrays(context.TRIANGLES, 0, 9)");
   108 // negative values must generate INVALID_VALUE; they can never be valid
   109 shouldGenerateGLError(context, context.INVALID_VALUE, "context.drawArrays(context.TRIANGLES, 0, -500)");
   110 shouldGenerateGLError(context, context.INVALID_VALUE, "context.drawArrays(context.TRIANGLES, -200, 1)");
   111 shouldGenerateGLError(context, context.INVALID_VALUE, "context.drawArrays(context.TRIANGLES, -200, -500)");
   113 // 0xffffffff needs to convert to a 'long' IDL argument as -1, as per
   114 // WebIDL 4.1.7.  JS ToInt32(0xffffffff) == -1, which is the first step
   115 // of the conversion.  Thus INVALID_VALUE.
   116 shouldGenerateGLError(context, context.INVALID_VALUE, "context.drawArrays(context.TRIANGLES, 0, 0xffffffff)");
   117 shouldGenerateGLError(context, context.INVALID_VALUE, "context.drawArrays(context.TRIANGLES, 0xffffffff, 1)");
   118 shouldGenerateGLError(context, context.INVALID_VALUE, "context.drawArrays(context.TRIANGLES, 0xffffffff, 0xffffffff)");
   120 // values that could otherwise be valid but aren't due to bindings generate
   121 // INVALID_OPERATION
   122 shouldGenerateGLError(context, context.INVALID_OPERATION, "context.drawArrays(context.TRIANGLES, 0, 200)");
   123 shouldGenerateGLError(context, context.INVALID_OPERATION, "context.drawArrays(context.TRIANGLES, 0, 0x7fffffff)");
   124 shouldGenerateGLError(context, context.INVALID_OPERATION, "context.drawArrays(context.TRIANGLES, 0x7fffffff, 1)");
   125 shouldGenerateGLError(context, context.INVALID_OPERATION, "context.drawArrays(context.TRIANGLES, 0x7fffffff, 0x7fffffff)");
   127 debug("")
   128 successfullyParsed = true;
   129 </script>
   131 <script>finishTest();</script>
   132 </body>
   133 </html>

mercurial