content/canvas/test/webgl-conformance/conformance/misc/null-object-behaviour.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/misc/null-object-behaviour.html	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,107 @@
     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 without providing the necessary objects");
    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 +shouldGenerateGLError(context, context.INVALID_VALUE, "context.compileShader(undefined)");
    1.53 +shouldGenerateGLError(context, context.INVALID_VALUE, "context.linkProgram(undefined)");
    1.54 +shouldGenerateGLError(context, context.INVALID_VALUE, "context.attachShader(undefined, undefined)");
    1.55 +shouldGenerateGLError(context, context.INVALID_VALUE, "context.attachShader(program, undefined)");
    1.56 +shouldGenerateGLError(context, context.INVALID_VALUE, "context.attachShader(undefined, shader)");
    1.57 +shouldGenerateGLError(context, context.INVALID_VALUE, "context.detachShader(program, undefined)");
    1.58 +shouldGenerateGLError(context, context.INVALID_VALUE, "context.detachShader(undefined, shader)");
    1.59 +shouldGenerateGLError(context, context.INVALID_VALUE, "context.shaderSource(undefined, undefined)");
    1.60 +shouldGenerateGLError(context, context.INVALID_VALUE, "context.shaderSource(undefined, 'foo')");
    1.61 +shouldGenerateGLError(context, context.INVALID_VALUE, "context.bindAttribLocation(undefined, 0, 'foo')");
    1.62 +shouldThrow("context.bindBuffer(context.ARRAY_BUFFER, 0)");
    1.63 +shouldThrow("context.bindFramebuffer(context.FRAMEBUFFER, 0)");
    1.64 +shouldThrow("context.bindRenderbuffer(context.RENDERBUFFER, 0)");
    1.65 +shouldThrow("context.bindTexture(context.TEXTURE_2D, 0)");
    1.66 +shouldGenerateGLError(context, context.NO_ERROR, "context.bindBuffer(context.ARRAY_BUFFER, null)");
    1.67 +shouldGenerateGLError(context, context.NO_ERROR, "context.bindFramebuffer(context.FRAMEBUFFER, null)");
    1.68 +shouldGenerateGLError(context, context.NO_ERROR, "context.bindRenderbuffer(context.RENDERBUFFER, null)");
    1.69 +shouldGenerateGLError(context, context.NO_ERROR, "context.bindTexture(context.TEXTURE_2D, null)");
    1.70 +shouldGenerateGLError(context, context.NO_ERROR, "context.bindBuffer(context.ARRAY_BUFFER, undefined)");
    1.71 +shouldGenerateGLError(context, context.NO_ERROR, "context.bindFramebuffer(context.FRAMEBUFFER, undefined)");
    1.72 +shouldGenerateGLError(context, context.NO_ERROR, "context.bindRenderbuffer(context.RENDERBUFFER, undefined)");
    1.73 +shouldGenerateGLError(context, context.NO_ERROR, "context.bindTexture(context.TEXTURE_2D, undefined)");
    1.74 +shouldGenerateGLError(context, context.INVALID_OPERATION, "context.framebufferRenderbuffer(context.FRAMEBUFFER, context.DEPTH_ATTACHMENT, context.RENDERBUFFER, null)");
    1.75 +shouldGenerateGLError(context, context.INVALID_OPERATION, "context.framebufferTexture2D(context.FRAMEBUFFER, context.COLOR_ATTACHMENT0, context.TEXTURE_2D, null, 0)");
    1.76 +shouldGenerateGLError(context, context.INVALID_VALUE, "context.getProgramParameter(undefined, 0)");
    1.77 +shouldGenerateGLError(context, context.INVALID_VALUE, "context.getProgramInfoLog(undefined, 0)");
    1.78 +shouldGenerateGLError(context, context.INVALID_VALUE, "context.getShaderParameter(undefined, 0)");
    1.79 +shouldGenerateGLError(context, context.INVALID_VALUE, "context.getShaderInfoLog(undefined, 0)");
    1.80 +shouldGenerateGLError(context, context.INVALID_VALUE, "context.getShaderSource(undefined)");
    1.81 +shouldGenerateGLError(context, context.INVALID_VALUE, "context.getUniform(undefined, null)");
    1.82 +shouldGenerateGLError(context, context.INVALID_VALUE, "context.getUniformLocation(undefined, 'foo')");
    1.83 +
    1.84 +debug("");
    1.85 +debug("check with bindings");
    1.86 +context.bindBuffer(context.ARRAY_BUFFER, context.createBuffer());
    1.87 +context.bindTexture(context.TEXTURE_2D, context.createTexture());
    1.88 +shouldGenerateGLError(context, context.NO_ERROR, "context.bufferData(context.ARRAY_BUFFER, 1, context.STATIC_DRAW)");
    1.89 +shouldGenerateGLError(context, context.NO_ERROR, "context.getBufferParameter(context.ARRAY_BUFFER, context.BUFFER_SIZE)");
    1.90 +shouldGenerateGLError(context, context.NO_ERROR, "context.texImage2D(context.TEXTURE_2D, 0, context.RGBA, 1, 1, 0, context.RGBA, context.UNSIGNED_BYTE, new Uint8Array([0,0,0,0]))");
    1.91 +shouldGenerateGLError(context, context.NO_ERROR, "context.texParameteri(context.TEXTURE_2D, context.TEXTURE_MIN_FILTER, context.NEAREST)");
    1.92 +shouldGenerateGLError(context, context.NO_ERROR, "context.getTexParameter(context.TEXTURE_2D, context.TEXTURE_MIN_FILTER)");
    1.93 +
    1.94 +debug("");
    1.95 +debug("check without bindings");
    1.96 +context.bindBuffer(context.ARRAY_BUFFER, null);
    1.97 +context.bindTexture(context.TEXTURE_2D, null);
    1.98 +shouldGenerateGLError(context, context.INVALID_OPERATION, "context.bufferData(context.ARRAY_BUFFER, 1, context.STATIC_DRAW)");
    1.99 +shouldGenerateGLError(context, context.INVALID_OPERATION, "context.getBufferParameter(context.ARRAY_BUFFER, context.BUFFER_SIZE)");
   1.100 +shouldGenerateGLError(context, context.INVALID_OPERATION, "context.texImage2D(context.TEXTURE_2D, 0, context.RGBA, 1, 1, 0, context.RGBA, context.UNSIGNED_BYTE, new Uint8Array([0,0,0,0]))");
   1.101 +shouldGenerateGLError(context, context.INVALID_OPERATION, "context.texParameteri(context.TEXTURE_2D, context.TEXTURE_MIN_FILTER, context.NEAREST)");
   1.102 +shouldGenerateGLError(context, context.INVALID_OPERATION, "context.getTexParameter(context.TEXTURE_2D, context.TEXTURE_MIN_FILTER)");
   1.103 +
   1.104 +
   1.105 +successfullyParsed = true;
   1.106 +</script>
   1.107 +
   1.108 +<script>finishTest();</script>
   1.109 +</body>
   1.110 +</html>

mercurial