From 183cc4c03505277a4dd2c95d2a1446cb56e14e7e Mon Sep 17 00:00:00 2001 From: Anthony Ramine Date: Thu, 5 Apr 2018 17:39:53 +0200 Subject: [PATCH 1/3] Properly check for invalid targets in gl.BindFramebuffer It should always emit InvalidEnum, not InvalidOperation. --- components/script/dom/webglrenderingcontext.rs | 7 +------ .../conformance2/renderbuffers/framebuffer-test.html.ini | 2 +- 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/components/script/dom/webglrenderingcontext.rs b/components/script/dom/webglrenderingcontext.rs index 1fbc49fcb03..a425be8c873 100644 --- a/components/script/dom/webglrenderingcontext.rs +++ b/components/script/dom/webglrenderingcontext.rs @@ -11,7 +11,6 @@ use canvas_traits::webgl::DOMToTextureCommand; use canvas_traits::webgl::WebGLError::*; use canvas_traits::webgl::webgl_channel; use dom::bindings::cell::DomRefCell; -use dom::bindings::codegen::Bindings::WebGL2RenderingContextBinding::WebGL2RenderingContextConstants as WebGL2Constants; use dom::bindings::codegen::Bindings::WebGLRenderingContextBinding::{self, WebGLContextAttributes}; use dom::bindings::codegen::Bindings::WebGLRenderingContextBinding::WebGLRenderingContextConstants as constants; use dom::bindings::codegen::Bindings::WebGLRenderingContextBinding::WebGLRenderingContextMethods; @@ -1576,12 +1575,8 @@ impl WebGLRenderingContextMethods for WebGLRenderingContext { // https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.6 fn BindFramebuffer(&self, target: u32, framebuffer: Option<&WebGLFramebuffer>) { - if target == WebGL2Constants::READ_FRAMEBUFFER { - return self.webgl_error(InvalidEnum); - } - if target != constants::FRAMEBUFFER { - return self.webgl_error(InvalidOperation); + return self.webgl_error(InvalidEnum); } if let Some(framebuffer) = framebuffer { diff --git a/tests/wpt/mozilla/meta/webgl/conformance-2.0.0/conformance2/renderbuffers/framebuffer-test.html.ini b/tests/wpt/mozilla/meta/webgl/conformance-2.0.0/conformance2/renderbuffers/framebuffer-test.html.ini index 3f29b3b4a77..9aa6764538b 100644 --- a/tests/wpt/mozilla/meta/webgl/conformance-2.0.0/conformance2/renderbuffers/framebuffer-test.html.ini +++ b/tests/wpt/mozilla/meta/webgl/conformance-2.0.0/conformance2/renderbuffers/framebuffer-test.html.ini @@ -95,6 +95,6 @@ [WebGL test #55: getError expected: NO_ERROR. Was INVALID_ENUM : bind read framebuffer to default (null) framebuffer.] expected: FAIL - [WebGL test #56: getError expected: NO_ERROR. Was INVALID_OPERATION : bind draw framebuffer to default (null) framebuffer.] + [WebGL test #56: getError expected: NO_ERROR. Was INVALID_ENUM : bind draw framebuffer to default (null) framebuffer.] expected: FAIL From ac85d1255d1fa714fde05afab85e0480327b713b Mon Sep 17 00:00:00 2001 From: Anthony Ramine Date: Thu, 5 Apr 2018 18:01:09 +0200 Subject: [PATCH 2/3] Emit InvalidEnum for invalid targets passed to gl.renderbufferStorage --- components/script/dom/webglrenderingcontext.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/script/dom/webglrenderingcontext.rs b/components/script/dom/webglrenderingcontext.rs index a425be8c873..5deace85746 100644 --- a/components/script/dom/webglrenderingcontext.rs +++ b/components/script/dom/webglrenderingcontext.rs @@ -3518,7 +3518,7 @@ impl WebGLRenderingContextMethods for WebGLRenderingContext { // // "target must be RENDERBUFFER." if target != constants::RENDERBUFFER { - return self.webgl_error(InvalidOperation) + return self.webgl_error(InvalidEnum); } // From the GLES 2.0.25 spec: From e8f19fa7fcf0b51debbd33b0c0cf5f6b2c3bf82d Mon Sep 17 00:00:00 2001 From: Anthony Ramine Date: Thu, 5 Apr 2018 18:01:32 +0200 Subject: [PATCH 3/3] Properly check the right internal formats in gl.renderbufferStorage --- components/script/dom/webglrenderbuffer.rs | 11 +++++++---- .../textures/tex-input-validation.html.ini | 14 +++++++++++--- 2 files changed, 18 insertions(+), 7 deletions(-) diff --git a/components/script/dom/webglrenderbuffer.rs b/components/script/dom/webglrenderbuffer.rs index feac4eed416..a672f9faa72 100644 --- a/components/script/dom/webglrenderbuffer.rs +++ b/components/script/dom/webglrenderbuffer.rs @@ -95,11 +95,14 @@ impl WebGLRenderbuffer { // validation. match internal_format { constants::RGBA4 | - constants::DEPTH_STENCIL | + constants::RGB565 | + constants::RGB5_A1 | constants::DEPTH_COMPONENT16 | - constants::STENCIL_INDEX8 => - self.internal_format.set(Some(internal_format)), - + constants::STENCIL_INDEX8 | + // https://www.khronos.org/registry/webgl/specs/latest/1.0/#6.7 + constants::DEPTH_STENCIL => { + self.internal_format.set(Some(internal_format)) + } _ => return Err(WebGLError::InvalidEnum), }; diff --git a/tests/wpt/mozilla/meta/webgl/conformance-1.0.3/conformance/textures/tex-input-validation.html.ini b/tests/wpt/mozilla/meta/webgl/conformance-1.0.3/conformance/textures/tex-input-validation.html.ini index fce3bfa64ff..4d390acaba6 100644 --- a/tests/wpt/mozilla/meta/webgl/conformance-1.0.3/conformance/textures/tex-input-validation.html.ini +++ b/tests/wpt/mozilla/meta/webgl/conformance-1.0.3/conformance/textures/tex-input-validation.html.ini @@ -1,9 +1,17 @@ [tex-input-validation.html] type: testharness - expected: CRASH - [WebGL test #3: successfullyParsed should be true (of type boolean). Was undefined (of type undefined).] + [WebGL test #34: getError expected: INVALID_OPERATION. Was NO_ERROR : colorBufferFormat: RGB565 internalFormat: RGBA target: TEXTURE_2D border: 0] expected: FAIL - [WebGL test #20: successfullyParsed should be true (of type boolean). Was undefined (of type undefined).] + [WebGL test #37: getError expected: NO_ERROR. Was INVALID_OPERATION : colorBufferFormat: RGB565 internalFormat: RGB target: TEXTURE_2D border: 0] + expected: FAIL + + [WebGL test #45: getError expected: INVALID_OPERATION. Was NO_ERROR : colorBufferFormat: RGB565 internalFormat: RGBA target: TEXTURE_2D] + expected: FAIL + + [WebGL test #53: getError expected: INVALID_OPERATION. Was NO_ERROR : colorBufferFormat: RGB internalFormat: RGBA] + expected: FAIL + + [WebGL test #61: getError expected: INVALID_OPERATION. Was NO_ERROR : colorBufferFormat: RGB internalFormat: RGBA] expected: FAIL