Changeset 75175 in webkit
- Timestamp:
- Jan 6, 2011 11:33:58 AM (13 years ago)
- Location:
- trunk
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r75173 r75175 1 2010-12-28 Zhenyao Mo <zmo@google.com> 2 3 Reviewed by Kenneth Russell. 4 5 Must generate INVALID_VALUE errors for strings containing out-of-range characters 6 https://bugs.webkit.org/show_bug.cgi?id=50929 7 8 * fast/canvas/webgl/invalid-passed-params-expected.txt: Add test cases for invalid characters. 9 * fast/canvas/webgl/invalid-passed-params.html: Ditto. 10 1 11 2011-01-06 Abhishek Arya <inferno@chromium.org> 2 12 -
trunk/LayoutTests/fast/canvas/webgl/invalid-passed-params-expected.txt
r74719 r75175 2 2 3 3 On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE". 4 4 5 5 6 Test createShader() … … 8 9 PASS context.createShader(0) generated expected GL error: INVALID_ENUM. 9 10 PASS context.createShader(context.TRIANGLES) generated expected GL error: INVALID_ENUM. 11 10 12 Test clear() 11 13 PASS context.clear(desktopGL['ACCUM_BUFFER_BIT']) generated expected GL error: INVALID_VALUE. … … 13 15 PASS context.clear(desktopGL['ACCUM_BUFFER_BIT'] | context.COLOR_BUFFER_BIT | context.DEPTH_BUFFER_BIT | context.STENCIL_BUFFER_BIT) generated expected GL error: INVALID_VALUE. 14 16 PASS context.clear(context.COLOR_BUFFER_BIT | context.DEPTH_BUFFER_BIT | context.STENCIL_BUFFER_BIT) generated expected GL error: NO_ERROR. 17 15 18 Test bufferData() 16 19 PASS context.bindBuffer(context.ARRAY_BUFFER, buffer) generated expected GL error: NO_ERROR. … … 24 27 PASS context.bufferData(context.ARRAY_BUFFER, 16, desktopGL['DYNAMIC_READ']) generated expected GL error: INVALID_ENUM. 25 28 PASS context.bufferData(context.ARRAY_BUFFER, 16, desktopGL['DYNAMIC_COPY']) generated expected GL error: INVALID_ENUM. 29 26 30 Test {copy}Tex{Sub}Image2D with negative offset/width/height 27 31 PASS context.bindTexture(context.TEXTURE_2D, tex) generated expected GL error: NO_ERROR. … … 36 40 PASS context.copyTexSubImage2D(context.TEXTURE_2D, 0, 0, 0, 0, 0, -1, -1) generated expected GL error: INVALID_VALUE. 37 41 PASS context.copyTexSubImage2D(context.TEXTURE_2D, 0, 0, 0, 0, 0, 2, 2) generated expected GL error: NO_ERROR. 42 38 43 Test renderbufferStorage() with negative width/height 39 44 PASS context.bindRenderbuffer(context.RENDERBUFFER, renderbuffer) generated expected GL error: NO_ERROR. 40 45 PASS context.renderbufferStorage(context.RENDERBUFFER, context.RGBA4, -2, -2) generated expected GL error: INVALID_VALUE. 41 46 PASS context.renderbufferStorage(context.RENDERBUFFER, context.RGBA4, 16, 16) generated expected GL error: NO_ERROR. 47 42 48 Test scissor() with negative width/height 43 49 PASS context.scissor(0, 0, -2, -2) generated expected GL error: INVALID_VALUE. 44 50 PASS context.scissor(0, 0, 16, 16) generated expected GL error: NO_ERROR. 51 45 52 Test viewport() with negative width/height 46 53 PASS context.viewport(0, 0, -2, -2) generated expected GL error: INVALID_VALUE. 47 54 PASS context.viewport(0, 0, 16, 16) generated expected GL error: NO_ERROR. 55 56 Set up a program to test invalid characters 57 PASS context.getError() is context.NO_ERROR 58 PASS context.getError() is context.NO_ERROR 59 PASS context.getProgramParameter(program, context.LINK_STATUS) is true 60 PASS context.getError() is context.NO_ERROR 61 PASS context.getError() is context.NO_ERROR 62 PASS context.getError() is context.NO_ERROR 63 PASS context.getError() is context.NO_ERROR 64 65 Test shaderSource() with invalid characters 66 PASS context.getError() is context.INVALID_VALUE 67 PASS context.getError() is context.INVALID_VALUE 68 PASS context.getError() is context.INVALID_VALUE 69 PASS context.getError() is context.INVALID_VALUE 70 PASS context.getError() is context.INVALID_VALUE 71 PASS context.getError() is context.INVALID_VALUE 72 73 Test bindAttribLocation() with invalid characters 74 PASS context.getError() is context.INVALID_VALUE 75 PASS context.getError() is context.INVALID_VALUE 76 PASS context.getError() is context.INVALID_VALUE 77 PASS context.getError() is context.INVALID_VALUE 78 PASS context.getError() is context.INVALID_VALUE 79 PASS context.getError() is context.INVALID_VALUE 80 81 Test getAttribLocation() with invalid characters 82 PASS context.getError() is context.INVALID_VALUE 83 PASS context.getError() is context.INVALID_VALUE 84 PASS context.getError() is context.INVALID_VALUE 85 PASS context.getError() is context.INVALID_VALUE 86 PASS context.getError() is context.INVALID_VALUE 87 PASS context.getError() is context.INVALID_VALUE 88 89 Test getUniformLocation() with invalid characters 90 PASS context.getError() is context.INVALID_VALUE 91 PASS context.getError() is context.INVALID_VALUE 92 PASS context.getError() is context.INVALID_VALUE 93 PASS context.getError() is context.INVALID_VALUE 94 PASS context.getError() is context.INVALID_VALUE 95 PASS context.getError() is context.INVALID_VALUE 48 96 49 97 PASS successfullyParsed is true -
trunk/LayoutTests/fast/canvas/webgl/invalid-passed-params.html
r74719 r75175 15 15 var context = create3DContext(); 16 16 17 debug(""); 17 18 debug("Test createShader()"); 18 19 shouldGenerateGLError(context, context.NO_ERROR, "context.createShader(context.FRAGMENT_SHADER)"); … … 21 22 shouldGenerateGLError(context, context.INVALID_ENUM, "context.createShader(context.TRIANGLES)"); 22 23 24 debug(""); 23 25 debug("Test clear()"); 24 26 shouldGenerateGLError(context, context.INVALID_VALUE, "context.clear(desktopGL['ACCUM_BUFFER_BIT'])"); … … 27 29 shouldGenerateGLError(context, context.NO_ERROR, "context.clear(context.COLOR_BUFFER_BIT | context.DEPTH_BUFFER_BIT | context.STENCIL_BUFFER_BIT)"); 28 30 31 debug(""); 29 32 debug("Test bufferData()"); 30 33 var buffer = context.createBuffer(); … … 40 43 shouldGenerateGLError(context, context.INVALID_ENUM, "context.bufferData(context.ARRAY_BUFFER, 16, desktopGL['DYNAMIC_COPY'])"); 41 44 45 debug(""); 42 46 debug("Test {copy}Tex{Sub}Image2D with negative offset/width/height"); 43 47 var tex = context.createTexture(); … … 55 59 shouldGenerateGLError(context, context.NO_ERROR, "context.copyTexSubImage2D(context.TEXTURE_2D, 0, 0, 0, 0, 0, 2, 2)"); 56 60 61 debug(""); 57 62 debug("Test renderbufferStorage() with negative width/height"); 58 63 var renderbuffer = context.createRenderbuffer(); … … 61 66 shouldGenerateGLError(context, context.NO_ERROR, "context.renderbufferStorage(context.RENDERBUFFER, context.RGBA4, 16, 16)"); 62 67 68 debug(""); 63 69 debug("Test scissor() with negative width/height"); 64 70 shouldGenerateGLError(context, context.INVALID_VALUE, "context.scissor(0, 0, -2, -2)"); 65 71 shouldGenerateGLError(context, context.NO_ERROR, "context.scissor(0, 0, 16, 16)"); 66 72 73 debug(""); 67 74 debug("Test viewport() with negative width/height"); 68 75 shouldGenerateGLError(context, context.INVALID_VALUE, "context.viewport(0, 0, -2, -2)"); 69 76 shouldGenerateGLError(context, context.NO_ERROR, "context.viewport(0, 0, 16, 16)"); 77 78 debug(""); 79 debug("Set up a program to test invalid characters"); 80 var invalidSet = ['"', '$', '`', '@', '\\', "'"]; 81 var validUniformName = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_1234567890"; 82 var validAttribName = "abcdefghijklmnopqrstuvwxyz_ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890"; 83 var validShaderSource = "uniform float " + validUniformName + ";\n" 84 + "varying float " + validAttribName + ";\n" 85 + "void main() {\n" 86 + validAttribName + " = " + validUniformName + ";\n" 87 + "gl_Position = vec4(0.0, 0.0, 0.0, 1.0); }\n"; 88 + "//.+-/*%<>[](){}^|&~=!:;,?# "; 89 var vShader = context.createShader(context.VERTEX_SHADER); 90 context.shaderSource(vShader, validShaderSource); 91 context.compileShader(vShader); 92 shouldBe("context.getError()", "context.NO_ERROR"); 93 var fShader = context.createShader(context.FRAGMENT_SHADER); 94 context.shaderSource(fShader, "precision highp float;\n" 95 + "varying float " + validAttribName + ";\n" 96 + "void main() {\n" 97 + "gl_FragColor = vec4(" + validAttribName + ", 0.0, 0.0, 1.0); }"); 98 context.compileShader(fShader); 99 shouldBe("context.getError()", "context.NO_ERROR"); 100 var program = context.createProgram(); 101 context.attachShader(program, vShader); 102 context.attachShader(program, fShader); 103 context.linkProgram(program); 104 shouldBeTrue("context.getProgramParameter(program, context.LINK_STATUS)"); 105 shouldBe("context.getError()", "context.NO_ERROR"); 106 context.bindAttribLocation(program, 1, validAttribName); 107 shouldBe("context.getError()", "context.NO_ERROR"); 108 context.getAttribLocation(program, validAttribName); 109 shouldBe("context.getError()", "context.NO_ERROR"); 110 context.getUniformLocation(program, validUniformName); 111 shouldBe("context.getError()", "context.NO_ERROR"); 112 113 debug(""); 114 debug("Test shaderSource() with invalid characters"); 115 for (var i = 0; i < invalidSet.length; ++i) { 116 var invalidShaderSource = validShaderSource + "\n//" + invalidSet[i]; 117 context.shaderSource(vShader, invalidShaderSource); 118 shouldBe("context.getError()", "context.INVALID_VALUE"); 119 } 120 121 debug(""); 122 debug("Test bindAttribLocation() with invalid characters"); 123 for (var i = 0; i < invalidSet.length; ++i) { 124 var invalidName = validAttribName + invalidSet[i]; 125 context.bindAttribLocation(program, 1, invalidName); 126 shouldBe("context.getError()", "context.INVALID_VALUE"); 127 } 128 129 debug(""); 130 debug("Test getAttribLocation() with invalid characters"); 131 for (var i = 0; i < invalidSet.length; ++i) { 132 var invalidName = validAttribName + invalidSet[i]; 133 context.getAttribLocation(program, invalidName); 134 shouldBe("context.getError()", "context.INVALID_VALUE"); 135 } 136 137 debug(""); 138 debug("Test getUniformLocation() with invalid characters"); 139 for (var i = 0; i < invalidSet.length; ++i) { 140 var invalidName = validUniformName + invalidSet[i]; 141 context.getUniformLocation(program, invalidName); 142 shouldBe("context.getError()", "context.INVALID_VALUE"); 143 } 70 144 71 145 debug("") -
trunk/WebCore/ChangeLog
r75172 r75175 1 2010-12-28 Zhenyao Mo <zmo@google.com> 2 3 Reviewed by Kenneth Russell. 4 5 Must generate INVALID_VALUE errors for strings containing out-of-range characters 6 https://bugs.webkit.org/show_bug.cgi?id=50929 7 8 * html/canvas/WebGLRenderingContext.cpp: Validate characters according to GLSL ES 1.0 spec section 3.1. 9 (WebCore::WebGLRenderingContext::bindAttribLocation): 10 (WebCore::WebGLRenderingContext::getAttribLocation): 11 (WebCore::WebGLRenderingContext::getUniformLocation): 12 (WebCore::WebGLRenderingContext::shaderSource): 13 (WebCore::WebGLRenderingContext::validateString): Helper function to perform the character validation. 14 * html/canvas/WebGLRenderingContext.h: Declare validateString(). 15 1 16 2011-01-06 Yong Li <yoli@rim.com> 2 17 -
trunk/WebCore/html/canvas/WebGLRenderingContext.cpp
r74818 r75175 87 87 } 88 88 89 // Return true if a character belongs to the ASCII subset as defined in 90 // GLSL ES 1.0 spec section 3.1. 91 bool validateCharacter(unsigned char c) 92 { 93 // Printing characters are valid except " $ ` @ \ ' DEL. 94 if (c >= 32 && c <= 126 95 && c != '"' && c != '$' && c != '`' && c != '@' && c != '\\' && c != '\'') 96 return true; 97 // Horizontal tab, line feed, vertical tab, form feed, carriage return 98 // are also valid. 99 if (c >= 9 && c <= 13) 100 return true; 101 return false; 102 } 103 89 104 } // namespace anonymous 90 105 … … 311 326 if (isContextLost() || !validateWebGLObject(program)) 312 327 return; 328 if (!validateString(name)) 329 return; 313 330 m_context->bindAttribLocation(objectOrZero(program), index, name); 314 331 cleanupAfterGraphicsCall(false); … … 1460 1477 { 1461 1478 if (isContextLost()) 1479 return -1; 1480 if (!validateString(name)) 1462 1481 return -1; 1463 1482 return m_context->getAttribLocation(objectOrZero(program), name); … … 2086 2105 if (isContextLost() || !validateWebGLObject(program)) 2087 2106 return 0; 2107 if (!validateString(name)) 2108 return 0; 2088 2109 WebGLStateRestorer(this, false); 2089 2110 long uniformLocation = m_context->getUniformLocation(objectOrZero(program), name); … … 2470 2491 if (isContextLost() || !validateWebGLObject(shader)) 2471 2492 return; 2493 if (!validateString(string)) 2494 return; 2472 2495 m_context->shaderSource(objectOrZero(shader), string); 2473 2496 cleanupAfterGraphicsCall(false); … … 3705 3728 } 3706 3729 3730 bool WebGLRenderingContext::validateString(const String& string) 3731 { 3732 for (size_t i = 0; i < string.length(); ++i) { 3733 if (!validateCharacter(string[i])) { 3734 m_context->synthesizeGLError(GraphicsContext3D::INVALID_VALUE); 3735 return false; 3736 } 3737 } 3738 return true; 3739 } 3740 3707 3741 bool WebGLRenderingContext::validateTexFuncFormatAndType(unsigned long format, unsigned long type) 3708 3742 { -
trunk/WebCore/html/canvas/WebGLRenderingContext.h
r74818 r75175 516 516 bool validateSize(long x, long y); 517 517 518 // Helper function to check if all characters in the string belong to the 519 // ASCII subset as defined in GLSL ES 1.0 spec section 3.1. 520 bool validateString(const String&); 521 518 522 // Helper function to check target and texture bound to the target. 519 523 // Generate GL errors and return 0 if target is invalid or texture bound is
Note: See TracChangeset
for help on using the changeset viewer.