Commit b983e904 authored by cmarrin@apple.com's avatar cmarrin@apple.com
Browse files

Do error checking of parameter to createShader

        https://bugs.webkit.org/show_bug.cgi?id=31808



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@51370 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent c4897228
2009-11-24 Chris Marrin <cmarrin@apple.com>
Reviewed by Eric Seidel.
Test for createShader param passing
https://bugs.webkit.org/show_bug.cgi?id=31808
This test will eventually contain more param passing tests as
they are implemented.
* fast/canvas/webgl/invalidPassedParams-expected.txt: Added.
* fast/canvas/webgl/invalidPassedParams.html: Added.
2009-11-24 Darin Fisher <darin@chromium.org>
 
Reviewed by Adam Barth.
Test for invalid passed parameters
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
Test shaders
PASS shader = context.createShader(context.FRAGMENT_SHADER) is shader
PASS shader = context.createShader(context.VERTEX_SHADER) is shader
PASS context.createShader(0) threw exception Error: SYNTAX_ERR: DOM Exception 12.
PASS context.createShader(context.TRIANGLES) threw exception Error: SYNTAX_ERR: DOM Exception 12.
PASS successfullyParsed is true
TEST COMPLETE
<html>
<head>
<link rel="stylesheet" href="../../js/resources/js-test-style.css"/>
<script src="../../js/resources/js-test-pre.js"></script>
<script src="resources/webgl-test.js"></script>
</head>
<body>
<div id="description"></div>
<div id="console"></div>
<script>
description("Test for invalid passed parameters");
var context = create3DContext();
debug("Test shaders");
var shader;
shouldBe("shader = context.createShader(context.FRAGMENT_SHADER)", "shader");
shouldBe("shader = context.createShader(context.VERTEX_SHADER)", "shader");
shouldThrow("context.createShader(0)");
shouldThrow("context.createShader(context.TRIANGLES)");
debug("")
successfullyParsed = true;
</script>
<script src="../../js/resources/js-test-post.js"></script>
</body>
</html>
2009-11-24 Chris Marrin <cmarrin@apple.com>
Reviewed by Eric Seidel.
Do error checking of parameter to createShader
https://bugs.webkit.org/show_bug.cgi?id=31808
Test: fast/canvas/webgl/invalidPassedParams.html
* html/canvas/WebGLRenderingContext.cpp:
(WebCore::WebGLRenderingContext::createShader):
* html/canvas/WebGLRenderingContext.h:
* html/canvas/WebGLRenderingContext.idl:
2009-11-24 Kent Tamura <tkent@chromium.org>
 
Reviewed by Eric Seidel.
......@@ -448,9 +448,13 @@ PassRefPtr<WebGLRenderbuffer> WebGLRenderingContext::createRenderbuffer()
return o;
}
PassRefPtr<WebGLShader> WebGLRenderingContext::createShader(unsigned long type)
PassRefPtr<WebGLShader> WebGLRenderingContext::createShader(unsigned long type, ExceptionCode& ec)
{
// FIXME: Need to do param checking and throw exception if an illegal value is passed in
if (type != GraphicsContext3D::VERTEX_SHADER && type != GraphicsContext3D::FRAGMENT_SHADER) {
ec = SYNTAX_ERR;
return 0;
}
RefPtr<WebGLShader> o = WebGLShader::create(this, static_cast<GraphicsContext3D::WebGLEnumType>(type));
addObject(o.get());
return o;
......
......@@ -96,7 +96,7 @@ class WebKitCSSMatrix;
PassRefPtr<WebGLFramebuffer> createFramebuffer();
PassRefPtr<WebGLProgram> createProgram();
PassRefPtr<WebGLRenderbuffer> createRenderbuffer();
PassRefPtr<WebGLShader> createShader(unsigned long type);
PassRefPtr<WebGLShader> createShader(unsigned long type, ExceptionCode&);
PassRefPtr<WebGLTexture> createTexture();
void cullFace(unsigned long mode);
......
......@@ -499,7 +499,7 @@ module html {
WebGLFramebuffer createFramebuffer();
WebGLProgram createProgram();
WebGLRenderbuffer createRenderbuffer();
WebGLShader createShader(in unsigned long type);
WebGLShader createShader(in unsigned long type) raises(DOMException);
WebGLTexture createTexture();
void cullFace(in unsigned long mode);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment