diff options
3 files changed, 144 insertions, 12 deletions
diff --git a/components/script/dom/webglrenderingcontext.rs b/components/script/dom/webglrenderingcontext.rs index 204426f8063..a3a6764996c 100644 --- a/components/script/dom/webglrenderingcontext.rs +++ b/components/script/dom/webglrenderingcontext.rs @@ -1237,21 +1237,41 @@ impl WebGLRenderingContextMethods for WebGLRenderingContext { #[allow(unsafe_code)] // https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.5 - unsafe fn GetBufferParameter(&self, _cx: *mut JSContext, target: u32, parameter: u32) -> JSVal { - let parameter_matches = match parameter { - constants::BUFFER_SIZE | - constants::BUFFER_USAGE => true, - _ => false, + unsafe fn GetBufferParameter( + &self, + _cx: *mut JSContext, + target: u32, + parameter: u32, + ) -> JSVal { + let buffer = match target { + constants::ARRAY_BUFFER => self.bound_buffer_array.get(), + constants::ELEMENT_ARRAY_BUFFER => self.bound_buffer_element_array.get(), + _ => { + self.webgl_error(InvalidEnum); + return NullValue(); + } + }; + match parameter { + constants::BUFFER_SIZE | constants::BUFFER_USAGE => {}, + _ => { + self.webgl_error(InvalidEnum); + return NullValue(); + } + } + let buffer = match buffer { + Some(buffer) => buffer, + None => { + self.webgl_error(InvalidOperation); + return NullValue(); + } }; - if !parameter_matches { - self.webgl_error(InvalidEnum); - return NullValue(); + if parameter == constants::BUFFER_SIZE { + return Int32Value(buffer.capacity() as i32); } let (sender, receiver) = webgl_channel().unwrap(); self.send_command(WebGLCommand::GetBufferParameter(target, parameter, sender)); - Int32Value(receiver.recv().unwrap()) } diff --git a/tests/wpt/mozilla/meta/webgl/conformance-1.0.3/conformance/misc/null-object-behaviour.html.ini b/tests/wpt/mozilla/meta/webgl/conformance-1.0.3/conformance/misc/null-object-behaviour.html.ini index c18d4b53eb6..ffd049d0cd1 100644 --- a/tests/wpt/mozilla/meta/webgl/conformance-1.0.3/conformance/misc/null-object-behaviour.html.ini +++ b/tests/wpt/mozilla/meta/webgl/conformance-1.0.3/conformance/misc/null-object-behaviour.html.ini @@ -1,3 +1,7 @@ [null-object-behaviour.html] - type: testharness - expected: CRASH + [WebGL test #3: getError expected: INVALID_VALUE. Was NO_ERROR : after evaluating: context.linkProgram(undefined)] + expected: FAIL + + [WebGL test #38: getError expected: INVALID_OPERATION. Was INVALID_VALUE : after evaluating: context.bufferData(context.ARRAY_BUFFER, 1, context.STATIC_DRAW)] + expected: FAIL + diff --git a/tests/wpt/mozilla/meta/webgl/conformance-2.0.0/conformance2/state/gl-object-get-calls.html.ini b/tests/wpt/mozilla/meta/webgl/conformance-2.0.0/conformance2/state/gl-object-get-calls.html.ini index e283ec2b7de..e860fd3aae1 100644 --- a/tests/wpt/mozilla/meta/webgl/conformance-2.0.0/conformance2/state/gl-object-get-calls.html.ini +++ b/tests/wpt/mozilla/meta/webgl/conformance-2.0.0/conformance2/state/gl-object-get-calls.html.ini @@ -1,2 +1,110 @@ [gl-object-get-calls.html] - expected: CRASH + expected: ERROR + [WebGL test #6: gl.getBufferParameter(gl.COPY_READ_BUFFER, gl.BUFFER_SIZE) should be 16 (of type number). Was null (of type object).] + expected: FAIL + + [WebGL test #7: gl.getBufferParameter(gl.COPY_READ_BUFFER, gl.BUFFER_USAGE) should be 35048 (of type number). Was null (of type object).] + expected: FAIL + + [WebGL test #9: gl.getBufferParameter(gl.COPY_WRITE_BUFFER, gl.BUFFER_SIZE) should be 16 (of type number). Was null (of type object).] + expected: FAIL + + [WebGL test #10: gl.getBufferParameter(gl.COPY_WRITE_BUFFER, gl.BUFFER_USAGE) should be 35048 (of type number). Was null (of type object).] + expected: FAIL + + [WebGL test #12: gl.getBufferParameter(gl.PIXEL_PACK_BUFFER, gl.BUFFER_SIZE) should be 16 (of type number). Was null (of type object).] + expected: FAIL + + [WebGL test #13: gl.getBufferParameter(gl.PIXEL_PACK_BUFFER, gl.BUFFER_USAGE) should be 35048 (of type number). Was null (of type object).] + expected: FAIL + + [WebGL test #15: gl.getBufferParameter(gl.PIXEL_UNPACK_BUFFER, gl.BUFFER_SIZE) should be 16 (of type number). Was null (of type object).] + expected: FAIL + + [WebGL test #16: gl.getBufferParameter(gl.PIXEL_UNPACK_BUFFER, gl.BUFFER_USAGE) should be 35048 (of type number). Was null (of type object).] + expected: FAIL + + [WebGL test #18: gl.getBufferParameter(gl.TRANSFORM_FEEDBACK_BUFFER, gl.BUFFER_SIZE) should be 16 (of type number). Was null (of type object).] + expected: FAIL + + [WebGL test #19: gl.getBufferParameter(gl.TRANSFORM_FEEDBACK_BUFFER, gl.BUFFER_USAGE) should be 35048 (of type number). Was null (of type object).] + expected: FAIL + + [WebGL test #21: gl.getBufferParameter(gl.UNIFORM_BUFFER, gl.BUFFER_SIZE) should be 16 (of type number). Was null (of type object).] + expected: FAIL + + [WebGL test #22: gl.getBufferParameter(gl.UNIFORM_BUFFER, gl.BUFFER_USAGE) should be 35048 (of type number). Was null (of type object).] + expected: FAIL + + [WebGL test #26: getError expected: NO_ERROR. Was INVALID_ENUM : ] + expected: FAIL + + [WebGL test #28: getError expected: NO_ERROR. Was INVALID_ENUM : ] + expected: FAIL + + [WebGL test #29: gl.checkFramebufferStatus(gl.FRAMEBUFFER) should be 36053. Was 36061.] + expected: FAIL + + [WebGL test #35: gl.getFramebufferAttachmentParameter(gl.FRAMEBUFFER, gl.DEPTH_STENCIL_ATTACHMENT, gl.FRAMEBUFFER_ATTACHMENT_OBJECT_NAME) should be [object WebGLRenderbuffer\]. Was null.] + expected: FAIL + + [WebGL test #42: getError expected: INVALID_OPERATION. Was INVALID_ENUM : after evaluating: gl.getFramebufferAttachmentParameter(gl.FRAMEBUFFER, gl.DEPTH_STENCIL_ATTACHMENT, gl.FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE)] + expected: FAIL + + [WebGL test #48: gl.getFramebufferAttachmentParameter(gl.FRAMEBUFFER, gl.BACK, gl.FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE) should be 33304 (of type number). Was null (of type object).] + expected: FAIL + + [WebGL test #49: gl.getFramebufferAttachmentParameter(gl.FRAMEBUFFER, gl.DEPTH, gl.FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE) should be 33304 (of type number). Was null (of type object).] + expected: FAIL + + [WebGL test #50: gl.getFramebufferAttachmentParameter(gl.FRAMEBUFFER, gl.STENCIL, gl.FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE) should be 33304 (of type number). Was null (of type object).] + expected: FAIL + + [WebGL test #63: getError expected: NO_ERROR. Was INVALID_OPERATION : ] + expected: FAIL + + [WebGL test #64: getFramebufferAttachmentParameter did not generate INVALID_ENUM for invalid parameter enum: NO_ERROR] + expected: FAIL + + [WebGL test #65: getFramebufferAttachmentParameter did not generate INVALID_ENUM for invalid target enum: NO_ERROR] + expected: FAIL + + [WebGL test #66: getFramebufferAttachmentParameter did not generate INVALID_ENUM for invalid attachment enum: NO_ERROR] + expected: FAIL + + [WebGL test #67: getError expected: NO_ERROR. Was INVALID_ENUM : ] + expected: FAIL + + [WebGL test #69: getError expected: NO_ERROR. Was INVALID_ENUM : ] + expected: FAIL + + [WebGL test #70: gl.checkFramebufferStatus(gl.FRAMEBUFFER) should be 36053. Was 36061.] + expected: FAIL + + [WebGL test #76: gl.getFramebufferAttachmentParameter(gl.FRAMEBUFFER, gl.DEPTH_STENCIL_ATTACHMENT, gl.FRAMEBUFFER_ATTACHMENT_OBJECT_NAME) should be [object WebGLRenderbuffer\]. Was null.] + expected: FAIL + + [WebGL test #83: getError expected: INVALID_OPERATION. Was INVALID_ENUM : after evaluating: gl.getFramebufferAttachmentParameter(gl.FRAMEBUFFER, gl.DEPTH_STENCIL_ATTACHMENT, gl.FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE)] + expected: FAIL + + [WebGL test #89: gl.getFramebufferAttachmentParameter(gl.FRAMEBUFFER, gl.BACK, gl.FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE) should be 33304 (of type number). Was null (of type object).] + expected: FAIL + + [WebGL test #90: gl.getFramebufferAttachmentParameter(gl.FRAMEBUFFER, gl.DEPTH, gl.FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE) should be 33304 (of type number). Was null (of type object).] + expected: FAIL + + [WebGL test #91: gl.getFramebufferAttachmentParameter(gl.FRAMEBUFFER, gl.STENCIL, gl.FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE) should be 0 (of type number). Was null (of type object).] + expected: FAIL + + [WebGL test #104: getFramebufferAttachmentParameter did not generate INVALID_ENUM for invalid parameter enum: NO_ERROR] + expected: FAIL + + [WebGL test #105: getFramebufferAttachmentParameter did not generate INVALID_ENUM for invalid target enum: NO_ERROR] + expected: FAIL + + [WebGL test #106: getFramebufferAttachmentParameter did not generate INVALID_ENUM for invalid attachment enum: NO_ERROR] + expected: FAIL + + [WebGL test #108: successfullyParsed should be true (of type boolean). Was undefined (of type undefined).] + expected: FAIL + |