Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
michael@0 | 1 | <!-- |
michael@0 | 2 | Copyright (C) 2011 Apple Computer, Inc. All rights reserved. |
michael@0 | 3 | |
michael@0 | 4 | Redistribution and use in source and binary forms, with or without |
michael@0 | 5 | modification, are permitted provided that the following conditions |
michael@0 | 6 | are met: |
michael@0 | 7 | 1. Redistributions of source code must retain the above copyright |
michael@0 | 8 | notice, this list of conditions and the following disclaimer. |
michael@0 | 9 | 2. Redistributions in binary form must reproduce the above copyright |
michael@0 | 10 | notice, this list of conditions and the following disclaimer in the |
michael@0 | 11 | documentation and/or other materials provided with the distribution. |
michael@0 | 12 | |
michael@0 | 13 | THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY |
michael@0 | 14 | EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
michael@0 | 15 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
michael@0 | 16 | PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR |
michael@0 | 17 | CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, |
michael@0 | 18 | EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, |
michael@0 | 19 | PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR |
michael@0 | 20 | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY |
michael@0 | 21 | OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
michael@0 | 22 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
michael@0 | 23 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
michael@0 | 24 | --> |
michael@0 | 25 | <!DOCTYPE html> |
michael@0 | 26 | <html> |
michael@0 | 27 | <head> |
michael@0 | 28 | <meta charset="utf-8"> |
michael@0 | 29 | <link rel="stylesheet" href="../../resources/js-test-style.css"/> |
michael@0 | 30 | <script src="../../resources/js-test-pre.js"></script> |
michael@0 | 31 | <script src="../resources/webgl-test.js"></script> |
michael@0 | 32 | <script src="../../resources/desktop-gl-constants.js"></script> |
michael@0 | 33 | </head> |
michael@0 | 34 | <body> |
michael@0 | 35 | <div id="description"></div> |
michael@0 | 36 | <div id="console"></div> |
michael@0 | 37 | |
michael@0 | 38 | <script> |
michael@0 | 39 | description("Test for invalid passed parameters"); |
michael@0 | 40 | |
michael@0 | 41 | var context = create3DContext(); |
michael@0 | 42 | |
michael@0 | 43 | debug(""); |
michael@0 | 44 | debug("Test createShader()"); |
michael@0 | 45 | shouldGenerateGLError(context, context.NO_ERROR, "context.createShader(context.FRAGMENT_SHADER)"); |
michael@0 | 46 | shouldGenerateGLError(context, context.NO_ERROR, "context.createShader(context.VERTEX_SHADER)"); |
michael@0 | 47 | shouldGenerateGLError(context, context.INVALID_ENUM, "context.createShader(0)"); |
michael@0 | 48 | shouldGenerateGLError(context, context.INVALID_ENUM, "context.createShader(context.TRIANGLES)"); |
michael@0 | 49 | |
michael@0 | 50 | debug(""); |
michael@0 | 51 | debug("Test clear()"); |
michael@0 | 52 | shouldGenerateGLError(context, context.INVALID_VALUE, "context.clear(desktopGL['ACCUM_BUFFER_BIT'])"); |
michael@0 | 53 | shouldGenerateGLError(context, context.INVALID_VALUE, "context.clear(desktopGL['ACCUM_BUFFER_BIT'] | context.COLOR_BUFFER_BIT)"); |
michael@0 | 54 | shouldGenerateGLError(context, context.INVALID_VALUE, "context.clear(desktopGL['ACCUM_BUFFER_BIT'] | context.COLOR_BUFFER_BIT | context.DEPTH_BUFFER_BIT | context.STENCIL_BUFFER_BIT)"); |
michael@0 | 55 | shouldGenerateGLError(context, context.NO_ERROR, "context.clear(context.COLOR_BUFFER_BIT | context.DEPTH_BUFFER_BIT | context.STENCIL_BUFFER_BIT)"); |
michael@0 | 56 | |
michael@0 | 57 | debug(""); |
michael@0 | 58 | debug("Test bufferData()"); |
michael@0 | 59 | var buffer = context.createBuffer(); |
michael@0 | 60 | shouldGenerateGLError(context, context.NO_ERROR, "context.bindBuffer(context.ARRAY_BUFFER, buffer)"); |
michael@0 | 61 | shouldGenerateGLError(context, context.NO_ERROR, "context.bufferData(context.ARRAY_BUFFER, 16, context.STREAM_DRAW)"); |
michael@0 | 62 | shouldGenerateGLError(context, context.NO_ERROR, "context.bufferData(context.ARRAY_BUFFER, 16, context.STATIC_DRAW)"); |
michael@0 | 63 | shouldGenerateGLError(context, context.NO_ERROR, "context.bufferData(context.ARRAY_BUFFER, 16, context.DYNAMIC_DRAW)"); |
michael@0 | 64 | shouldGenerateGLError(context, context.INVALID_ENUM, "context.bufferData(context.ARRAY_BUFFER, 16, desktopGL['STREAM_READ'])"); |
michael@0 | 65 | shouldGenerateGLError(context, context.INVALID_ENUM, "context.bufferData(context.ARRAY_BUFFER, 16, desktopGL['STREAM_COPY'])"); |
michael@0 | 66 | shouldGenerateGLError(context, context.INVALID_ENUM, "context.bufferData(context.ARRAY_BUFFER, 16, desktopGL['STATIC_READ'])"); |
michael@0 | 67 | shouldGenerateGLError(context, context.INVALID_ENUM, "context.bufferData(context.ARRAY_BUFFER, 16, desktopGL['STATIC_COPY'])"); |
michael@0 | 68 | shouldGenerateGLError(context, context.INVALID_ENUM, "context.bufferData(context.ARRAY_BUFFER, 16, desktopGL['DYNAMIC_READ'])"); |
michael@0 | 69 | shouldGenerateGLError(context, context.INVALID_ENUM, "context.bufferData(context.ARRAY_BUFFER, 16, desktopGL['DYNAMIC_COPY'])"); |
michael@0 | 70 | |
michael@0 | 71 | debug(""); |
michael@0 | 72 | debug("Test {copy}Tex{Sub}Image2D with negative offset/width/height"); |
michael@0 | 73 | var tex = context.createTexture(); |
michael@0 | 74 | var pixels = new Uint8Array(2 * 2 * 4); |
michael@0 | 75 | shouldGenerateGLError(context, context.NO_ERROR, "context.bindTexture(context.TEXTURE_2D, tex)"); |
michael@0 | 76 | shouldGenerateGLError(context, context.INVALID_VALUE, "context.texImage2D(context.TEXTURE_2D, 0, context.RGBA, -16, -16, 0, context.RGBA, context.UNSIGNED_BYTE, null)"); |
michael@0 | 77 | shouldGenerateGLError(context, context.NO_ERROR, "context.texImage2D(context.TEXTURE_2D, 0, context.RGBA, 16, 16, 0, context.RGBA, context.UNSIGNED_BYTE, null)"); |
michael@0 | 78 | shouldGenerateGLError(context, context.INVALID_VALUE, "context.texSubImage2D(context.TEXTURE_2D, 0, -1, -1, 2, 2, context.RGBA, context.UNSIGNED_BYTE, pixels)"); |
michael@0 | 79 | shouldGenerateGLError(context, context.INVALID_VALUE, "context.texSubImage2D(context.TEXTURE_2D, 0, 0, 0, -1, -1, context.RGBA, context.UNSIGNED_BYTE, pixels)"); |
michael@0 | 80 | shouldGenerateGLError(context, context.NO_ERROR, "context.texSubImage2D(context.TEXTURE_2D, 0, 0, 0, 2, 2, context.RGBA, context.UNSIGNED_BYTE, pixels)"); |
michael@0 | 81 | shouldGenerateGLError(context, context.INVALID_VALUE, "context.copyTexImage2D(context.TEXTURE_2D, 0, context.RGBA, 0, 0, -1, -1, 0)"); |
michael@0 | 82 | shouldGenerateGLError(context, context.NO_ERROR, "context.copyTexImage2D(context.TEXTURE_2D, 0, context.RGBA, 0, 0, 16, 16, 0)"); |
michael@0 | 83 | shouldGenerateGLError(context, context.INVALID_VALUE, "context.copyTexSubImage2D(context.TEXTURE_2D, 0, -1, -1, 0, 0, 2, 2)"); |
michael@0 | 84 | shouldGenerateGLError(context, context.INVALID_VALUE, "context.copyTexSubImage2D(context.TEXTURE_2D, 0, 0, 0, 0, 0, -1, -1)"); |
michael@0 | 85 | shouldGenerateGLError(context, context.NO_ERROR, "context.copyTexSubImage2D(context.TEXTURE_2D, 0, 0, 0, 0, 0, 2, 2)"); |
michael@0 | 86 | |
michael@0 | 87 | debug(""); |
michael@0 | 88 | debug("Test renderbufferStorage() with negative width/height"); |
michael@0 | 89 | var renderbuffer = context.createRenderbuffer(); |
michael@0 | 90 | shouldGenerateGLError(context, context.NO_ERROR, "context.bindRenderbuffer(context.RENDERBUFFER, renderbuffer)"); |
michael@0 | 91 | shouldGenerateGLError(context, context.INVALID_VALUE, "context.renderbufferStorage(context.RENDERBUFFER, context.RGBA4, -2, -2)"); |
michael@0 | 92 | shouldGenerateGLError(context, context.NO_ERROR, "context.renderbufferStorage(context.RENDERBUFFER, context.RGBA4, 16, 16)"); |
michael@0 | 93 | |
michael@0 | 94 | debug(""); |
michael@0 | 95 | debug("Test scissor() with negative width/height"); |
michael@0 | 96 | shouldGenerateGLError(context, context.INVALID_VALUE, "context.scissor(0, 0, -2, -2)"); |
michael@0 | 97 | shouldGenerateGLError(context, context.NO_ERROR, "context.scissor(0, 0, 16, 16)"); |
michael@0 | 98 | |
michael@0 | 99 | debug(""); |
michael@0 | 100 | debug("Test viewport() with negative width/height"); |
michael@0 | 101 | shouldGenerateGLError(context, context.INVALID_VALUE, "context.viewport(0, 0, -2, -2)"); |
michael@0 | 102 | shouldGenerateGLError(context, context.NO_ERROR, "context.viewport(0, 0, 16, 16)"); |
michael@0 | 103 | |
michael@0 | 104 | debug(""); |
michael@0 | 105 | debug("Set up a program to test invalid characters"); |
michael@0 | 106 | var invalidSet = ['"', '$', '`', '@', '\\', "'"]; |
michael@0 | 107 | var validUniformName = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_1234567890"; |
michael@0 | 108 | var validAttribName = "abcdefghijklmnopqrstuvwxyz_ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890"; |
michael@0 | 109 | function generateShaderSource(opt_invalidIdentifierChar, opt_invalidCommentChar) { |
michael@0 | 110 | var invalidIdentifierString = ""; |
michael@0 | 111 | var invalidCommentString = ""; |
michael@0 | 112 | if (opt_invalidIdentifierChar != undefined) { |
michael@0 | 113 | invalidIdentifierString += opt_invalidIdentifierChar; |
michael@0 | 114 | } |
michael@0 | 115 | if (opt_invalidCommentChar != undefined) { |
michael@0 | 116 | invalidCommentString += opt_invalidCommentChar; |
michael@0 | 117 | } |
michael@0 | 118 | return "uniform float " + validUniformName + invalidIdentifierString + ";\n" |
michael@0 | 119 | + "varying float " + validAttribName + ";\n" |
michael@0 | 120 | + "void main() {\n" |
michael@0 | 121 | + validAttribName + " = " + validUniformName + ";\n" |
michael@0 | 122 | + "gl_Position = vec4(0.0, 0.0, 0.0, 1.0); }\n"; |
michael@0 | 123 | + "//.+-/*%<>[](){}^|&~=!:;,?# " + invalidCommentString; |
michael@0 | 124 | } |
michael@0 | 125 | var vShader = context.createShader(context.VERTEX_SHADER); |
michael@0 | 126 | context.shaderSource(vShader, generateShaderSource()); |
michael@0 | 127 | context.compileShader(vShader); |
michael@0 | 128 | shouldBe("context.getError()", "context.NO_ERROR"); |
michael@0 | 129 | var fShader = context.createShader(context.FRAGMENT_SHADER); |
michael@0 | 130 | context.shaderSource(fShader, "precision mediump float;\n" |
michael@0 | 131 | + "varying float " + validAttribName + ";\n" |
michael@0 | 132 | + "void main() {\n" |
michael@0 | 133 | + "gl_FragColor = vec4(" + validAttribName + ", 0.0, 0.0, 1.0); }"); |
michael@0 | 134 | context.compileShader(fShader); |
michael@0 | 135 | shouldBe("context.getError()", "context.NO_ERROR"); |
michael@0 | 136 | var program = context.createProgram(); |
michael@0 | 137 | context.attachShader(program, vShader); |
michael@0 | 138 | context.attachShader(program, fShader); |
michael@0 | 139 | context.linkProgram(program); |
michael@0 | 140 | var linkStatus = context.getProgramParameter(program, context.LINK_STATUS); |
michael@0 | 141 | shouldBeTrue("linkStatus"); |
michael@0 | 142 | if (!linkStatus) |
michael@0 | 143 | debug(context.getProgramInfoLog(program)); |
michael@0 | 144 | shouldBe("context.getError()", "context.NO_ERROR"); |
michael@0 | 145 | context.bindAttribLocation(program, 1, validAttribName); |
michael@0 | 146 | shouldBe("context.getError()", "context.NO_ERROR"); |
michael@0 | 147 | context.getAttribLocation(program, validAttribName); |
michael@0 | 148 | shouldBe("context.getError()", "context.NO_ERROR"); |
michael@0 | 149 | context.getUniformLocation(program, validUniformName); |
michael@0 | 150 | shouldBe("context.getError()", "context.NO_ERROR"); |
michael@0 | 151 | |
michael@0 | 152 | debug(""); |
michael@0 | 153 | debug("Test shaderSource() with invalid characters"); |
michael@0 | 154 | for (var i = 0; i < invalidSet.length; ++i) { |
michael@0 | 155 | var validShaderSource = generateShaderSource(undefined, invalidSet[i]); |
michael@0 | 156 | context.shaderSource(vShader, validShaderSource); |
michael@0 | 157 | shouldBe("context.getError()", "context.NO_ERROR"); |
michael@0 | 158 | var invalidShaderSource = generateShaderSource(invalidSet[i], undefined); |
michael@0 | 159 | context.shaderSource(vShader, invalidShaderSource); |
michael@0 | 160 | shouldBe("context.getError()", "context.INVALID_VALUE"); |
michael@0 | 161 | } |
michael@0 | 162 | |
michael@0 | 163 | debug(""); |
michael@0 | 164 | debug("Test bindAttribLocation() with invalid characters"); |
michael@0 | 165 | for (var i = 0; i < invalidSet.length; ++i) { |
michael@0 | 166 | var invalidName = validAttribName + invalidSet[i]; |
michael@0 | 167 | context.bindAttribLocation(program, 1, invalidName); |
michael@0 | 168 | shouldBe("context.getError()", "context.INVALID_VALUE"); |
michael@0 | 169 | } |
michael@0 | 170 | |
michael@0 | 171 | debug(""); |
michael@0 | 172 | debug("Test getAttribLocation() with invalid characters"); |
michael@0 | 173 | for (var i = 0; i < invalidSet.length; ++i) { |
michael@0 | 174 | var invalidName = validAttribName + invalidSet[i]; |
michael@0 | 175 | context.getAttribLocation(program, invalidName); |
michael@0 | 176 | shouldBe("context.getError()", "context.INVALID_VALUE"); |
michael@0 | 177 | } |
michael@0 | 178 | |
michael@0 | 179 | debug(""); |
michael@0 | 180 | debug("Test getUniformLocation() with invalid characters"); |
michael@0 | 181 | for (var i = 0; i < invalidSet.length; ++i) { |
michael@0 | 182 | var invalidName = validUniformName + invalidSet[i]; |
michael@0 | 183 | context.getUniformLocation(program, invalidName); |
michael@0 | 184 | shouldBe("context.getError()", "context.INVALID_VALUE"); |
michael@0 | 185 | } |
michael@0 | 186 | |
michael@0 | 187 | debug("") |
michael@0 | 188 | successfullyParsed = true; |
michael@0 | 189 | </script> |
michael@0 | 190 | |
michael@0 | 191 | <script>finishTest();</script> |
michael@0 | 192 | </body> |
michael@0 | 193 | </html> |