Changeset 57324 in webkit


Ignore:
Timestamp:
Apr 9, 2010 3:37:19 AM (14 years ago)
Author:
eric@webkit.org
Message:

2010-04-09 Zhenyao Mo <zmo@google.com>

Reviewed by Darin Fisher.

Passing null WebGLObjects should synthesize INVALID_VALUE error
https://bugs.webkit.org/show_bug.cgi?id=37047

  • fast/canvas/webgl/error-reporting-expected.txt: Change a few errors from INVALID_OPERATION to INVALID_VALUE.
  • fast/canvas/webgl/getActiveTest-expected.txt: Ditto.
  • fast/canvas/webgl/null-object-behaviour-expected.txt: Ditto.
  • fast/canvas/webgl/script-tests/error-reporting.js: Ditto.

2010-04-09 Zhenyao Mo <zmo@google.com>

Reviewed by Darin Fisher.

Passing null WebGLObjects should synthesize INVALID_VALUE error
https://bugs.webkit.org/show_bug.cgi?id=37047

  • html/canvas/WebGLRenderingContext.cpp: Synthesize INVALID_VALUE error when input object is 0. (WebCore::WebGLRenderingContext::bindAttribLocation): (WebCore::WebGLRenderingContext::compileShader): (WebCore::WebGLRenderingContext::detachShader): (WebCore::WebGLRenderingContext::validateWebGLObject): (WebCore::WebGLRenderingContext::getActiveAttrib): (WebCore::WebGLRenderingContext::getActiveUniform): (WebCore::WebGLRenderingContext::getProgramParameter): (WebCore::WebGLRenderingContext::getProgramInfoLog): (WebCore::WebGLRenderingContext::getShaderParameter): (WebCore::WebGLRenderingContext::getShaderInfoLog): (WebCore::WebGLRenderingContext::getShaderSource): (WebCore::WebGLRenderingContext::getUniform): (WebCore::WebGLRenderingContext::getUniformLocation): (WebCore::WebGLRenderingContext::linkProgram): (WebCore::WebGLRenderingContext::shaderSource):
  • html/canvas/WebGLRenderingContext.h: Add helper function to validate webgl object input parameters.
Location:
trunk
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r57322 r57324  
     12010-04-09  Zhenyao Mo  <zmo@google.com>
     2
     3        Reviewed by Darin Fisher.
     4
     5        Passing null WebGLObjects should synthesize INVALID_VALUE error
     6        https://bugs.webkit.org/show_bug.cgi?id=37047
     7
     8        * fast/canvas/webgl/error-reporting-expected.txt: Change a few errors from INVALID_OPERATION to INVALID_VALUE.
     9        * fast/canvas/webgl/getActiveTest-expected.txt: Ditto.
     10        * fast/canvas/webgl/null-object-behaviour-expected.txt: Ditto.
     11        * fast/canvas/webgl/script-tests/error-reporting.js: Ditto.
     12
    1132010-04-09  Zhenyao Mo  <zmo@google.com>
    214
  • trunk/LayoutTests/fast/canvas/webgl/error-reporting-expected.txt

    r52164 r57324  
    66Testing getActiveAttrib
    77PASS context.getActiveAttrib(null, 2) is null
    8 PASS context.getError() is context.INVALID_OPERATION
     8PASS context.getError() is context.INVALID_VALUE
    99PASS context.getError() is context.NO_ERROR
    1010PASS context.getActiveAttrib(program, 2) is null
     
    1313Testing getActiveUniform
    1414PASS context.getActiveUniform(null, 0) is null
    15 PASS context.getError() is context.INVALID_OPERATION
     15PASS context.getError() is context.INVALID_VALUE
    1616PASS context.getError() is context.NO_ERROR
    1717PASS context.getActiveUniform(program, 50) is null
  • trunk/LayoutTests/fast/canvas/webgl/getActiveTest-expected.txt

    r51970 r57324  
    1111PASS context.getActiveUniform(program, -1) threw exception GL error 1281 in getActiveUniform.
    1212PASS context.getError() is 0
    13 PASS context.getActiveUniform(null, 0) threw exception GL error 1282 in getActiveUniform.
     13PASS context.getActiveUniform(null, 0) threw exception GL error 1281 in getActiveUniform.
    1414PASS context.getError() is 0
    1515PASS context.getActiveAttrib(program, 0).name is 'a_normal'
     
    2323PASS context.getActiveAttrib(program, -1) threw exception GL error 1281 in getActiveAttrib.
    2424PASS context.getError() is 0
    25 PASS context.getActiveAttrib(null, 0) threw exception GL error 1282 in getActiveAttrib.
     25PASS context.getActiveAttrib(null, 0) threw exception GL error 1281 in getActiveAttrib.
    2626PASS context.getError() is 0
    2727PASS context2.getError() is 0
  • trunk/LayoutTests/fast/canvas/webgl/null-object-behaviour-expected.txt

    r52164 r57324  
    33On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
    44
    5 PASS context.compileShader() threw exception GL error 1282 in compileShader.
    6 PASS context.linkProgram() threw exception GL error 1282 in linkProgram.
     5PASS context.compileShader() threw exception GL error 1281 in compileShader.
     6PASS context.linkProgram() threw exception GL error 1281 in linkProgram.
    77PASS context.attachShader() threw exception GL error 1281 in attachShader.
    88PASS context.attachShader(program, undefined) threw exception GL error 1281 in attachShader.
    99PASS context.attachShader(undefined, shader) threw exception GL error 1281 in attachShader.
    10 PASS context.detachShader(program, undefined) threw exception GL error 1282 in detachShader.
    11 PASS context.detachShader(undefined, shader) threw exception GL error 1282 in detachShader.
    12 PASS context.shaderSource() threw exception GL error 1282 in shaderSource.
    13 PASS context.shaderSource(undefined, 'foo') threw exception GL error 1282 in shaderSource.
    14 PASS context.bindAttribLocation(undefined, 0, 'foo') threw exception GL error 1282 in bindAttribLocation.
     10PASS context.detachShader(program, undefined) threw exception GL error 1281 in detachShader.
     11PASS context.detachShader(undefined, shader) threw exception GL error 1281 in detachShader.
     12PASS context.shaderSource() threw exception GL error 1281 in shaderSource.
     13PASS context.shaderSource(undefined, 'foo') threw exception GL error 1281 in shaderSource.
     14PASS context.bindAttribLocation(undefined, 0, 'foo') threw exception GL error 1281 in bindAttribLocation.
    1515PASS context.bindBuffer(context.ARRAY_BUFFER, 0) is undefined.
    1616PASS context.bindFramebuffer(context.FRAMEBUFFER, 0) is undefined.
     
    1919PASS context.framebufferRenderbuffer(context.FRAMEBUFFER, context.DEPTH_ATTACHMENT, context.RENDERBUFFER, 0) threw exception GL error 1282 in framebufferRenderbuffer.
    2020PASS context.framebufferTexture2D(context.FRAMEBUFFER, context.COLOR_ATTACHMENT0, context.TEXTURE_2D, 0, 0) threw exception GL error 1282 in framebufferTexture2D.
    21 PASS context.getProgramParameter(undefined, 0) threw exception GL error 1282 in getProgramParameter.
    22 PASS context.getProgramInfoLog(undefined, 0) threw exception GL error 1282 in getProgramInfoLog.
    23 PASS context.getShaderParameter(undefined, 0) threw exception GL error 1282 in getShaderParameter.
    24 PASS context.getShaderInfoLog(undefined, 0) threw exception GL error 1282 in getShaderInfoLog.
    25 PASS context.getShaderSource(undefined) threw exception GL error 1282 in getShaderSource.
    26 PASS context.getUniform(undefined, 0) threw exception GL error 1282 in getUniform.
    27 PASS context.getUniformLocation(undefined, 'foo') threw exception GL error 1282 in getUniformLocation.
     21PASS context.getProgramParameter(undefined, 0) threw exception GL error 1281 in getProgramParameter.
     22PASS context.getProgramInfoLog(undefined, 0) threw exception GL error 1281 in getProgramInfoLog.
     23PASS context.getShaderParameter(undefined, 0) threw exception GL error 1281 in getShaderParameter.
     24PASS context.getShaderInfoLog(undefined, 0) threw exception GL error 1281 in getShaderInfoLog.
     25PASS context.getShaderSource(undefined) threw exception GL error 1281 in getShaderSource.
     26PASS context.getUniform(undefined, 0) threw exception GL error 1281 in getUniform.
     27PASS context.getUniformLocation(undefined, 'foo') threw exception GL error 1281 in getUniformLocation.
    2828PASS successfullyParsed is true
    2929
  • trunk/LayoutTests/fast/canvas/webgl/script-tests/error-reporting.js

    r52164 r57324  
    1616// Synthetic OpenGL error
    1717shouldBeNull("context.getActiveAttrib(null, 2)");
    18 shouldBe("context.getError()", "context.INVALID_OPERATION");
     18shouldBe("context.getError()", "context.INVALID_VALUE");
    1919// Error state should be clear by this point
    2020shouldBe("context.getError()", "context.NO_ERROR");
     
    2828// Synthetic OpenGL error
    2929shouldBeNull("context.getActiveUniform(null, 0)");
    30 shouldBe("context.getError()", "context.INVALID_OPERATION");
     30shouldBe("context.getError()", "context.INVALID_VALUE");
    3131// Error state should be clear by this point
    3232shouldBe("context.getError()", "context.NO_ERROR");
  • trunk/WebCore/ChangeLog

    r57322 r57324  
     12010-04-09  Zhenyao Mo  <zmo@google.com>
     2
     3        Reviewed by Darin Fisher.
     4
     5        Passing null WebGLObjects should synthesize INVALID_VALUE error
     6        https://bugs.webkit.org/show_bug.cgi?id=37047
     7
     8        * html/canvas/WebGLRenderingContext.cpp: Synthesize INVALID_VALUE error when input object is 0.
     9        (WebCore::WebGLRenderingContext::bindAttribLocation):
     10        (WebCore::WebGLRenderingContext::compileShader):
     11        (WebCore::WebGLRenderingContext::detachShader):
     12        (WebCore::WebGLRenderingContext::validateWebGLObject):
     13        (WebCore::WebGLRenderingContext::getActiveAttrib):
     14        (WebCore::WebGLRenderingContext::getActiveUniform):
     15        (WebCore::WebGLRenderingContext::getProgramParameter):
     16        (WebCore::WebGLRenderingContext::getProgramInfoLog):
     17        (WebCore::WebGLRenderingContext::getShaderParameter):
     18        (WebCore::WebGLRenderingContext::getShaderInfoLog):
     19        (WebCore::WebGLRenderingContext::getShaderSource):
     20        (WebCore::WebGLRenderingContext::getUniform):
     21        (WebCore::WebGLRenderingContext::getUniformLocation):
     22        (WebCore::WebGLRenderingContext::linkProgram):
     23        (WebCore::WebGLRenderingContext::shaderSource):
     24        * html/canvas/WebGLRenderingContext.h: Add helper function to validate webgl object input parameters.
     25
    1262010-04-09  Zhenyao Mo  <zmo@google.com>
    227
  • trunk/WebCore/html/canvas/WebGLRenderingContext.cpp

    r57049 r57324  
    184184{
    185185    UNUSED_PARAM(ec);
    186     if (!program || program->context() != this) {
    187         m_context->synthesizeGLError(GraphicsContext3D::INVALID_OPERATION);
    188         return;
    189     }
     186    if (!validateWebGLObject(program))
     187        return;
    190188    m_context->bindAttribLocation(program, index, name);
    191189    cleanupAfterGraphicsCall(false);
     
    410408{
    411409    UNUSED_PARAM(ec);
    412     if (!shader || shader->context() != this) {
    413         m_context->synthesizeGLError(GraphicsContext3D::INVALID_OPERATION);
    414         return;
    415     }
     410    if (!validateWebGLObject(shader))
     411        return;
    416412    m_context->compileShader(shader);
    417413    cleanupAfterGraphicsCall(false);
     
    553549{
    554550    UNUSED_PARAM(ec);
    555     if (!program || program->context() != this || !shader || shader->context() != this) {
    556         m_context->synthesizeGLError(GraphicsContext3D::INVALID_OPERATION);
    557         return;
    558     }
     551    if (!validateWebGLObject(program) || !validateWebGLObject(shader))
     552        return;
    559553    m_context->detachShader(program, shader);
    560554    cleanupAfterGraphicsCall(false);
     
    701695   
    702696    return numElementsRequired <= smallestNumElements;
     697}
     698
     699bool WebGLRenderingContext::validateWebGLObject(CanvasObject* object)
     700{
     701    if (!object) {
     702        m_context->synthesizeGLError(GraphicsContext3D::INVALID_VALUE);
     703        return false;
     704    }
     705    if (object->context() != this) {
     706        m_context->synthesizeGLError(GraphicsContext3D::INVALID_OPERATION);
     707        return false;
     708    }
     709    return true;
    703710}
    704711
     
    864871    UNUSED_PARAM(ec);
    865872    ActiveInfo info;
    866     if (!program || program->context() != this) {
    867         m_context->synthesizeGLError(GraphicsContext3D::INVALID_OPERATION);
     873    if (!validateWebGLObject(program))
    868874        return 0;
    869     }
    870875    if (!m_context->getActiveAttrib(program, index, info)) {
    871876        return 0;
     
    878883    UNUSED_PARAM(ec);
    879884    ActiveInfo info;
    880     if (!program || program->context() != this) {
    881         m_context->synthesizeGLError(GraphicsContext3D::INVALID_OPERATION);
     885    if (!validateWebGLObject(program))
    882886        return 0;
    883     }
    884887    if (!m_context->getActiveUniform(program, index, info)) {
    885888        return 0;
     
    11531156{
    11541157    UNUSED_PARAM(ec);
    1155     if (!program || program->context() != this) {
    1156         m_context->synthesizeGLError(GraphicsContext3D::INVALID_OPERATION);
     1158    if (!validateWebGLObject(program))
    11571159        return WebGLGetInfo();
    1158     }
    11591160
    11601161    WebGLStateRestorer(this, false);
     
    11831184{
    11841185    UNUSED_PARAM(ec);
    1185     if (!program || program->context() != this) {
    1186         m_context->synthesizeGLError(GraphicsContext3D::INVALID_OPERATION);
     1186    if (!validateWebGLObject(program))
    11871187        return "";
    1188     }
    11891188    WebGLStateRestorer(this, false);
    11901189    return m_context->getProgramInfoLog(program);
     
    12271226{
    12281227    UNUSED_PARAM(ec);
    1229     if (!shader || shader->context() != this) {
    1230         m_context->synthesizeGLError(GraphicsContext3D::INVALID_OPERATION);
     1228    if (!validateWebGLObject(shader))
    12311229        return WebGLGetInfo();
    1232     }
    12331230    WebGLStateRestorer(this, false);
    12341231    int value = 0;
     
    12541251{
    12551252    UNUSED_PARAM(ec);
    1256     if (!shader || shader->context() != this) {
    1257         m_context->synthesizeGLError(GraphicsContext3D::INVALID_OPERATION);
     1253    if (!validateWebGLObject(shader))
    12581254        return "";
    1259     }
    12601255    WebGLStateRestorer(this, false);
    12611256    return m_context->getShaderInfoLog(shader);
     
    12651260{
    12661261    UNUSED_PARAM(ec);
    1267     if (!shader || shader->context() != this) {
    1268         m_context->synthesizeGLError(GraphicsContext3D::INVALID_OPERATION);
     1262    if (!validateWebGLObject(shader))
    12691263        return "";
    1270     }
    12711264    WebGLStateRestorer(this, false);
    12721265    return m_context->getShaderSource(shader);
     
    13051298{
    13061299    UNUSED_PARAM(ec);
    1307     if (!program || uniformLocation->program() != program || program->context() != this) {
     1300    if (!validateWebGLObject(program))
     1301        return WebGLGetInfo();
     1302    if (uniformLocation->program() != program) {
    13081303        m_context->synthesizeGLError(GraphicsContext3D::INVALID_OPERATION);
    13091304        return WebGLGetInfo();
     
    14341429{
    14351430    UNUSED_PARAM(ec);
    1436     if (!program || program->context() != this) {
    1437         m_context->synthesizeGLError(GraphicsContext3D::INVALID_OPERATION);
     1431    if (!validateWebGLObject(program))
    14381432        return 0;
    1439     }
    14401433    WebGLStateRestorer(this, false);
    14411434    long uniformLocation = m_context->getUniformLocation(program, name);
     
    15631556{
    15641557    UNUSED_PARAM(ec);
    1565     if (!program || program->context() != this) {
    1566         m_context->synthesizeGLError(GraphicsContext3D::INVALID_OPERATION);
    1567         return;
    1568     }
    1569        
     1558    if (!validateWebGLObject(program))
     1559        return;
    15701560    m_context->linkProgram(program);
    15711561    cleanupAfterGraphicsCall(false);
     
    16311621{
    16321622    UNUSED_PARAM(ec);
    1633     if (!shader || shader->context() != this) {
    1634         m_context->synthesizeGLError(GraphicsContext3D::INVALID_OPERATION);
    1635         return;
    1636     }
     1623    if (!validateWebGLObject(shader))
     1624        return;
    16371625    m_context->shaderSource(shader, string);
    16381626    cleanupAfterGraphicsCall(false);
  • trunk/WebCore/html/canvas/WebGLRenderingContext.h

    r53238 r57324  
    310310        bool validateRenderingState(long numElements);
    311311
     312        bool validateWebGLObject(CanvasObject* object);
     313
    312314        OwnPtr<GraphicsContext3D> m_context;
    313315        bool m_needsUpdate;
Note: See TracChangeset for help on using the changeset viewer.