From 68898f4ebd1a9112b7281ec766a725e24c62205e Mon Sep 17 00:00:00 2001 From: Anthony Ramine Date: Mon, 9 Apr 2018 11:46:12 +0200 Subject: [PATCH 1/4] Fix the error emitted for invalid targets in WebGLTexture::bind It doesn't actually matter because this is only called from WebGLRenderingContext::BindTexture, which already checks the target, but better be safe than sorry. --- components/script/dom/webgltexture.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/script/dom/webgltexture.rs b/components/script/dom/webgltexture.rs index ef980c75211..45b26997bc3 100644 --- a/components/script/dom/webgltexture.rs +++ b/components/script/dom/webgltexture.rs @@ -109,7 +109,7 @@ impl WebGLTexture { let face_count = match target { constants::TEXTURE_2D => 1, constants::TEXTURE_CUBE_MAP => 6, - _ => return Err(WebGLError::InvalidOperation) + _ => return Err(WebGLError::InvalidEnum) }; self.face_count.set(face_count); self.target.set(Some(target)); From fcb6d5112e62e74cf224e88d8693dce6983b281e Mon Sep 17 00:00:00 2001 From: Anthony Ramine Date: Mon, 9 Apr 2018 11:55:32 +0200 Subject: [PATCH 2/4] Properly check for cubic dimensions in gl.copyTexImage2D --- .../script/dom/webgl_validations/tex_image_2d.rs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/components/script/dom/webgl_validations/tex_image_2d.rs b/components/script/dom/webgl_validations/tex_image_2d.rs index dc180729902..8a1b9ad9c16 100644 --- a/components/script/dom/webgl_validations/tex_image_2d.rs +++ b/components/script/dom/webgl_validations/tex_image_2d.rs @@ -151,6 +151,13 @@ impl<'a> WebGLValidator for CommonTexImage2DValidator<'a> { } }; + // GL_INVALID_VALUE is generated if target is one of the six cube map 2D + // image targets and the width and height parameters are not equal. + if target.is_cubic() && self.width != self.height { + self.context.webgl_error(InvalidValue); + return Err(TexImageValidationError::InvalidCubicTextureDimensions); + } + // GL_INVALID_VALUE is generated if level is less than 0. if self.level < 0 { self.context.webgl_error(InvalidValue); @@ -287,13 +294,6 @@ impl<'a> WebGLValidator for TexImage2DValidator<'a> { border, } = self.common_validator.validate()?; - // GL_INVALID_VALUE is generated if target is one of the six cube map 2D - // image targets and the width and height parameters are not equal. - if target.is_cubic() && width != height { - context.webgl_error(InvalidValue); - return Err(TexImageValidationError::InvalidCubicTextureDimensions); - } - // GL_INVALID_ENUM is generated if format or data_type is not an // accepted value. let data_type = match TexDataType::from_gl_constant(self.data_type) { From 561c41097fc5577f9747a205af29e443ace73a0a Mon Sep 17 00:00:00 2001 From: Anthony Ramine Date: Mon, 9 Apr 2018 14:29:11 +0200 Subject: [PATCH 3/4] Fix filtering of reserved WebGL names in gl.getAttribLocation --- components/script/dom/webglprogram.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/components/script/dom/webglprogram.rs b/components/script/dom/webglprogram.rs index 115b866b984..88e03f6330c 100644 --- a/components/script/dom/webglprogram.rs +++ b/components/script/dom/webglprogram.rs @@ -306,7 +306,8 @@ impl WebGLProgram { return Err(WebGLError::InvalidOperation); } - if name.starts_with("webgl") || name.starts_with("_webgl_") { + // https://www.khronos.org/registry/webgl/specs/latest/1.0/#GLSL_CONSTRUCTS + if name.starts_with("webgl_") || name.starts_with("_webgl_") { return Ok(None); } From f837354cb765f3e63783b845be128c187b53b596 Mon Sep 17 00:00:00 2001 From: Anthony Ramine Date: Mon, 9 Apr 2018 15:52:56 +0200 Subject: [PATCH 4/4] Do not emit a WebGL error for "gl_" prefixed names in gl.getAttribLocation --- components/script/dom/webglprogram.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/script/dom/webglprogram.rs b/components/script/dom/webglprogram.rs index 88e03f6330c..3d4cb5f593c 100644 --- a/components/script/dom/webglprogram.rs +++ b/components/script/dom/webglprogram.rs @@ -303,7 +303,7 @@ impl WebGLProgram { // Check if the name is reserved if name.starts_with("gl_") { - return Err(WebGLError::InvalidOperation); + return Ok(None); } // https://www.khronos.org/registry/webgl/specs/latest/1.0/#GLSL_CONSTRUCTS