From daa64bf84f1f17e82e77bea896bf86a6b2a6672d Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Sat, 31 Dec 2016 11:08:27 -0800 Subject: [PATCH] webgl: Validate enums for blendEquation. Improves a conformance test that tried passing in desktop GL enums for blending. --- components/script/dom/webglrenderingcontext.rs | 8 ++++++++ .../conformance/state/gl-enum-tests.html.ini | 18 ------------------ 2 files changed, 8 insertions(+), 18 deletions(-) diff --git a/components/script/dom/webglrenderingcontext.rs b/components/script/dom/webglrenderingcontext.rs index 81dfe8042782..7ac39c13e1fb 100644 --- a/components/script/dom/webglrenderingcontext.rs +++ b/components/script/dom/webglrenderingcontext.rs @@ -788,11 +788,19 @@ impl WebGLRenderingContextMethods for WebGLRenderingContext { // https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.3 fn BlendEquation(&self, mode: u32) { + if mode != constants::FUNC_ADD { + return self.webgl_error(InvalidEnum); + } + self.ipc_renderer.send(CanvasMsg::WebGL(WebGLCommand::BlendEquation(mode))).unwrap(); } // https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.3 fn BlendEquationSeparate(&self, mode_rgb: u32, mode_alpha: u32) { + if mode_rgb != constants::FUNC_ADD || mode_alpha != constants::FUNC_ADD { + return self.webgl_error(InvalidEnum); + } + self.ipc_renderer .send(CanvasMsg::WebGL(WebGLCommand::BlendEquationSeparate(mode_rgb, mode_alpha))) .unwrap(); diff --git a/tests/wpt/metadata/webgl/conformance-1.0.3/conformance/state/gl-enum-tests.html.ini b/tests/wpt/metadata/webgl/conformance-1.0.3/conformance/state/gl-enum-tests.html.ini index 7683cb3d1f10..fec9fde18b1f 100644 --- a/tests/wpt/metadata/webgl/conformance-1.0.3/conformance/state/gl-enum-tests.html.ini +++ b/tests/wpt/metadata/webgl/conformance-1.0.3/conformance/state/gl-enum-tests.html.ini @@ -1,24 +1,6 @@ [gl-enum-tests.html] type: testharness expected: ERROR - [WebGL test #3: getError expected: INVALID_ENUM. Was NO_ERROR : gl.blendEquation(desktopGL['MIN'\]) should return INVALID_ENUM.] - expected: FAIL - - [WebGL test #4: getError expected: INVALID_ENUM. Was NO_ERROR : gl.blendEquation(desktopGL['MAX'\]) should return INVALID_ENUM.] - expected: FAIL - - [WebGL test #5: getError expected: INVALID_ENUM. Was NO_ERROR : gl.blendEquationSeparate(desktopGL['MIN'\], gl.FUNC_ADD) should return INVALID_ENUM.] - expected: FAIL - - [WebGL test #6: getError expected: INVALID_ENUM. Was NO_ERROR : gl.blendEquationSeparate(desktopGL['MAX'\], gl.FUNC_ADD) should return INVALID_ENUM.] - expected: FAIL - - [WebGL test #7: getError expected: INVALID_ENUM. Was NO_ERROR : gl.blendEquationSeparate(gl.FUNC_ADD, desktopGL['MIN'\]) should return INVALID_ENUM.] - expected: FAIL - - [WebGL test #8: getError expected: INVALID_ENUM. Was NO_ERROR : gl.blendEquationSeparate(gl.FUNC_ADD, desktopGL['MAX'\]) should return INVALID_ENUM.] - expected: FAIL - [WebGL test #9: successfullyParsed should be true (of type boolean). Was undefined (of type undefined).] expected: FAIL