Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(942)

Side by Side Diff: conformance/misc/invalid-passed-params.html

Issue 8342021: Add webgl conformance tests r15841. (Closed) Base URL: svn://chrome-svn/chrome/trunk/deps/third_party/webgl/sdk/tests/
Patch Set: Created 9 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « conformance/misc/instanceof-test.html ('k') | conformance/misc/is-object.html » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Property Changes:
Added: svn:eol-style
+ LF
OLDNEW
(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/desktop-gl-constants.js"></script>
33 </head>
34 <body>
35 <div id="description"></div>
36 <div id="console"></div>
37
38 <script>
39 description("Test for invalid passed parameters");
40
41 var context = create3DContext();
42
43 debug("");
44 debug("Test createShader()");
45 shouldGenerateGLError(context, context.NO_ERROR, "context.createShader(context.F RAGMENT_SHADER)");
46 shouldGenerateGLError(context, context.NO_ERROR, "context.createShader(context.V ERTEX_SHADER)");
47 shouldGenerateGLError(context, context.INVALID_ENUM, "context.createShader(0)");
48 shouldGenerateGLError(context, context.INVALID_ENUM, "context.createShader(conte xt.TRIANGLES)");
49
50 debug("");
51 debug("Test clear()");
52 shouldGenerateGLError(context, context.INVALID_VALUE, "context.clear(desktopGL[' ACCUM_BUFFER_BIT'])");
53 shouldGenerateGLError(context, context.INVALID_VALUE, "context.clear(desktopGL[' ACCUM_BUFFER_BIT'] | context.COLOR_BUFFER_BIT)");
54 shouldGenerateGLError(context, context.INVALID_VALUE, "context.clear(desktopGL[' ACCUM_BUFFER_BIT'] | context.COLOR_BUFFER_BIT | context.DEPTH_BUFFER_BIT | conte xt.STENCIL_BUFFER_BIT)");
55 shouldGenerateGLError(context, context.NO_ERROR, "context.clear(context.COLOR_BU FFER_BIT | context.DEPTH_BUFFER_BIT | context.STENCIL_BUFFER_BIT)");
56
57 debug("");
58 debug("Test bufferData()");
59 var buffer = context.createBuffer();
60 shouldGenerateGLError(context, context.NO_ERROR, "context.bindBuffer(context.ARR AY_BUFFER, buffer)");
61 shouldGenerateGLError(context, context.NO_ERROR, "context.bufferData(context.ARR AY_BUFFER, 16, context.STREAM_DRAW)");
62 shouldGenerateGLError(context, context.NO_ERROR, "context.bufferData(context.ARR AY_BUFFER, 16, context.STATIC_DRAW)");
63 shouldGenerateGLError(context, context.NO_ERROR, "context.bufferData(context.ARR AY_BUFFER, 16, context.DYNAMIC_DRAW)");
64 shouldGenerateGLError(context, context.INVALID_ENUM, "context.bufferData(context .ARRAY_BUFFER, 16, desktopGL['STREAM_READ'])");
65 shouldGenerateGLError(context, context.INVALID_ENUM, "context.bufferData(context .ARRAY_BUFFER, 16, desktopGL['STREAM_COPY'])");
66 shouldGenerateGLError(context, context.INVALID_ENUM, "context.bufferData(context .ARRAY_BUFFER, 16, desktopGL['STATIC_READ'])");
67 shouldGenerateGLError(context, context.INVALID_ENUM, "context.bufferData(context .ARRAY_BUFFER, 16, desktopGL['STATIC_COPY'])");
68 shouldGenerateGLError(context, context.INVALID_ENUM, "context.bufferData(context .ARRAY_BUFFER, 16, desktopGL['DYNAMIC_READ'])");
69 shouldGenerateGLError(context, context.INVALID_ENUM, "context.bufferData(context .ARRAY_BUFFER, 16, desktopGL['DYNAMIC_COPY'])");
70
71 debug("");
72 debug("Test {copy}Tex{Sub}Image2D with negative offset/width/height");
73 var tex = context.createTexture();
74 var pixels = new Uint8Array(2 * 2 * 4);
75 shouldGenerateGLError(context, context.NO_ERROR, "context.bindTexture(context.TE XTURE_2D, tex)");
76 shouldGenerateGLError(context, context.INVALID_VALUE, "context.texImage2D(contex t.TEXTURE_2D, 0, context.RGBA, -16, -16, 0, context.RGBA, context.UNSIGNED_BYTE, null)");
77 shouldGenerateGLError(context, context.NO_ERROR, "context.texImage2D(context.TEX TURE_2D, 0, context.RGBA, 16, 16, 0, context.RGBA, context.UNSIGNED_BYTE, null)" );
78 shouldGenerateGLError(context, context.INVALID_VALUE, "context.texSubImage2D(con text.TEXTURE_2D, 0, -1, -1, 2, 2, context.RGBA, context.UNSIGNED_BYTE, pixels)") ;
79 shouldGenerateGLError(context, context.INVALID_VALUE, "context.texSubImage2D(con text.TEXTURE_2D, 0, 0, 0, -1, -1, context.RGBA, context.UNSIGNED_BYTE, pixels)") ;
80 shouldGenerateGLError(context, context.NO_ERROR, "context.texSubImage2D(context. TEXTURE_2D, 0, 0, 0, 2, 2, context.RGBA, context.UNSIGNED_BYTE, pixels)");
81 shouldGenerateGLError(context, context.INVALID_VALUE, "context.copyTexImage2D(co ntext.TEXTURE_2D, 0, context.RGBA, 0, 0, -1, -1, 0)");
82 shouldGenerateGLError(context, context.NO_ERROR, "context.copyTexImage2D(context .TEXTURE_2D, 0, context.RGBA, 0, 0, 16, 16, 0)");
83 shouldGenerateGLError(context, context.INVALID_VALUE, "context.copyTexSubImage2D (context.TEXTURE_2D, 0, -1, -1, 0, 0, 2, 2)");
84 shouldGenerateGLError(context, context.INVALID_VALUE, "context.copyTexSubImage2D (context.TEXTURE_2D, 0, 0, 0, 0, 0, -1, -1)");
85 shouldGenerateGLError(context, context.NO_ERROR, "context.copyTexSubImage2D(cont ext.TEXTURE_2D, 0, 0, 0, 0, 0, 2, 2)");
86
87 debug("");
88 debug("Test renderbufferStorage() with negative width/height");
89 var renderbuffer = context.createRenderbuffer();
90 shouldGenerateGLError(context, context.NO_ERROR, "context.bindRenderbuffer(conte xt.RENDERBUFFER, renderbuffer)");
91 shouldGenerateGLError(context, context.INVALID_VALUE, "context.renderbufferStora ge(context.RENDERBUFFER, context.RGBA4, -2, -2)");
92 shouldGenerateGLError(context, context.NO_ERROR, "context.renderbufferStorage(co ntext.RENDERBUFFER, context.RGBA4, 16, 16)");
93
94 debug("");
95 debug("Test scissor() with negative width/height");
96 shouldGenerateGLError(context, context.INVALID_VALUE, "context.scissor(0, 0, -2, -2)");
97 shouldGenerateGLError(context, context.NO_ERROR, "context.scissor(0, 0, 16, 16)" );
98
99 debug("");
100 debug("Test viewport() with negative width/height");
101 shouldGenerateGLError(context, context.INVALID_VALUE, "context.viewport(0, 0, -2 , -2)");
102 shouldGenerateGLError(context, context.NO_ERROR, "context.viewport(0, 0, 16, 16) ");
103
104 debug("");
105 debug("Set up a program to test invalid characters");
106 var invalidSet = ['"', '$', '`', '@', '\\', "'"];
107 var validUniformName = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_123 4567890";
108 var validAttribName = "abcdefghijklmnopqrstuvwxyz_ABCDEFGHIJKLMNOPQRSTUVWXYZ1234 567890";
109 function generateShaderSource(opt_invalidIdentifierChar, opt_invalidCommentChar) {
110 var invalidIdentifierString = "";
111 var invalidCommentString = "";
112 if (opt_invalidIdentifierChar != undefined) {
113 invalidIdentifierString += opt_invalidIdentifierChar;
114 }
115 if (opt_invalidCommentChar != undefined) {
116 invalidCommentString += opt_invalidCommentChar;
117 }
118 return "uniform float " + validUniformName + invalidIdentifierString + ";\n"
119 + "varying float " + validAttribName + ";\n"
120 + "void main() {\n"
121 + validAttribName + " = " + validUniformName + ";\n"
122 + "gl_Position = vec4(0.0, 0.0, 0.0, 1.0); }\n";
123 + "//.+-/*%<>[](){}^|&~=!:;,?# " + invalidCommentStrin g;
124 }
125 var vShader = context.createShader(context.VERTEX_SHADER);
126 context.shaderSource(vShader, generateShaderSource());
127 context.compileShader(vShader);
128 shouldBe("context.getError()", "context.NO_ERROR");
129 var fShader = context.createShader(context.FRAGMENT_SHADER);
130 context.shaderSource(fShader, "precision mediump float;\n"
131 + "varying float " + validAttribName + ";\n"
132 + "void main() {\n"
133 + "gl_FragColor = vec4(" + validAttribName + ", 0. 0, 0.0, 1.0); }");
134 context.compileShader(fShader);
135 shouldBe("context.getError()", "context.NO_ERROR");
136 var program = context.createProgram();
137 context.attachShader(program, vShader);
138 context.attachShader(program, fShader);
139 context.linkProgram(program);
140 shouldBeTrue("context.getProgramParameter(program, context.LINK_STATUS)");
141 shouldBe("context.getError()", "context.NO_ERROR");
142 context.bindAttribLocation(program, 1, validAttribName);
143 shouldBe("context.getError()", "context.NO_ERROR");
144 context.getAttribLocation(program, validAttribName);
145 shouldBe("context.getError()", "context.NO_ERROR");
146 context.getUniformLocation(program, validUniformName);
147 shouldBe("context.getError()", "context.NO_ERROR");
148
149 debug("");
150 debug("Test shaderSource() with invalid characters");
151 for (var i = 0; i < invalidSet.length; ++i) {
152 var validShaderSource = generateShaderSource(undefined, invalidSet[i]);
153 context.shaderSource(vShader, validShaderSource);
154 shouldBe("context.getError()", "context.NO_ERROR");
155 var invalidShaderSource = generateShaderSource(invalidSet[i], undefined);
156 context.shaderSource(vShader, invalidShaderSource);
157 shouldBe("context.getError()", "context.INVALID_VALUE");
158 }
159
160 debug("");
161 debug("Test bindAttribLocation() with invalid characters");
162 for (var i = 0; i < invalidSet.length; ++i) {
163 var invalidName = validAttribName + invalidSet[i];
164 context.bindAttribLocation(program, 1, invalidName);
165 shouldBe("context.getError()", "context.INVALID_VALUE");
166 }
167
168 debug("");
169 debug("Test getAttribLocation() with invalid characters");
170 for (var i = 0; i < invalidSet.length; ++i) {
171 var invalidName = validAttribName + invalidSet[i];
172 context.getAttribLocation(program, invalidName);
173 shouldBe("context.getError()", "context.INVALID_VALUE");
174 }
175
176 debug("");
177 debug("Test getUniformLocation() with invalid characters");
178 for (var i = 0; i < invalidSet.length; ++i) {
179 var invalidName = validUniformName + invalidSet[i];
180 context.getUniformLocation(program, invalidName);
181 shouldBe("context.getError()", "context.INVALID_VALUE");
182 }
183
184 debug("")
185 successfullyParsed = true;
186 </script>
187
188 <script src="../../resources/js-test-post.js"></script>
189 </body>
190 </html>
OLDNEW
« no previous file with comments | « conformance/misc/instanceof-test.html ('k') | conformance/misc/is-object.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698