diff --git a/components/script/dom/webglrenderingcontext.rs b/components/script/dom/webglrenderingcontext.rs index 672ada20b08..ac2ef4ea218 100644 --- a/components/script/dom/webglrenderingcontext.rs +++ b/components/script/dom/webglrenderingcontext.rs @@ -3613,7 +3613,7 @@ impl WebGLRenderingContextMethods for WebGLRenderingContext { height: i32, format: u32, data_type: u32, - mut pixels: CustomAutoRooterGuard>, + pixels: CustomAutoRooterGuard>, ) -> ErrorResult { let validator = TexImage2DValidator::new(self, target, level, format, width, height, @@ -3644,10 +3644,11 @@ impl WebGLRenderingContextMethods for WebGLRenderingContext { // If data is null, a buffer of sufficient size // initialized to 0 is passed. - let buff = match *pixels { - None => vec![0u8; expected_byte_length as usize], - Some(ref mut data) => data.to_vec(), - }; + let buff = handle_potential_webgl_error!( + self, + pixels.as_ref().map(|p| p.to_vec()).ok_or(InvalidValue), + return Ok(()) + ); // From the WebGL spec: // diff --git a/tests/wpt/webgl/meta/conformance/textures/misc/tex-sub-image-2d-bad-args.html.ini b/tests/wpt/webgl/meta/conformance/textures/misc/tex-sub-image-2d-bad-args.html.ini index ba0e399016a..dc6a8f4d77c 100644 --- a/tests/wpt/webgl/meta/conformance/textures/misc/tex-sub-image-2d-bad-args.html.ini +++ b/tests/wpt/webgl/meta/conformance/textures/misc/tex-sub-image-2d-bad-args.html.ini @@ -1,7 +1,4 @@ [tex-sub-image-2d-bad-args.html] - [WebGL test #9: getError expected: INVALID_VALUE. Was NO_ERROR : null pixels] - expected: FAIL - [WebGL test #0: getError expected: INVALID_OPERATION. Was INVALID_VALUE : no previously defined texture image] expected: FAIL