OLD | NEW |
(Empty) | |
| 1 <!-- |
| 2 |
| 3 /* |
| 4 ** Copyright (c) 2012 The Khronos Group Inc. |
| 5 ** |
| 6 ** Permission is hereby granted, free of charge, to any person obtaining a |
| 7 ** copy of this software and/or associated documentation files (the |
| 8 ** "Materials"), to deal in the Materials without restriction, including |
| 9 ** without limitation the rights to use, copy, modify, merge, publish, |
| 10 ** distribute, sublicense, and/or sell copies of the Materials, and to |
| 11 ** permit persons to whom the Materials are furnished to do so, subject to |
| 12 ** the following conditions: |
| 13 ** |
| 14 ** The above copyright notice and this permission notice shall be included |
| 15 ** in all copies or substantial portions of the Materials. |
| 16 ** |
| 17 ** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, |
| 18 ** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF |
| 19 ** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. |
| 20 ** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY |
| 21 ** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, |
| 22 ** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE |
| 23 ** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. |
| 24 */ |
| 25 |
| 26 --> |
| 27 |
| 28 <!DOCTYPE html> |
| 29 <html> |
| 30 <head> |
| 31 <meta charset="utf-8"> |
| 32 <link rel="stylesheet" href="../../resources/js-test-style.css"/> |
| 33 <script src="../../resources/js-test-pre.js"></script> |
| 34 <script src="../resources/webgl-test.js"></script> |
| 35 <script src="../resources/webgl-test-utils.js"></script> |
| 36 </head> |
| 37 <body> |
| 38 <div id="description"></div> |
| 39 <div id="console"></div> |
| 40 |
| 41 <script> |
| 42 "use strict"; |
| 43 var wtu = WebGLTestUtils; |
| 44 description("Tests calling WebGL APIs without providing the necessary objects"); |
| 45 |
| 46 var context = wtu.create3DContext(); |
| 47 var program = wtu.loadStandardProgram(context); |
| 48 var shader = wtu.loadStandardVertexShader(context); |
| 49 var shouldGenerateGLError = wtu.shouldGenerateGLError; |
| 50 |
| 51 assertMsg(program != null, "Program Compiled"); |
| 52 assertMsg(shader != null, "Shader Compiled"); |
| 53 shouldGenerateGLError(context, context.INVALID_VALUE, "context.compileShader(und
efined)"); |
| 54 shouldGenerateGLError(context, context.INVALID_VALUE, "context.linkProgram(undef
ined)"); |
| 55 shouldGenerateGLError(context, context.INVALID_VALUE, "context.attachShader(unde
fined, undefined)"); |
| 56 shouldGenerateGLError(context, context.INVALID_VALUE, "context.attachShader(prog
ram, undefined)"); |
| 57 shouldGenerateGLError(context, context.INVALID_VALUE, "context.attachShader(unde
fined, shader)"); |
| 58 shouldGenerateGLError(context, context.INVALID_VALUE, "context.detachShader(prog
ram, undefined)"); |
| 59 shouldGenerateGLError(context, context.INVALID_VALUE, "context.detachShader(unde
fined, shader)"); |
| 60 shouldGenerateGLError(context, context.INVALID_VALUE, "context.shaderSource(unde
fined, undefined)"); |
| 61 shouldGenerateGLError(context, context.INVALID_VALUE, "context.shaderSource(unde
fined, 'foo')"); |
| 62 shouldGenerateGLError(context, context.INVALID_VALUE, "context.bindAttribLocatio
n(undefined, 0, 'foo')"); |
| 63 shouldThrow("context.bindBuffer(context.ARRAY_BUFFER, 0)"); |
| 64 shouldThrow("context.bindFramebuffer(context.FRAMEBUFFER, 0)"); |
| 65 shouldThrow("context.bindRenderbuffer(context.RENDERBUFFER, 0)"); |
| 66 shouldThrow("context.bindTexture(context.TEXTURE_2D, 0)"); |
| 67 shouldGenerateGLError(context, context.NO_ERROR, "context.bindBuffer(context.ARR
AY_BUFFER, null)"); |
| 68 shouldGenerateGLError(context, context.NO_ERROR, "context.bindFramebuffer(contex
t.FRAMEBUFFER, null)"); |
| 69 shouldGenerateGLError(context, context.NO_ERROR, "context.bindRenderbuffer(conte
xt.RENDERBUFFER, null)"); |
| 70 shouldGenerateGLError(context, context.NO_ERROR, "context.bindTexture(context.TE
XTURE_2D, null)"); |
| 71 shouldGenerateGLError(context, context.NO_ERROR, "context.bindBuffer(context.ARR
AY_BUFFER, undefined)"); |
| 72 shouldGenerateGLError(context, context.NO_ERROR, "context.bindFramebuffer(contex
t.FRAMEBUFFER, undefined)"); |
| 73 shouldGenerateGLError(context, context.NO_ERROR, "context.bindRenderbuffer(conte
xt.RENDERBUFFER, undefined)"); |
| 74 shouldGenerateGLError(context, context.NO_ERROR, "context.bindTexture(context.TE
XTURE_2D, undefined)"); |
| 75 shouldGenerateGLError(context, context.INVALID_OPERATION, "context.framebufferRe
nderbuffer(context.FRAMEBUFFER, context.DEPTH_ATTACHMENT, context.RENDERBUFFER,
null)"); |
| 76 shouldGenerateGLError(context, context.INVALID_OPERATION, "context.framebufferTe
xture2D(context.FRAMEBUFFER, context.COLOR_ATTACHMENT0, context.TEXTURE_2D, null
, 0)"); |
| 77 shouldGenerateGLError(context, context.INVALID_VALUE, "context.getProgramParamet
er(undefined, 0)"); |
| 78 shouldGenerateGLError(context, context.INVALID_VALUE, "context.getProgramInfoLog
(undefined, 0)"); |
| 79 shouldGenerateGLError(context, context.INVALID_VALUE, "context.getShaderParamete
r(undefined, 0)"); |
| 80 shouldGenerateGLError(context, context.INVALID_VALUE, "context.getShaderInfoLog(
undefined, 0)"); |
| 81 shouldGenerateGLError(context, context.INVALID_VALUE, "context.getShaderSource(u
ndefined)"); |
| 82 shouldGenerateGLError(context, context.INVALID_VALUE, "context.getUniform(undefi
ned, null)"); |
| 83 shouldGenerateGLError(context, context.INVALID_VALUE, "context.getUniformLocatio
n(undefined, 'foo')"); |
| 84 |
| 85 debug(""); |
| 86 debug("check with bindings"); |
| 87 context.bindBuffer(context.ARRAY_BUFFER, context.createBuffer()); |
| 88 context.bindTexture(context.TEXTURE_2D, context.createTexture()); |
| 89 shouldGenerateGLError(context, context.NO_ERROR, "context.bufferData(context.ARR
AY_BUFFER, 1, context.STATIC_DRAW)"); |
| 90 shouldGenerateGLError(context, context.NO_ERROR, "context.getBufferParameter(con
text.ARRAY_BUFFER, context.BUFFER_SIZE)"); |
| 91 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]))"); |
| 92 shouldGenerateGLError(context, context.NO_ERROR, "context.texParameteri(context.
TEXTURE_2D, context.TEXTURE_MIN_FILTER, context.NEAREST)"); |
| 93 shouldGenerateGLError(context, context.NO_ERROR, "context.getTexParameter(contex
t.TEXTURE_2D, context.TEXTURE_MIN_FILTER)"); |
| 94 |
| 95 debug(""); |
| 96 debug("check without bindings"); |
| 97 context.bindBuffer(context.ARRAY_BUFFER, null); |
| 98 context.bindTexture(context.TEXTURE_2D, null); |
| 99 shouldGenerateGLError(context, context.INVALID_OPERATION, "context.bufferData(co
ntext.ARRAY_BUFFER, 1, context.STATIC_DRAW)"); |
| 100 shouldGenerateGLError(context, context.INVALID_OPERATION, "context.getBufferPara
meter(context.ARRAY_BUFFER, context.BUFFER_SIZE)"); |
| 101 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]))"); |
| 102 shouldGenerateGLError(context, context.INVALID_OPERATION, "context.texParameteri
(context.TEXTURE_2D, context.TEXTURE_MIN_FILTER, context.NEAREST)"); |
| 103 shouldGenerateGLError(context, context.INVALID_OPERATION, "context.getTexParamet
er(context.TEXTURE_2D, context.TEXTURE_MIN_FILTER)"); |
| 104 |
| 105 |
| 106 var successfullyParsed = true; |
| 107 </script> |
| 108 |
| 109 <script src="../../resources/js-test-post.js"></script> |
| 110 </body> |
| 111 </html> |
OLD | NEW |