1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/content/canvas/test/webgl-conformance/conformance/misc/bad-arguments-test.html Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,117 @@ 1.4 +<!-- 1.5 +Copyright (C) 2011 Apple Computer, Inc. All rights reserved. 1.6 + 1.7 +Redistribution and use in source and binary forms, with or without 1.8 +modification, are permitted provided that the following conditions 1.9 +are met: 1.10 +1. Redistributions of source code must retain the above copyright 1.11 + notice, this list of conditions and the following disclaimer. 1.12 +2. Redistributions in binary form must reproduce the above copyright 1.13 + notice, this list of conditions and the following disclaimer in the 1.14 + documentation and/or other materials provided with the distribution. 1.15 + 1.16 +THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY 1.17 +EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 1.18 +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 1.19 +PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR 1.20 +CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 1.21 +EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 1.22 +PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 1.23 +PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY 1.24 +OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 1.25 +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 1.26 +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 1.27 +--> 1.28 +<!DOCTYPE html> 1.29 +<html> 1.30 +<head> 1.31 +<meta charset="utf-8"> 1.32 +<link rel="stylesheet" href="../../resources/js-test-style.css"/> 1.33 +<script src="../../resources/js-test-pre.js"></script> 1.34 +<script src="../resources/webgl-test.js"></script> 1.35 +<script src="../resources/webgl-test-utils.js"></script> 1.36 +</head> 1.37 +<body> 1.38 +<div id="description"></div> 1.39 +<div id="console"></div> 1.40 + 1.41 +<script> 1.42 +var wtu = WebGLTestUtils; 1.43 +description("Tests calling WebGL APIs with wrong argument types"); 1.44 + 1.45 +var context = wtu.create3DContext(); 1.46 +var program = wtu.loadStandardProgram(context); 1.47 +var shader = wtu.loadStandardVertexShader(context); 1.48 +var shouldGenerateGLError = wtu.shouldGenerateGLError; 1.49 + 1.50 +assertMsg(program != null, "Program Compiled"); 1.51 +assertMsg(shader != null, "Shader Compiled"); 1.52 + 1.53 +var loc = context.getUniformLocation(program, "u_modelViewProjMatrix"); 1.54 +assertMsg(loc != null, "getUniformLocation succeeded"); 1.55 + 1.56 +var arguments = [ 1.57 + { value: "foo", 1.58 + throws: true }, 1.59 + { value: 0, 1.60 + throws: true }, 1.61 + { value: null, 1.62 + throws: false }, 1.63 + { value: undefined, 1.64 + throws: false } 1.65 +]; 1.66 + 1.67 +var argument; 1.68 + 1.69 +function shouldBeEmptyString(command) { 1.70 + shouldBe(command, "''"); 1.71 +} 1.72 + 1.73 +for (var i = 0; i < arguments.length; ++i) { 1.74 + var func, func2, func3; 1.75 + if (arguments[i].throws) { 1.76 + func = shouldThrow; 1.77 + func2 = shouldThrow; 1.78 + func3 = shouldThrow; 1.79 + } else { 1.80 + func = shouldBeUndefined; 1.81 + func2 = shouldBeNull; 1.82 + func3 = shouldBeEmptyString; 1.83 + } 1.84 + argument = arguments[i].value; 1.85 + func("context.compileShader(argument)"); 1.86 + func("context.linkProgram(argument)"); 1.87 + func("context.attachShader(program, argument)"); 1.88 + func("context.attachShader(argument, shader)"); 1.89 + func("context.detachShader(program, argument)"); 1.90 + func("context.detachShader(argument, shader)"); 1.91 + func("context.useProgram(argument)"); 1.92 + func("context.shaderSource(argument, 'foo')"); 1.93 + func("context.bindAttribLocation(argument, 0, 'foo')"); 1.94 + func("context.bindBuffer(context.ARRAY_BUFFER, argument)"); 1.95 + func("context.bindFramebuffer(context.FRAMEBUFFER, argument)"); 1.96 + func("context.bindRenderbuffer(context.RENDERBUFFER, argument)"); 1.97 + func("context.bindTexture(context.TEXTURE_2D, argument)"); 1.98 + func("context.framebufferRenderbuffer(context.FRAMEBUFFER, context.DEPTH_ATTACHMENT, context.RENDERBUFFER, argument)"); 1.99 + func("context.framebufferTexture2D(context.FRAMEBUFFER, context.COLOR_ATTACHMENT0, context.TEXTURE_2D, argument, 0)"); 1.100 + func("context.uniform2fv(argument, new Float32Array([0.0, 0.0]))"); 1.101 + func("context.uniform2iv(argument, new Int32Array([0, 0]))"); 1.102 + func("context.uniformMatrix2fv(argument, false, new Float32Array([0.0, 0.0, 0.0, 0.0]))"); 1.103 + 1.104 + func2("context.getProgramParameter(argument, 0)"); 1.105 + func2("context.getShaderParameter(argument, 0)"); 1.106 + func2("context.getUniform(argument, loc)"); 1.107 + func2("context.getUniform(program, argument)"); 1.108 + func2("context.getUniformLocation(argument, 'u_modelViewProjMatrix')"); 1.109 + 1.110 + func3("context.getProgramInfoLog(argument)"); 1.111 + func3("context.getShaderInfoLog(argument)"); 1.112 + func3("context.getShaderSource(argument)"); 1.113 +} 1.114 + 1.115 +successfullyParsed = true; 1.116 +</script> 1.117 + 1.118 +<script>finishTest();</script> 1.119 +</body> 1.120 +</html>