OLD | NEW |
(Empty) | |
| 1 <!-- |
| 2 Copyright (C) 2011 Apple Computer, Inc. All rights reserved. |
| 3 |
| 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. |
| 12 |
| 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> |
| 37 |
| 38 <script> |
| 39 var wtu = WebGLTestUtils; |
| 40 description("Tests calling WebGL APIs without providing the necessary objects"); |
| 41 |
| 42 var context = wtu.create3DContext(); |
| 43 var program = wtu.loadStandardProgram(context); |
| 44 var shader = wtu.loadStandardVertexShader(context); |
| 45 var shouldGenerateGLError = wtu.shouldGenerateGLError; |
| 46 |
| 47 assertMsg(program != null, "Program Compiled"); |
| 48 assertMsg(shader != null, "Shader Compiled"); |
| 49 shouldGenerateGLError(context, context.INVALID_VALUE, "context.compileShader(und
efined)"); |
| 50 shouldGenerateGLError(context, context.INVALID_VALUE, "context.linkProgram(undef
ined)"); |
| 51 shouldGenerateGLError(context, context.INVALID_VALUE, "context.attachShader(unde
fined, undefined)"); |
| 52 shouldGenerateGLError(context, context.INVALID_VALUE, "context.attachShader(prog
ram, undefined)"); |
| 53 shouldGenerateGLError(context, context.INVALID_VALUE, "context.attachShader(unde
fined, shader)"); |
| 54 shouldGenerateGLError(context, context.INVALID_VALUE, "context.detachShader(prog
ram, undefined)"); |
| 55 shouldGenerateGLError(context, context.INVALID_VALUE, "context.detachShader(unde
fined, shader)"); |
| 56 shouldGenerateGLError(context, context.INVALID_VALUE, "context.shaderSource(unde
fined, undefined)"); |
| 57 shouldGenerateGLError(context, context.INVALID_VALUE, "context.shaderSource(unde
fined, 'foo')"); |
| 58 shouldGenerateGLError(context, context.INVALID_VALUE, "context.bindAttribLocatio
n(undefined, 0, 'foo')"); |
| 59 shouldThrow("context.bindBuffer(context.ARRAY_BUFFER, 0)"); |
| 60 shouldThrow("context.bindFramebuffer(context.FRAMEBUFFER, 0)"); |
| 61 shouldThrow("context.bindRenderbuffer(context.RENDERBUFFER, 0)"); |
| 62 shouldThrow("context.bindTexture(context.TEXTURE_2D, 0)"); |
| 63 shouldGenerateGLError(context, context.NO_ERROR, "context.bindBuffer(context.ARR
AY_BUFFER, null)"); |
| 64 shouldGenerateGLError(context, context.NO_ERROR, "context.bindFramebuffer(contex
t.FRAMEBUFFER, null)"); |
| 65 shouldGenerateGLError(context, context.NO_ERROR, "context.bindRenderbuffer(conte
xt.RENDERBUFFER, null)"); |
| 66 shouldGenerateGLError(context, context.NO_ERROR, "context.bindTexture(context.TE
XTURE_2D, null)"); |
| 67 shouldGenerateGLError(context, context.NO_ERROR, "context.bindBuffer(context.ARR
AY_BUFFER, undefined)"); |
| 68 shouldGenerateGLError(context, context.NO_ERROR, "context.bindFramebuffer(contex
t.FRAMEBUFFER, undefined)"); |
| 69 shouldGenerateGLError(context, context.NO_ERROR, "context.bindRenderbuffer(conte
xt.RENDERBUFFER, undefined)"); |
| 70 shouldGenerateGLError(context, context.NO_ERROR, "context.bindTexture(context.TE
XTURE_2D, undefined)"); |
| 71 shouldGenerateGLError(context, context.INVALID_OPERATION, "context.framebufferRe
nderbuffer(context.FRAMEBUFFER, context.DEPTH_ATTACHMENT, context.RENDERBUFFER,
null)"); |
| 72 shouldGenerateGLError(context, context.INVALID_OPERATION, "context.framebufferTe
xture2D(context.FRAMEBUFFER, context.COLOR_ATTACHMENT0, context.TEXTURE_2D, null
, 0)"); |
| 73 shouldGenerateGLError(context, context.INVALID_VALUE, "context.getProgramParamet
er(undefined, 0)"); |
| 74 shouldGenerateGLError(context, context.INVALID_VALUE, "context.getProgramInfoLog
(undefined, 0)"); |
| 75 shouldGenerateGLError(context, context.INVALID_VALUE, "context.getShaderParamete
r(undefined, 0)"); |
| 76 shouldGenerateGLError(context, context.INVALID_VALUE, "context.getShaderInfoLog(
undefined, 0)"); |
| 77 shouldGenerateGLError(context, context.INVALID_VALUE, "context.getShaderSource(u
ndefined)"); |
| 78 shouldGenerateGLError(context, context.INVALID_VALUE, "context.getUniform(undefi
ned, null)"); |
| 79 shouldGenerateGLError(context, context.INVALID_VALUE, "context.getUniformLocatio
n(undefined, 'foo')"); |
| 80 |
| 81 debug(""); |
| 82 debug("check with bindings"); |
| 83 context.bindBuffer(context.ARRAY_BUFFER, context.createBuffer()); |
| 84 context.bindTexture(context.TEXTURE_2D, context.createTexture()); |
| 85 shouldGenerateGLError(context, context.NO_ERROR, "context.bufferData(context.ARR
AY_BUFFER, 1, context.STATIC_DRAW)"); |
| 86 shouldGenerateGLError(context, context.NO_ERROR, "context.getBufferParameter(con
text.ARRAY_BUFFER, context.BUFFER_SIZE)"); |
| 87 shouldGenerateGLError(context, context.NO_ERROR, "context.texImage2D(context.TEX
TURE_2D, 0, context.RGBA, 1, 1, 0, context.RGBA, context.UNSIGNED_BYTE, new Uint
8Array([0,0,0,0]))"); |
| 88 shouldGenerateGLError(context, context.NO_ERROR, "context.texParameteri(context.
TEXTURE_2D, context.TEXTURE_MIN_FILTER, context.NEAREST)"); |
| 89 shouldGenerateGLError(context, context.NO_ERROR, "context.getTexParameter(contex
t.TEXTURE_2D, context.TEXTURE_MIN_FILTER)"); |
| 90 |
| 91 debug(""); |
| 92 debug("check without bindings"); |
| 93 context.bindBuffer(context.ARRAY_BUFFER, null); |
| 94 context.bindTexture(context.TEXTURE_2D, null); |
| 95 shouldGenerateGLError(context, context.INVALID_OPERATION, "context.bufferData(co
ntext.ARRAY_BUFFER, 1, context.STATIC_DRAW)"); |
| 96 shouldGenerateGLError(context, context.INVALID_OPERATION, "context.getBufferPara
meter(context.ARRAY_BUFFER, context.BUFFER_SIZE)"); |
| 97 shouldGenerateGLError(context, context.INVALID_OPERATION, "context.texImage2D(co
ntext.TEXTURE_2D, 0, context.RGBA, 1, 1, 0, context.RGBA, context.UNSIGNED_BYTE,
new Uint8Array([0,0,0,0]))"); |
| 98 shouldGenerateGLError(context, context.INVALID_OPERATION, "context.texParameteri
(context.TEXTURE_2D, context.TEXTURE_MIN_FILTER, context.NEAREST)"); |
| 99 shouldGenerateGLError(context, context.INVALID_OPERATION, "context.getTexParamet
er(context.TEXTURE_2D, context.TEXTURE_MIN_FILTER)"); |
| 100 |
| 101 |
| 102 successfullyParsed = true; |
| 103 </script> |
| 104 |
| 105 <script src="../../resources/js-test-post.js"></script> |
| 106 </body> |
| 107 </html> |
OLD | NEW |