Exception checks were being too aggressive
authorcmarrin@apple.com <cmarrin@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 3 Nov 2009 00:04:29 +0000 (00:04 +0000)
committercmarrin@apple.com <cmarrin@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 3 Nov 2009 00:04:29 +0000 (00:04 +0000)
        https://bugs.webkit.org/show_bug.cgi?id=31005

        Several calls in CanvasRenderingContext3D are allowed to
        have a null value passed, which indicated that the
        object is being unbound. Handle this case and the corresponding
        null handling in GraphicsContext3DMac.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@50432 268f45cc-cd09-0410-ab3c-d52691b4dbfc

LayoutTests/ChangeLog
LayoutTests/fast/canvas/webgl/incorrect-context-object-behaviour-expected.txt
LayoutTests/fast/canvas/webgl/null-object-behaviour-expected.txt
LayoutTests/fast/canvas/webgl/script-tests/incorrect-context-object-behaviour.js
LayoutTests/fast/canvas/webgl/script-tests/null-object-behaviour.js
WebCore/ChangeLog
WebCore/html/canvas/CanvasRenderingContext3D.cpp
WebCore/platform/graphics/mac/GraphicsContext3DMac.cpp

index a7d9c015fe50c3011f012ae9b9056807c56c9eb5..6b88ef446e6a1876c91dd5212af4e3e48ac92987 100644 (file)
@@ -1,3 +1,15 @@
+2009-11-02  Chris Marrin  <cmarrin@apple.com>
+
+        Reviewed by Oliver Hunt.
+
+        Revised tests for changes to when exceptions are raised in WebGL content
+        https://bugs.webkit.org/show_bug.cgi?id=31005
+
+        * fast/canvas/webgl/incorrect-context-object-behaviour-expected.txt:
+        * fast/canvas/webgl/null-object-behaviour-expected.txt:
+        * fast/canvas/webgl/script-tests/incorrect-context-object-behaviour.js:
+        * fast/canvas/webgl/script-tests/null-object-behaviour.js:
+
 2009-11-02  Philippe Normand  <pnormand@igalia.com>
 
         Reviewed by Jan Alonzo.
 2009-11-02  Philippe Normand  <pnormand@igalia.com>
 
         Reviewed by Jan Alonzo.
index 2fc73e8ac071475a56b1890696bae03ebecaed79..777d091cbb8cbc514bf4c83370c1371c5cad60fa 100644 (file)
@@ -12,11 +12,11 @@ PASS contextA.detachShader(programB, shaderA) threw exception Error: TYPE_MISMAT
 PASS contextA.detachShader(programB, shaderB) threw exception Error: TYPE_MISMATCH_ERR: DOM Exception 17.
 PASS contextA.shaderSource(shaderB, 'foo') threw exception Error: TYPE_MISMATCH_ERR: DOM Exception 17.
 PASS contextA.bindAttribLocation(programB, 0, 'foo') threw exception Error: TYPE_MISMATCH_ERR: DOM Exception 17.
 PASS contextA.detachShader(programB, shaderB) threw exception Error: TYPE_MISMATCH_ERR: DOM Exception 17.
 PASS contextA.shaderSource(shaderB, 'foo') threw exception Error: TYPE_MISMATCH_ERR: DOM Exception 17.
 PASS contextA.bindAttribLocation(programB, 0, 'foo') threw exception Error: TYPE_MISMATCH_ERR: DOM Exception 17.
-PASS contextA.bindFramebuffer(0, frameBufferB) threw exception Error: TYPE_MISMATCH_ERR: DOM Exception 17.
-PASS contextA.bindRenderbuffer(0, renderBufferB) threw exception Error: TYPE_MISMATCH_ERR: DOM Exception 17.
-PASS contextA.bindTexture(textureB) threw exception Error: TYPE_MISMATCH_ERR: DOM Exception 17.
-PASS contextA.framebufferRenderbuffer(0, 0, renderBufferB) threw exception Error: TYPE_MISMATCH_ERR: DOM Exception 17.
-PASS contextA.framebufferTexture2D(0, 0, textureB) threw exception Error: TYPE_MISMATCH_ERR: DOM Exception 17.
+PASS contextA.bindFramebuffer(contextA.FRAMEBUFFER, frameBufferB) threw exception Error: TYPE_MISMATCH_ERR: DOM Exception 17.
+PASS contextA.bindRenderbuffer(contextA.RENDERBUFFER, renderBufferB) threw exception Error: TYPE_MISMATCH_ERR: DOM Exception 17.
+PASS contextA.bindTexture(contextA.TEXTURE_2D, textureB) threw exception Error: TYPE_MISMATCH_ERR: DOM Exception 17.
+PASS contextA.framebufferRenderbuffer(contextA.FRAMEBUFFER, contextA.DEPTH_ATTACHMENT, contextA.RENDERBUFFER, renderBufferB) threw exception Error: TYPE_MISMATCH_ERR: DOM Exception 17.
+PASS contextA.framebufferTexture2D(contextA.FRAMEBUFFER, contextA.COLOR_ATTACHMENT0, contextA.TEXTURE_2D, textureB, 0) threw exception Error: TYPE_MISMATCH_ERR: DOM Exception 17.
 PASS contextA.getProgrami(programB, 0) threw exception Error: TYPE_MISMATCH_ERR: DOM Exception 17.
 PASS contextA.getProgramiv(programB, 0) threw exception Error: TYPE_MISMATCH_ERR: DOM Exception 17.
 PASS contextA.getProgramInfoLog(programB, 0) threw exception Error: TYPE_MISMATCH_ERR: DOM Exception 17.
 PASS contextA.getProgrami(programB, 0) threw exception Error: TYPE_MISMATCH_ERR: DOM Exception 17.
 PASS contextA.getProgramiv(programB, 0) threw exception Error: TYPE_MISMATCH_ERR: DOM Exception 17.
 PASS contextA.getProgramInfoLog(programB, 0) threw exception Error: TYPE_MISMATCH_ERR: DOM Exception 17.
index a1f82989fa1ebe3a20778a143221410dce503997..1db44bf7da0943d185cd38711ae2961d94ced381 100644 (file)
@@ -12,12 +12,12 @@ PASS context.detachShader(undefined, shader) threw exception Error: TYPE_MISMATC
 PASS context.shaderSource() threw exception Error: TYPE_MISMATCH_ERR: DOM Exception 17.
 PASS context.shaderSource(undefined, 'foo') threw exception Error: TYPE_MISMATCH_ERR: DOM Exception 17.
 PASS context.bindAttribLocation(undefined, 0, 'foo') threw exception Error: TYPE_MISMATCH_ERR: DOM Exception 17.
 PASS context.shaderSource() threw exception Error: TYPE_MISMATCH_ERR: DOM Exception 17.
 PASS context.shaderSource(undefined, 'foo') threw exception Error: TYPE_MISMATCH_ERR: DOM Exception 17.
 PASS context.bindAttribLocation(undefined, 0, 'foo') threw exception Error: TYPE_MISMATCH_ERR: DOM Exception 17.
-PASS context.bindBuffer(0) threw exception Error: TYPE_MISMATCH_ERR: DOM Exception 17.
-PASS context.bindFramebuffer(0) threw exception Error: TYPE_MISMATCH_ERR: DOM Exception 17.
-PASS context.bindRenderbuffer(0) threw exception Error: TYPE_MISMATCH_ERR: DOM Exception 17.
-PASS context.bindTexture(0) threw exception Error: TYPE_MISMATCH_ERR: DOM Exception 17.
-PASS context.framebufferRenderbuffer(0, 0, 0) threw exception Error: TYPE_MISMATCH_ERR: DOM Exception 17.
-PASS context.framebufferTexture2D(0, 0, 0) threw exception Error: TYPE_MISMATCH_ERR: DOM Exception 17.
+PASS context.bindBuffer(context.ARRAY_BUFFER, 0) is undefined.
+PASS context.bindFramebuffer(context.FRAMEBUFFER, 0) is undefined.
+PASS context.bindRenderbuffer(context.RENDERBUFFER, 0) is undefined.
+PASS context.bindTexture(context.TEXTURE_2D, 0) is undefined.
+PASS context.framebufferRenderbuffer(context.FRAMEBUFFER, context.DEPTH_ATTACHMENT, context.RENDERBUFFER, 0) is undefined.
+PASS context.framebufferTexture2D(context.FRAMEBUFFER, context.COLOR_ATTACHMENT0, context.TEXTURE_2D, 0, 0) is undefined.
 PASS context.getProgrami(undefined, 0) threw exception Error: TYPE_MISMATCH_ERR: DOM Exception 17.
 PASS context.getProgramiv(undefined, 0) threw exception Error: TYPE_MISMATCH_ERR: DOM Exception 17.
 PASS context.getProgramInfoLog(undefined, 0) threw exception Error: TYPE_MISMATCH_ERR: DOM Exception 17.
 PASS context.getProgrami(undefined, 0) threw exception Error: TYPE_MISMATCH_ERR: DOM Exception 17.
 PASS context.getProgramiv(undefined, 0) threw exception Error: TYPE_MISMATCH_ERR: DOM Exception 17.
 PASS context.getProgramInfoLog(undefined, 0) threw exception Error: TYPE_MISMATCH_ERR: DOM Exception 17.
index c699c7d6be17b29f05b06d9dd319399d3983392a..c81d7b915a4224725ed4948b94f8dffbcc960c3d 100644 (file)
@@ -26,11 +26,11 @@ shouldThrow("contextA.detachShader(programB, shaderA)");
 shouldThrow("contextA.detachShader(programB, shaderB)");
 shouldThrow("contextA.shaderSource(shaderB, 'foo')");
 shouldThrow("contextA.bindAttribLocation(programB, 0, 'foo')");
 shouldThrow("contextA.detachShader(programB, shaderB)");
 shouldThrow("contextA.shaderSource(shaderB, 'foo')");
 shouldThrow("contextA.bindAttribLocation(programB, 0, 'foo')");
-shouldThrow("contextA.bindFramebuffer(0, frameBufferB)");
-shouldThrow("contextA.bindRenderbuffer(0, renderBufferB)");
-shouldThrow("contextA.bindTexture(textureB)");
-shouldThrow("contextA.framebufferRenderbuffer(0, 0, renderBufferB)");
-shouldThrow("contextA.framebufferTexture2D(0, 0, textureB)");
+shouldThrow("contextA.bindFramebuffer(contextA.FRAMEBUFFER, frameBufferB)");
+shouldThrow("contextA.bindRenderbuffer(contextA.RENDERBUFFER, renderBufferB)");
+shouldThrow("contextA.bindTexture(contextA.TEXTURE_2D, textureB)");
+shouldThrow("contextA.framebufferRenderbuffer(contextA.FRAMEBUFFER, contextA.DEPTH_ATTACHMENT, contextA.RENDERBUFFER, renderBufferB)");
+shouldThrow("contextA.framebufferTexture2D(contextA.FRAMEBUFFER, contextA.COLOR_ATTACHMENT0, contextA.TEXTURE_2D, textureB, 0)");
 shouldThrow("contextA.getProgrami(programB, 0)");
 shouldThrow("contextA.getProgramiv(programB, 0)");
 shouldThrow("contextA.getProgramInfoLog(programB, 0)");
 shouldThrow("contextA.getProgrami(programB, 0)");
 shouldThrow("contextA.getProgramiv(programB, 0)");
 shouldThrow("contextA.getProgramInfoLog(programB, 0)");
index 5463d0e863b20a45dc1e98d78ba075c97efe66a9..47b23d2b2b8ff806082691dd4c215dc6a83d07b6 100644 (file)
@@ -14,12 +14,12 @@ shouldThrow("context.detachShader(undefined, shader)");
 shouldThrow("context.shaderSource()");
 shouldThrow("context.shaderSource(undefined, 'foo')");
 shouldThrow("context.bindAttribLocation(undefined, 0, 'foo')");
 shouldThrow("context.shaderSource()");
 shouldThrow("context.shaderSource(undefined, 'foo')");
 shouldThrow("context.bindAttribLocation(undefined, 0, 'foo')");
-shouldThrow("context.bindBuffer(0)");
-shouldThrow("context.bindFramebuffer(0)");
-shouldThrow("context.bindRenderbuffer(0)");
-shouldThrow("context.bindTexture(0)");
-shouldThrow("context.framebufferRenderbuffer(0, 0, 0)");
-shouldThrow("context.framebufferTexture2D(0, 0, 0)");
+shouldBeUndefined("context.bindBuffer(context.ARRAY_BUFFER, 0)");
+shouldBeUndefined("context.bindFramebuffer(context.FRAMEBUFFER, 0)");
+shouldBeUndefined("context.bindRenderbuffer(context.RENDERBUFFER, 0)");
+shouldBeUndefined("context.bindTexture(context.TEXTURE_2D, 0)");
+shouldBeUndefined("context.framebufferRenderbuffer(context.FRAMEBUFFER, context.DEPTH_ATTACHMENT, context.RENDERBUFFER, 0)");
+shouldBeUndefined("context.framebufferTexture2D(context.FRAMEBUFFER, context.COLOR_ATTACHMENT0, context.TEXTURE_2D, 0, 0)");
 shouldThrow("context.getProgrami(undefined, 0)");
 shouldThrow("context.getProgramiv(undefined, 0)");
 shouldThrow("context.getProgramInfoLog(undefined, 0)");
 shouldThrow("context.getProgrami(undefined, 0)");
 shouldThrow("context.getProgramiv(undefined, 0)");
 shouldThrow("context.getProgramInfoLog(undefined, 0)");
index 4892a43b062a0fead97d59233aa827fc84486c1b..962ba8ea5e76bb9ce48ffe48d1e62937803ea688 100644 (file)
@@ -1,3 +1,26 @@
+2009-11-02  Chris Marrin  <cmarrin@apple.com>
+
+        Reviewed by Oliver Hunt.
+
+        Exception checks were being too aggressive
+        https://bugs.webkit.org/show_bug.cgi?id=31005
+
+        Several calls in CanvasRenderingContext3D are allowed to
+        have a null value passed, which indicated that the 
+        object is being unbound. Handle this case and the corresponding
+        null handling in GraphicsContext3DMac.
+
+        * html/canvas/CanvasRenderingContext3D.cpp:
+        (WebCore::CanvasRenderingContext3D::bindBuffer):
+        (WebCore::CanvasRenderingContext3D::bindFramebuffer):
+        (WebCore::CanvasRenderingContext3D::bindRenderbuffer):
+        (WebCore::CanvasRenderingContext3D::bindTexture):
+        (WebCore::CanvasRenderingContext3D::framebufferRenderbuffer):
+        (WebCore::CanvasRenderingContext3D::framebufferTexture2D):
+        * platform/graphics/mac/GraphicsContext3DMac.cpp:
+        (WebCore::GraphicsContext3D::framebufferRenderbuffer):
+        (WebCore::GraphicsContext3D::framebufferTexture2D):
+
 2009-11-02  Patrick Mueller  <Patrick_Mueller@us.ibm.com>
 
         Reviewed by Timothy Hatcher.
 2009-11-02  Patrick Mueller  <Patrick_Mueller@us.ibm.com>
 
         Reviewed by Timothy Hatcher.
index 4e1fa28de099cc4e40563c805a4a8ee35f8a4d29..7b1703999e71fb5ea49e28f2c2ce1621a23fa07a 100644 (file)
@@ -151,7 +151,7 @@ void CanvasRenderingContext3D::bindAttribLocation(CanvasProgram* program, unsign
 
 void CanvasRenderingContext3D::bindBuffer(unsigned long target, CanvasBuffer* buffer, ExceptionCode& ec)
 {
 
 void CanvasRenderingContext3D::bindBuffer(unsigned long target, CanvasBuffer* buffer, ExceptionCode& ec)
 {
-    if (!buffer || buffer->context() != this) {
+    if (buffer && buffer->context() != this) {
         ec = TYPE_MISMATCH_ERR;
         return;
     }
         ec = TYPE_MISMATCH_ERR;
         return;
     }
@@ -162,7 +162,7 @@ void CanvasRenderingContext3D::bindBuffer(unsigned long target, CanvasBuffer* bu
 
 void CanvasRenderingContext3D::bindFramebuffer(unsigned long target, CanvasFramebuffer* buffer, ExceptionCode& ec)
 {
 
 void CanvasRenderingContext3D::bindFramebuffer(unsigned long target, CanvasFramebuffer* buffer, ExceptionCode& ec)
 {
-    if (!buffer || buffer->context() != this) {
+    if (buffer && buffer->context() != this) {
         ec = TYPE_MISMATCH_ERR;
         return;
     }
         ec = TYPE_MISMATCH_ERR;
         return;
     }
@@ -172,7 +172,7 @@ void CanvasRenderingContext3D::bindFramebuffer(unsigned long target, CanvasFrame
 
 void CanvasRenderingContext3D::bindRenderbuffer(unsigned long target, CanvasRenderbuffer* renderBuffer, ExceptionCode& ec)
 {
 
 void CanvasRenderingContext3D::bindRenderbuffer(unsigned long target, CanvasRenderbuffer* renderBuffer, ExceptionCode& ec)
 {
-    if (!renderBuffer || renderBuffer->context() != this) {
+    if (renderBuffer && renderBuffer->context() != this) {
         ec = TYPE_MISMATCH_ERR;
         return;
     }
         ec = TYPE_MISMATCH_ERR;
         return;
     }
@@ -183,7 +183,7 @@ void CanvasRenderingContext3D::bindRenderbuffer(unsigned long target, CanvasRend
 
 void CanvasRenderingContext3D::bindTexture(unsigned long target, CanvasTexture* texture, ExceptionCode& ec)
 {
 
 void CanvasRenderingContext3D::bindTexture(unsigned long target, CanvasTexture* texture, ExceptionCode& ec)
 {
-    if (!texture || texture->context() != this) {
+    if (texture && texture->context() != this) {
         ec = TYPE_MISMATCH_ERR;
         return;
     }
         ec = TYPE_MISMATCH_ERR;
         return;
     }
@@ -489,7 +489,7 @@ void CanvasRenderingContext3D::flush()
 
 void CanvasRenderingContext3D::framebufferRenderbuffer(unsigned long target, unsigned long attachment, unsigned long renderbuffertarget, CanvasRenderbuffer* buffer, ExceptionCode& ec)
 {
 
 void CanvasRenderingContext3D::framebufferRenderbuffer(unsigned long target, unsigned long attachment, unsigned long renderbuffertarget, CanvasRenderbuffer* buffer, ExceptionCode& ec)
 {
-    if (!buffer || buffer->context() != this) {
+    if (buffer && buffer->context() != this) {
         ec = TYPE_MISMATCH_ERR;
         return;
     }       
         ec = TYPE_MISMATCH_ERR;
         return;
     }       
@@ -499,7 +499,7 @@ void CanvasRenderingContext3D::framebufferRenderbuffer(unsigned long target, uns
 
 void CanvasRenderingContext3D::framebufferTexture2D(unsigned long target, unsigned long attachment, unsigned long textarget, CanvasTexture* texture, long level, ExceptionCode& ec)
 {
 
 void CanvasRenderingContext3D::framebufferTexture2D(unsigned long target, unsigned long attachment, unsigned long textarget, CanvasTexture* texture, long level, ExceptionCode& ec)
 {
-    if (!texture || texture->context() != this) {
+    if (texture && texture->context() != this) {
         ec = TYPE_MISMATCH_ERR;
         return;
     }
         ec = TYPE_MISMATCH_ERR;
         return;
     }
index 9afc0b6b5239ba0c589f87c68e96e0f02c13fccc..d479f96f34d31ac6b086f617899ab1ed4fac10e6 100644 (file)
@@ -478,18 +478,14 @@ void GraphicsContext3D::flush()
 
 void GraphicsContext3D::framebufferRenderbuffer(unsigned long target, unsigned long attachment, unsigned long renderbuffertarget, CanvasRenderbuffer* buffer)
 {
 
 void GraphicsContext3D::framebufferRenderbuffer(unsigned long target, unsigned long attachment, unsigned long renderbuffertarget, CanvasRenderbuffer* buffer)
 {
-    ASSERT(buffer);
-
     ensureContext(m_contextObj);
     ensureContext(m_contextObj);
-    ::glFramebufferRenderbufferEXT(target, attachment, renderbuffertarget, (GLuint) buffer->object());
+    ::glFramebufferRenderbufferEXT(target, attachment, renderbuffertarget, buffer ? (GLuint) buffer->object() : 0);
 }
 
 void GraphicsContext3D::framebufferTexture2D(unsigned long target, unsigned long attachment, unsigned long textarget, CanvasTexture* texture, long level)
 {
 }
 
 void GraphicsContext3D::framebufferTexture2D(unsigned long target, unsigned long attachment, unsigned long textarget, CanvasTexture* texture, long level)
 {
-    ASSERT(texture);
-    
     ensureContext(m_contextObj);
     ensureContext(m_contextObj);
-    ::glFramebufferTexture2DEXT(target, attachment, textarget, (GLuint) texture->object(), level);
+    ::glFramebufferTexture2DEXT(target, attachment, textarget, texture ? (GLuint) texture->object() : 0, level);
 }
 
 void GraphicsContext3D::frontFace(unsigned long mode)
 }
 
 void GraphicsContext3D::frontFace(unsigned long mode)