content/canvas/test/webgl-conformance/conformance/misc/bad-arguments-test.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 <script src="../resources/webgl-test-utils.js"></script>
    33 </head>
    34 <body>
    35 <div id="description"></div>
    36 <div id="console"></div>
    38 <script>
    39 var wtu = WebGLTestUtils;
    40 description("Tests calling WebGL APIs with wrong argument types");
    42 var context = wtu.create3DContext();
    43 var program = wtu.loadStandardProgram(context);
    44 var shader = wtu.loadStandardVertexShader(context);
    45 var shouldGenerateGLError = wtu.shouldGenerateGLError;
    47 assertMsg(program != null, "Program Compiled");
    48 assertMsg(shader != null, "Shader Compiled");
    50 var loc = context.getUniformLocation(program, "u_modelViewProjMatrix");
    51 assertMsg(loc != null, "getUniformLocation succeeded");
    53 var arguments = [
    54   { value: "foo",
    55     throws: true },
    56   { value: 0,
    57     throws: true },
    58   { value: null,
    59     throws: false },
    60   { value: undefined,
    61     throws: false }
    62 ];
    64 var argument;
    66 function shouldBeEmptyString(command) {
    67   shouldBe(command, "''");
    68 }
    70 for (var i = 0; i < arguments.length; ++i) {
    71   var func, func2, func3;
    72   if (arguments[i].throws) {
    73     func = shouldThrow;
    74     func2 = shouldThrow;
    75     func3 = shouldThrow;
    76   } else {
    77     func = shouldBeUndefined;
    78     func2 = shouldBeNull;
    79     func3 = shouldBeEmptyString;
    80   }
    81   argument = arguments[i].value;
    82   func("context.compileShader(argument)");
    83   func("context.linkProgram(argument)");
    84   func("context.attachShader(program, argument)");
    85   func("context.attachShader(argument, shader)");
    86   func("context.detachShader(program, argument)");
    87   func("context.detachShader(argument, shader)");
    88   func("context.useProgram(argument)");
    89   func("context.shaderSource(argument, 'foo')");
    90   func("context.bindAttribLocation(argument, 0, 'foo')");
    91   func("context.bindBuffer(context.ARRAY_BUFFER, argument)");
    92   func("context.bindFramebuffer(context.FRAMEBUFFER, argument)");
    93   func("context.bindRenderbuffer(context.RENDERBUFFER, argument)");
    94   func("context.bindTexture(context.TEXTURE_2D, argument)");
    95   func("context.framebufferRenderbuffer(context.FRAMEBUFFER, context.DEPTH_ATTACHMENT, context.RENDERBUFFER, argument)");
    96   func("context.framebufferTexture2D(context.FRAMEBUFFER, context.COLOR_ATTACHMENT0, context.TEXTURE_2D, argument, 0)");
    97   func("context.uniform2fv(argument, new Float32Array([0.0, 0.0]))");
    98   func("context.uniform2iv(argument, new Int32Array([0, 0]))");
    99   func("context.uniformMatrix2fv(argument, false, new Float32Array([0.0, 0.0, 0.0, 0.0]))");
   101   func2("context.getProgramParameter(argument, 0)");
   102   func2("context.getShaderParameter(argument, 0)");
   103   func2("context.getUniform(argument, loc)");
   104   func2("context.getUniform(program, argument)");
   105   func2("context.getUniformLocation(argument, 'u_modelViewProjMatrix')");
   107   func3("context.getProgramInfoLog(argument)");
   108   func3("context.getShaderInfoLog(argument)");
   109   func3("context.getShaderSource(argument)");
   110 }
   112 successfullyParsed = true;
   113 </script>
   115 <script>finishTest();</script>
   116 </body>
   117 </html>

mercurial