From 08b193c9220d5ff7452e0753ac17b0660051086a Mon Sep 17 00:00:00 2001 From: Simon Martin Date: Fri, 27 Apr 2018 09:53:38 +0200 Subject: [PATCH] Issue #20593: Implement proper checks in WebGLRenderingContext's getFramebufferAttachmentParameter(). --- .../script/dom/webglrenderingcontext.rs | 31 ++++- tests/wpt/mozilla/meta/MANIFEST.json | 10 ++ .../getFramebufferAttachmentParameter.html | 114 ++++++++++++++++++ 3 files changed, 154 insertions(+), 1 deletion(-) create mode 100644 tests/wpt/mozilla/tests/mozilla/webgl/getFramebufferAttachmentParameter.html diff --git a/components/script/dom/webglrenderingcontext.rs b/components/script/dom/webglrenderingcontext.rs index fe46e53f6d8..45ddf42dbb2 100644 --- a/components/script/dom/webglrenderingcontext.rs +++ b/components/script/dom/webglrenderingcontext.rs @@ -2339,7 +2339,36 @@ impl WebGLRenderingContextMethods for WebGLRenderingContext { _ => false }; - if !target_matches || !attachment_matches || !pname_matches { + let bound_attachment_matches = match self.bound_framebuffer.get().unwrap().attachment(attachment) { + Some(attachment_root) => { + match attachment_root { + WebGLFramebufferAttachmentRoot::Renderbuffer(_) => { + match pname { + constants::FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE | + constants::FRAMEBUFFER_ATTACHMENT_OBJECT_NAME => true, + _ => false + } + }, + WebGLFramebufferAttachmentRoot::Texture(_) => { + match pname { + constants::FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE | + constants::FRAMEBUFFER_ATTACHMENT_OBJECT_NAME | + constants::FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL | + constants::FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE => true, + _ => false + } + } + } + }, + _ => { + match pname { + constants::FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE => true, + _ => false + } + } + }; + + if !target_matches || !attachment_matches || !pname_matches || !bound_attachment_matches { self.webgl_error(InvalidEnum); return NullValue(); } diff --git a/tests/wpt/mozilla/meta/MANIFEST.json b/tests/wpt/mozilla/meta/MANIFEST.json index 69d53b994b0..b9b5cab6cfc 100644 --- a/tests/wpt/mozilla/meta/MANIFEST.json +++ b/tests/wpt/mozilla/meta/MANIFEST.json @@ -39299,6 +39299,12 @@ {} ] ], + "mozilla/webgl/getFramebufferAttachmentParameter.html": [ + [ + "/_mozilla/mozilla/webgl/getFramebufferAttachmentParameter.html", + {} + ] + ], "mozilla/webgl/get_supported_extensions.html": [ [ "/_mozilla/mozilla/webgl/get_supported_extensions.html", @@ -70976,6 +70982,10 @@ "a163189d8674be83c9e8c9055da31a1c5ed46be5", "support" ], + "mozilla/webgl/getFramebufferAttachmentParameter.html": [ + "71a8c1829f703ff43a30d1b3fb9b99e59d3db973", + "testharness" + ], "mozilla/webgl/get_supported_extensions.html": [ "719c7c4cb91f3c1b2bbc4cbe35285fc63ce6263f", "testharness" diff --git a/tests/wpt/mozilla/tests/mozilla/webgl/getFramebufferAttachmentParameter.html b/tests/wpt/mozilla/tests/mozilla/webgl/getFramebufferAttachmentParameter.html new file mode 100644 index 00000000000..6a51cbd51d6 --- /dev/null +++ b/tests/wpt/mozilla/tests/mozilla/webgl/getFramebufferAttachmentParameter.html @@ -0,0 +1,114 @@ + + +getFramebufferAttachmentParameter input type check (issue #20593) + + +