b=593850; [webgl] fix bad-arguments and null-object-behaviour tests; r=bjacob, a=b
authorVladimir Vukicevic <vladimir@pobox.com>
Mon, 13 Sep 2010 08:57:25 -0700
changeset 53701 3badb0070357b37bfbafea16489f7d8e889c5d2b
parent 53700 97e3f3152c536a35d7dc24e5d78f889eade9bff6
child 53702 e931499f28ebe939db16699ee1284ace466f0e7e
push idunknown
push userunknown
push dateunknown
reviewersbjacob, b
bugs593850
milestone2.0b6pre
b=593850; [webgl] fix bad-arguments and null-object-behaviour tests; r=bjacob, a=b
content/canvas/src/WebGLContextGL.cpp
content/canvas/test/webgl/failing_tests.txt
dom/interfaces/canvas/nsICanvasRenderingContextWebGL.idl
--- a/content/canvas/src/WebGLContextGL.cpp
+++ b/content/canvas/src/WebGLContextGL.cpp
@@ -145,16 +145,20 @@ WebGLContext::ActiveTexture(WebGLenum te
     mActiveTexture = texture - LOCAL_GL_TEXTURE0;
     gl->fActiveTexture(texture);
     return NS_OK;
 }
 
 NS_IMETHODIMP
 WebGLContext::AttachShader(nsIWebGLProgram *pobj, nsIWebGLShader *shobj)
 {
+    // if pobj or shobj are null/not specified, it's an error
+    if (pobj == nsnull || shobj == nsnull)
+        return ErrorInvalidValue("attachShader");
+
     WebGLuint progname, shadername;
     WebGLProgram *program;
     WebGLShader *shader;
     if (!GetConcreteObjectAndGLName("attachShader: program", pobj, &program, &progname) ||
         !GetConcreteObjectAndGLName("attachShader: shader", shobj, &shader, &shadername))
         return NS_OK;
 
     if (!program->AttachShader(shader))
@@ -2088,24 +2092,27 @@ WebGLContext::TexParameteri(WebGLenum ta
     return TexParameter_base(target, pname, &param, nsnull);
 }
 
 NS_IMETHODIMP
 WebGLContext::GetTexParameter(WebGLenum target, WebGLenum pname, nsIVariant **retval)
 {
     *retval = nsnull;
 
-    nsCOMPtr<nsIWritableVariant> wrval = do_CreateInstance("@mozilla.org/variant;1");
-    NS_ENSURE_TRUE(wrval, NS_ERROR_FAILURE);
-
     MakeContextCurrent();
 
     if (!ValidateTextureTargetEnum(target, "getTexParameter: target"))
         return NS_OK;
 
+    if (!activeBoundTextureForTarget(target))
+        return ErrorInvalidOperation("getTexParameter: no texture bound");
+
+    nsCOMPtr<nsIWritableVariant> wrval = do_CreateInstance("@mozilla.org/variant;1");
+    NS_ENSURE_TRUE(wrval, NS_ERROR_FAILURE);
+
     switch (pname) {
         case LOCAL_GL_TEXTURE_MIN_FILTER:
         case LOCAL_GL_TEXTURE_MAG_FILTER:
         case LOCAL_GL_TEXTURE_WRAP_S:
         case LOCAL_GL_TEXTURE_WRAP_T:
         {
             GLint i = 0;
             gl->fGetTexParameteriv(target, pname, &i);
@@ -3143,17 +3150,16 @@ WebGLContext::Viewport(WebGLint x, WebGL
     return NS_OK;
 }
 
 NS_IMETHODIMP
 WebGLContext::CompileShader(nsIWebGLShader *sobj)
 {
     WebGLShader *shader;
     WebGLuint shadername;
-
     if (!GetConcreteObjectAndGLName("compileShader", sobj, &shader, &shadername))
         return NS_OK;
     MakeContextCurrent();
 
 #if defined(USE_ANGLE)
     if (shader->NeedsTranslation() && mShaderValidation) {
         ShHandle compiler = 0;
         int debugFlags = 0;
--- a/content/canvas/test/webgl/failing_tests.txt
+++ b/content/canvas/test/webgl/failing_tests.txt
@@ -1,12 +1,11 @@
 conformance/array-buffer-crash.html
 conformance/array-buffer-view-crash.html
 conformance/array-unit-tests.html
-conformance/bad-arguments-test.html
 conformance/canvas-test.html
 conformance/constants.html
 conformance/context-attributes-alpha-depth-stencil-antialias.html
 conformance/context-attributes.html
 conformance/context-type-test.html
 conformance/framebuffer-object-attachment.html
 conformance/get-active-test.html
 conformance/gl-bind-attrib-location-test.html
@@ -15,17 +14,16 @@ conformance/gl-get-active-attribute.html
 conformance/gl-get-calls.html
 conformance/gl-object-get-calls.html
 conformance/gl-teximage.html
 conformance/gl-unknown-uniform.html
 conformance/glsl-2types-of-textures-on-same-unit.html
 conformance/glsl-conformance.html
 conformance/invalid-passed-params.html
 conformance/methods.html
-conformance/null-object-behaviour.html
 conformance/point-size.html
 conformance/program-test.html
 conformance/read-pixels-pack-alignment.html
 conformance/tex-image-and-sub-image-2d-with-array-buffer-view.html
 conformance/tex-image-and-sub-image-2d-with-image-data.html
 conformance/tex-image-and-sub-image-2d-with-video.html
 conformance/tex-image-with-format-and-type.html
 conformance/tex-image-with-invalid-data.html
--- a/dom/interfaces/canvas/nsICanvasRenderingContextWebGL.idl
+++ b/dom/interfaces/canvas/nsICanvasRenderingContextWebGL.idl
@@ -128,30 +128,16 @@ interface nsIWebGLUniformLocation : nsIS
     [noscript] attribute WebGLint location;
 };
 
 
 [scriptable, uuid(2f21ca21-9720-4eee-ad94-27eefe4f72dc)]
 interface nsICanvasRenderingContextWebGL : nsISupports
 {
   //
-  //  ARRAY CONSTRUCTORS
-  //
-
-  /*
-  nsIWebGLFloatArray createFloatArray();
-  nsIWebGLByteArray createByteArray();
-  nsIWebGLUnsignedByteArray createUnsignedByteArray();
-  nsIWebGLShortArray createShortArray();
-  nsIWebGLUnsignedShortArray createUnsignedShortArray();
-  nsIWebGLIntArray createIntArray();
-  nsIWebGLUnsignedIntArray createUnsignedIntArray();
-  */
-
-  //
   //  CONSTANTS
   //
 
   /* ClearBufferMask */
   const unsigned long DEPTH_BUFFER_BIT               = 0x00000100;
   const unsigned long STENCIL_BUFFER_BIT             = 0x00000400;
   const unsigned long COLOR_BUFFER_BIT               = 0x00004000;
 
@@ -159,26 +145,16 @@ interface nsICanvasRenderingContextWebGL
   const unsigned long POINTS                         = 0x0000;
   const unsigned long LINES                          = 0x0001;
   const unsigned long LINE_LOOP                      = 0x0002;
   const unsigned long LINE_STRIP                     = 0x0003;
   const unsigned long TRIANGLES                      = 0x0004;
   const unsigned long TRIANGLE_STRIP                 = 0x0005;
   const unsigned long TRIANGLE_FAN                   = 0x0006;
 
-  /* AlphaFunction (not supported in ES20) */
-  /*      GL_NEVER */
-  /*      GL_LESS */
-  /*      GL_EQUAL */
-  /*      GL_LEQUAL */
-  /*      GL_GREATER */
-  /*      GL_NOTEQUAL */
-  /*      GL_GEQUAL */
-  /*      GL_ALWAYS */
-
   /* BlendingFactorDest */
   const unsigned long ZERO                           = 0;
   const unsigned long ONE                            = 1;
   const unsigned long SRC_COLOR                      = 0x0300;
   const unsigned long ONE_MINUS_SRC_COLOR            = 0x0301;
   const unsigned long SRC_ALPHA                      = 0x0302;
   const unsigned long ONE_MINUS_SRC_ALPHA            = 0x0303;
   const unsigned long DST_ALPHA                      = 0x0304;
@@ -578,17 +554,17 @@ interface nsICanvasRenderingContextWebGL
   readonly attribute nsIDOMHTMLCanvasElement canvas;
 
   //
   //  METHODS
   //
   void present();
 
   void activeTexture(in WebGLenum texture);
-  void attachShader(in nsIWebGLProgram program, in nsIWebGLShader shader);
+  void attachShader([optional] in nsIWebGLProgram program, [optional] in nsIWebGLShader shader);
   void bindAttribLocation(in nsIWebGLProgram program, in WebGLuint index, in DOMString name);
   void bindBuffer(in WebGLenum target, in nsIWebGLBuffer buffer);
   void bindFramebuffer(in WebGLenum target, in nsIWebGLFramebuffer framebuffer);
   void bindRenderbuffer(in WebGLenum target, in nsIWebGLRenderbuffer renderbuffer);
   void bindTexture(in WebGLenum target, in nsIWebGLTexture texture);
   void blendColor(in WebGLclampf red, in WebGLclampf green, in WebGLclampf blue, in WebGLclampf alpha);
   void blendEquation(in WebGLenum mode);
   void blendEquationSeparate(in WebGLenum modeRGB, in WebGLenum modeAlpha);
@@ -606,17 +582,17 @@ interface nsICanvasRenderingContextWebGL
   [noscript] void bufferSubData_array(in WebGLenum target, in long offset, in WebGLArrayPtr data);
 
   WebGLenum checkFramebufferStatus(in WebGLenum target);
   void clear(in WebGLbitfield mask);
   void clearColor(in WebGLclampf red, in WebGLclampf green, in WebGLclampf blue, in WebGLclampf alpha);
   void clearDepth(in WebGLclampf depth);
   void clearStencil(in WebGLint s);
   void colorMask(in WebGLboolean red, in WebGLboolean green, in WebGLboolean blue, in WebGLboolean alpha);
-  void compileShader(in nsIWebGLShader shader);
+  void compileShader([optional] in nsIWebGLShader shader);
 
   void copyTexImage2D(in WebGLenum target, in WebGLint level, in WebGLenum internalformat, 
                       in WebGLint x, in WebGLint y, in WebGLsizei width, in WebGLsizei height, in WebGLint border);
   void copyTexSubImage2D(in WebGLenum target, in WebGLint level, in WebGLint xoffset, in WebGLint yoffset, 
                          in WebGLint x, in WebGLint y, in WebGLsizei width, in WebGLsizei height);
 
   nsIWebGLBuffer createBuffer();
   nsIWebGLProgram createProgram();
@@ -712,34 +688,34 @@ interface nsICanvasRenderingContextWebGL
   WebGLboolean isFramebuffer(in nsIWebGLFramebuffer framebuffer);
   WebGLboolean isProgram(in nsIWebGLProgram program);
   WebGLboolean isRenderbuffer(in nsIWebGLRenderbuffer renderbuffer);
   WebGLboolean isShader(in nsIWebGLShader shader);
   WebGLboolean isTexture(in nsIWebGLTexture texture);
 
   WebGLboolean isEnabled(in WebGLenum cap);
   void lineWidth(in WebGLfloat width);
-  void linkProgram(in nsIWebGLProgram program);
+  void linkProgram([optional] in nsIWebGLProgram program);
   void pixelStorei(in WebGLenum pname, in WebGLint param);
   void polygonOffset(in WebGLfloat factor, in WebGLfloat units);
 
   void readPixels([optional] in long dummy);
   [noscript] void readPixels_array(in WebGLint x, in WebGLint y, in WebGLsizei width, in WebGLsizei height,
                                    in WebGLenum format, in WebGLenum type, in WebGLArrayPtr pixels);
   [noscript] void readPixels_buf(in WebGLint x, in WebGLint y, in WebGLsizei width, in WebGLsizei height,
                                  in WebGLenum format, in WebGLenum type, in WebGLArrayBufferPtr pixels);
 
   //void glReleaseShaderCompiler();
 
   void renderbufferStorage(in WebGLenum target, in WebGLenum internalformat, in WebGLsizei width, in WebGLsizei height);
   void sampleCoverage(in WebGLclampf value, in WebGLboolean invert);
   void scissor(in WebGLint x, in WebGLint y, in WebGLsizei width, in WebGLsizei height);
 
   // Modified: void glShaderSource(WebGLuint shader, WebGLsizei count, const char** string, const WebGLint* length);
-  void shaderSource(in nsIWebGLShader shader, in DOMString source);
+  void shaderSource([optional] in nsIWebGLShader shader, [optional] in DOMString source);
 
   void stencilFunc(in WebGLenum func, in WebGLint ref, in WebGLuint mask);
   void stencilFuncSeparate(in WebGLenum face, in WebGLenum func, in WebGLint ref, in WebGLuint mask);
   void stencilMask(in WebGLuint mask);
   void stencilMaskSeparate(in WebGLenum face, in WebGLuint mask);
   void stencilOp(in WebGLenum fail, in WebGLenum zfail, in WebGLenum zpass);
   void stencilOpSeparate(in WebGLenum face, in WebGLenum fail, in WebGLenum zfail, in WebGLenum zpass);