Move parseFontFaceDescriptor to CSSPropertyParser.cpp
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / fast / canvas / webgl / invalid-passed-params.html
blob022aea0c9877f1ddaab389151a833bb9bc0543a3
1 <html>
2 <head>
3 <script src="../../../resources/js-test.js"></script>
4 <script src="resources/webgl-test.js"></script>
5 <script src="resources/desktop-gl-constants.js"></script>
6 </head>
7 <body>
8 <div id="description"></div>
9 <div id="console"></div>
11 <script>
12 description("Test for invalid passed parameters");
14 if (window.internals)
15 window.internals.settings.setWebGLErrorsToConsoleEnabled(false);
17 var context = create3DContext();
19 debug("");
20 debug("Test createShader()");
21 shouldGenerateGLError(context, context.NO_ERROR, "context.createShader(context.FRAGMENT_SHADER)");
22 shouldGenerateGLError(context, context.NO_ERROR, "context.createShader(context.VERTEX_SHADER)");
23 shouldGenerateGLError(context, context.INVALID_ENUM, "context.createShader(0)");
24 shouldGenerateGLError(context, context.INVALID_ENUM, "context.createShader(context.TRIANGLES)");
26 debug("");
27 debug("Test clear()");
28 shouldGenerateGLError(context, context.INVALID_VALUE, "context.clear(desktopGL['ACCUM_BUFFER_BIT'])");
29 shouldGenerateGLError(context, context.INVALID_VALUE, "context.clear(desktopGL['ACCUM_BUFFER_BIT'] | context.COLOR_BUFFER_BIT)");
30 shouldGenerateGLError(context, context.INVALID_VALUE, "context.clear(desktopGL['ACCUM_BUFFER_BIT'] | context.COLOR_BUFFER_BIT | context.DEPTH_BUFFER_BIT | context.STENCIL_BUFFER_BIT)");
31 shouldGenerateGLError(context, context.NO_ERROR, "context.clear(context.COLOR_BUFFER_BIT | context.DEPTH_BUFFER_BIT | context.STENCIL_BUFFER_BIT)");
33 debug("");
34 debug("Test bufferData()");
35 var buffer = context.createBuffer();
36 shouldGenerateGLError(context, context.NO_ERROR, "context.bindBuffer(context.ARRAY_BUFFER, buffer)");
37 shouldGenerateGLError(context, context.NO_ERROR, "context.bufferData(context.ARRAY_BUFFER, 16, context.STREAM_DRAW)");
38 shouldGenerateGLError(context, context.NO_ERROR, "context.bufferData(context.ARRAY_BUFFER, 16, context.STATIC_DRAW)");
39 shouldGenerateGLError(context, context.NO_ERROR, "context.bufferData(context.ARRAY_BUFFER, 16, context.DYNAMIC_DRAW)");
40 shouldGenerateGLError(context, context.INVALID_ENUM, "context.bufferData(context.ARRAY_BUFFER, 16, desktopGL['STREAM_READ'])");
41 shouldGenerateGLError(context, context.INVALID_ENUM, "context.bufferData(context.ARRAY_BUFFER, 16, desktopGL['STREAM_COPY'])");
42 shouldGenerateGLError(context, context.INVALID_ENUM, "context.bufferData(context.ARRAY_BUFFER, 16, desktopGL['STATIC_READ'])");
43 shouldGenerateGLError(context, context.INVALID_ENUM, "context.bufferData(context.ARRAY_BUFFER, 16, desktopGL['STATIC_COPY'])");
44 shouldGenerateGLError(context, context.INVALID_ENUM, "context.bufferData(context.ARRAY_BUFFER, 16, desktopGL['DYNAMIC_READ'])");
45 shouldGenerateGLError(context, context.INVALID_ENUM, "context.bufferData(context.ARRAY_BUFFER, 16, desktopGL['DYNAMIC_COPY'])");
47 debug("");
48 debug("Test {copy}Tex{Sub}Image2D with negative offset/width/height");
49 var tex = context.createTexture();
50 var pixels = new Uint8Array(2 * 2 * 4);
51 shouldGenerateGLError(context, context.NO_ERROR, "context.bindTexture(context.TEXTURE_2D, tex)");
52 shouldGenerateGLError(context, context.INVALID_VALUE, "context.texImage2D(context.TEXTURE_2D, 0, context.RGBA, -16, -16, 0, context.RGBA, context.UNSIGNED_BYTE, null)");
53 shouldGenerateGLError(context, context.NO_ERROR, "context.texImage2D(context.TEXTURE_2D, 0, context.RGBA, 16, 16, 0, context.RGBA, context.UNSIGNED_BYTE, null)");
54 shouldGenerateGLError(context, context.INVALID_VALUE, "context.texSubImage2D(context.TEXTURE_2D, 0, -1, -1, 2, 2, context.RGBA, context.UNSIGNED_BYTE, pixels)");
55 shouldGenerateGLError(context, context.INVALID_VALUE, "context.texSubImage2D(context.TEXTURE_2D, 0, 0, 0, -1, -1, context.RGBA, context.UNSIGNED_BYTE, pixels)");
56 shouldGenerateGLError(context, context.NO_ERROR, "context.texSubImage2D(context.TEXTURE_2D, 0, 0, 0, 2, 2, context.RGBA, context.UNSIGNED_BYTE, pixels)");
57 shouldGenerateGLError(context, context.INVALID_VALUE, "context.copyTexImage2D(context.TEXTURE_2D, 0, context.RGBA, 0, 0, -1, -1, 0)");
58 shouldGenerateGLError(context, context.NO_ERROR, "context.copyTexImage2D(context.TEXTURE_2D, 0, context.RGBA, 0, 0, 16, 16, 0)");
59 shouldGenerateGLError(context, context.INVALID_VALUE, "context.copyTexSubImage2D(context.TEXTURE_2D, 0, -1, -1, 0, 0, 2, 2)");
60 shouldGenerateGLError(context, context.INVALID_VALUE, "context.copyTexSubImage2D(context.TEXTURE_2D, 0, 0, 0, 0, 0, -1, -1)");
61 shouldGenerateGLError(context, context.NO_ERROR, "context.copyTexSubImage2D(context.TEXTURE_2D, 0, 0, 0, 0, 0, 2, 2)");
63 debug("");
64 debug("Test renderbufferStorage() with negative width/height");
65 var renderbuffer = context.createRenderbuffer();
66 shouldGenerateGLError(context, context.NO_ERROR, "context.bindRenderbuffer(context.RENDERBUFFER, renderbuffer)");
67 shouldGenerateGLError(context, context.INVALID_VALUE, "context.renderbufferStorage(context.RENDERBUFFER, context.RGBA4, -2, -2)");
68 shouldGenerateGLError(context, context.NO_ERROR, "context.renderbufferStorage(context.RENDERBUFFER, context.RGBA4, 16, 16)");
70 debug("");
71 debug("Test scissor() with negative width/height");
72 shouldGenerateGLError(context, context.INVALID_VALUE, "context.scissor(0, 0, -2, -2)");
73 shouldGenerateGLError(context, context.NO_ERROR, "context.scissor(0, 0, 16, 16)");
75 debug("");
76 debug("Test viewport() with negative width/height");
77 shouldGenerateGLError(context, context.INVALID_VALUE, "context.viewport(0, 0, -2, -2)");
78 shouldGenerateGLError(context, context.NO_ERROR, "context.viewport(0, 0, 16, 16)");
80 debug("");
81 debug("Set up a program to test invalid characters");
82 var invalidSet = ['"', '$', '`', '@', '\\', "'"];
83 var validUniformName = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_1234567890";
84 var validAttribName = "abcdefghijklmnopqrstuvwxyz_ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890";
85 function generateShaderSource(opt_invalidIdentifierChar, opt_invalidCommentChar) {
86 var invalidIdentifierString = "";
87 var invalidCommentString = "";
88 if (opt_invalidIdentifierChar != undefined) {
89 invalidIdentifierString += opt_invalidIdentifierChar;
91 if (opt_invalidCommentChar != undefined) {
92 invalidCommentString += opt_invalidCommentChar;
94 return "uniform float " + validUniformName + invalidIdentifierString + ";\n"
95 + "varying float " + validAttribName + ";\n"
96 + "void main() {\n"
97 + validAttribName + " = " + validUniformName + ";\n"
98 + "gl_Position = vec4(0.0, 0.0, 0.0, 1.0); }\n";
99 + "//.+-/*%<>[](){}^|&~=!:;,?# " + invalidCommentString;
101 var vShader = context.createShader(context.VERTEX_SHADER);
102 context.shaderSource(vShader, generateShaderSource());
103 context.compileShader(vShader);
104 shouldBe("context.getError()", "context.NO_ERROR");
105 var fShader = context.createShader(context.FRAGMENT_SHADER);
106 context.shaderSource(fShader, "precision highp float;\n"
107 + "varying float " + validAttribName + ";\n"
108 + "void main() {\n"
109 + "gl_FragColor = vec4(" + validAttribName + ", 0.0, 0.0, 1.0); }");
110 context.compileShader(fShader);
111 shouldBe("context.getError()", "context.NO_ERROR");
112 var program = context.createProgram();
113 context.attachShader(program, vShader);
114 context.attachShader(program, fShader);
115 context.linkProgram(program);
116 shouldBeTrue("context.getProgramParameter(program, context.LINK_STATUS)");
117 shouldBe("context.getError()", "context.NO_ERROR");
118 context.bindAttribLocation(program, 1, validAttribName);
119 shouldBe("context.getError()", "context.NO_ERROR");
120 context.getAttribLocation(program, validAttribName);
121 shouldBe("context.getError()", "context.NO_ERROR");
122 context.getUniformLocation(program, validUniformName);
123 shouldBe("context.getError()", "context.NO_ERROR");
125 debug("");
126 debug("Test shaderSource() with invalid characters");
127 for (var i = 0; i < invalidSet.length; ++i) {
128 var validShaderSource = generateShaderSource(undefined, invalidSet[i]);
129 context.shaderSource(vShader, validShaderSource);
130 shouldBe("context.getError()", "context.NO_ERROR");
131 var invalidShaderSource = generateShaderSource(invalidSet[i], undefined);
132 context.shaderSource(vShader, invalidShaderSource);
133 shouldBe("context.getError()", "context.INVALID_VALUE");
136 debug("");
137 debug("Test bindAttribLocation() with invalid characters");
138 for (var i = 0; i < invalidSet.length; ++i) {
139 var invalidName = validAttribName + invalidSet[i];
140 context.bindAttribLocation(program, 1, invalidName);
141 shouldBe("context.getError()", "context.INVALID_VALUE");
144 debug("");
145 debug("Test getAttribLocation() with invalid characters");
146 for (var i = 0; i < invalidSet.length; ++i) {
147 var invalidName = validAttribName + invalidSet[i];
148 context.getAttribLocation(program, invalidName);
149 shouldBe("context.getError()", "context.INVALID_VALUE");
152 debug("");
153 debug("Test getUniformLocation() with invalid characters");
154 for (var i = 0; i < invalidSet.length; ++i) {
155 var invalidName = validUniformName + invalidSet[i];
156 context.getUniformLocation(program, invalidName);
157 shouldBe("context.getError()", "context.INVALID_VALUE");
160 debug("")
161 </script>
163 </body>
164 </html>