diff options
author | bors-servo <lbergstrom+bors@mozilla.com> | 2018-05-20 11:54:56 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-05-20 11:54:56 -0400 |
commit | 0b5720547e8ee0148d8482b04cfc0a5f71cca2f0 (patch) | |
tree | cf4d773f0612782275d6007d78fbdfb1014488ae | |
parent | b9407adb04b28585403e1a0cdb49c406b6969c43 (diff) | |
parent | f32ffeb5530aff5a93ea1d5405d5bd8456fcd8af (diff) | |
download | servo-0b5720547e8ee0148d8482b04cfc0a5f71cca2f0.tar.gz servo-0b5720547e8ee0148d8482b04cfc0a5f71cca2f0.zip |
Auto merge of #20669 - simartin:issue_20623, r=jdm
Issue #20623: Check the input to WebGLRenderingContext's clear().
Validate the input to this function as per specifications.
---
- [X] `./mach build -d` does not report any errors
- [X] `./mach build-geckolib` does not report any errors
- [X] `./mach test-tidy` does not report any errors
- [X] These changes fix #20623
- [X] There are tests for these changes
<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/20669)
<!-- Reviewable:end -->
-rw-r--r-- | components/script/dom/webglrenderingcontext.rs | 3 | ||||
-rw-r--r-- | tests/wpt/mozilla/meta/MANIFEST.json | 10 | ||||
-rw-r--r-- | tests/wpt/mozilla/tests/mozilla/webgl/clear.html | 23 |
3 files changed, 36 insertions, 0 deletions
diff --git a/components/script/dom/webglrenderingcontext.rs b/components/script/dom/webglrenderingcontext.rs index 32059db6302..6617e1b227f 100644 --- a/components/script/dom/webglrenderingcontext.rs +++ b/components/script/dom/webglrenderingcontext.rs @@ -1878,6 +1878,9 @@ impl WebGLRenderingContextMethods for WebGLRenderingContext { if !self.validate_framebuffer_complete() { return; } + if mask & !(constants::DEPTH_BUFFER_BIT | constants::STENCIL_BUFFER_BIT | constants::COLOR_BUFFER_BIT) != 0 { + return self.webgl_error(InvalidValue); + } self.send_command(WebGLCommand::Clear(mask)); self.mark_as_dirty(); diff --git a/tests/wpt/mozilla/meta/MANIFEST.json b/tests/wpt/mozilla/meta/MANIFEST.json index 9398f6e4733..8ce7133cb9e 100644 --- a/tests/wpt/mozilla/meta/MANIFEST.json +++ b/tests/wpt/mozilla/meta/MANIFEST.json @@ -39293,6 +39293,12 @@ {} ] ], + "mozilla/webgl/clear.html": [ + [ + "/_mozilla/mozilla/webgl/clear.html", + {} + ] + ], "mozilla/webgl/context_creation_error.html": [ [ "/_mozilla/mozilla/webgl/context_creation_error.html", @@ -70956,6 +70962,10 @@ "c333c7b99156d63fcd3ad28014c7915a12cf8169", "testharness" ], + "mozilla/webgl/clear.html": [ + "14cc534be5da96b0cc128d5c44f662b2fdfb294c", + "testharness" + ], "mozilla/webgl/clearcolor.html": [ "942ee78ec987d17f63253ed97d6de958dbe8730d", "reftest" diff --git a/tests/wpt/mozilla/tests/mozilla/webgl/clear.html b/tests/wpt/mozilla/tests/mozilla/webgl/clear.html new file mode 100644 index 00000000000..b03c9a450f2 --- /dev/null +++ b/tests/wpt/mozilla/tests/mozilla/webgl/clear.html @@ -0,0 +1,23 @@ +<!doctype html> +<meta charset="utf-8"> +<title>WebGLRenderingContext.clear testing (issue #20623)</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script> +test(function() { + var gl = document.createElement("canvas").getContext("webgl"); + // Valid values + gl.clear(gl.DEPTH_BUFFER_BIT); + assert_equals(gl.NO_ERROR, gl.getError()); + gl.clear(gl.STENCIL_BUFFER_BIT); + assert_equals(gl.NO_ERROR, gl.getError()); + gl.clear(gl.COLOR_BUFFER_BIT); + assert_equals(gl.NO_ERROR, gl.getError()); + gl.clear(gl.DEPTH_BUFFER_BIT | gl.STENCIL_BUFFER_BIT | gl.COLOR_BUFFER_BIT); + assert_equals(gl.NO_ERROR, gl.getError()); + + // Invalid value + gl.clear(42); + assert_equals(gl.INVALID_VALUE, gl.getError()); +}); +</script> |