Auto merge of #13060 - anholt:webgl-invalid-passed-params, r=emilio

webgl: Do validation of glScissor/glViewport(width, height) on the DOM side

<!-- Please describe your changes on the following line: -->
webgl: Do validation of glScissor/glViewport(width, height) on the DOM side

---
<!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: -->
- [X] `./mach build -d` does not report any errors
- [X] `./mach test-tidy` does not report any errors
- [ ] These changes fix #__ (github issue number if applicable).

<!-- Either: -->
- [X] There are tests for these changes OR
- [ ] These changes do not require tests because _____

<!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->

Avoids testcase CRASHes due to unexpected GL errors.

<!-- 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/13060)
<!-- Reviewable:end -->
This commit is contained in:
bors-servo 2016-08-28 20:10:47 -05:00 committed by GitHub
commit 11e8e42fd8
3 changed files with 131 additions and 8 deletions

View file

@ -1526,6 +1526,10 @@ impl WebGLRenderingContextMethods for WebGLRenderingContext {
// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.4
fn Scissor(&self, x: i32, y: i32, width: i32, height: i32) {
if width < 0 || height < 0 {
return self.webgl_error(InvalidValue)
}
self.ipc_renderer
.send(CanvasMsg::WebGL(WebGLCommand::Scissor(x, y, width, height)))
.unwrap()
@ -1938,6 +1942,10 @@ impl WebGLRenderingContextMethods for WebGLRenderingContext {
// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.4
fn Viewport(&self, x: i32, y: i32, width: i32, height: i32) {
if width < 0 || height < 0 {
return self.webgl_error(InvalidValue)
}
self.ipc_renderer
.send(CanvasMsg::WebGL(WebGLCommand::Viewport(x, y, width, height)))
.unwrap()

View file

@ -1,3 +1,124 @@
[invalid-passed-params.html]
type: testharness
expected: CRASH
[WebGL test #4: getError expected: INVALID_VALUE. Was NO_ERROR : after evaluating: context.clear(desktopGL['ACCUM_BUFFER_BIT'\])]
expected: FAIL
[WebGL test #5: getError expected: INVALID_VALUE. Was NO_ERROR : after evaluating: context.clear(desktopGL['ACCUM_BUFFER_BIT'\] | context.COLOR_BUFFER_BIT)]
expected: FAIL
[WebGL test #6: getError expected: INVALID_VALUE. Was NO_ERROR : after evaluating: context.clear(desktopGL['ACCUM_BUFFER_BIT'\] | context.COLOR_BUFFER_BIT | context.DEPTH_BUFFER_BIT | context.STENCIL_BUFFER_BIT)]
expected: FAIL
[WebGL test #9: context.bufferData(context.ARRAY_BUFFER, 16, context.STREAM_DRAW) threw exception TypeError: Value is not an object.]
expected: FAIL
[WebGL test #10: context.bufferData(context.ARRAY_BUFFER, 16, context.STATIC_DRAW) threw exception TypeError: Value is not an object.]
expected: FAIL
[WebGL test #11: context.bufferData(context.ARRAY_BUFFER, 16, context.DYNAMIC_DRAW) threw exception TypeError: Value is not an object.]
expected: FAIL
[WebGL test #12: context.bufferData(context.ARRAY_BUFFER, 16, desktopGL['STREAM_READ'\]) threw exception TypeError: Value is not an object.]
expected: FAIL
[WebGL test #13: context.bufferData(context.ARRAY_BUFFER, 16, desktopGL['STREAM_COPY'\]) threw exception TypeError: Value is not an object.]
expected: FAIL
[WebGL test #14: context.bufferData(context.ARRAY_BUFFER, 16, desktopGL['STATIC_READ'\]) threw exception TypeError: Value is not an object.]
expected: FAIL
[WebGL test #15: context.bufferData(context.ARRAY_BUFFER, 16, desktopGL['STATIC_COPY'\]) threw exception TypeError: Value is not an object.]
expected: FAIL
[WebGL test #16: context.bufferData(context.ARRAY_BUFFER, 16, desktopGL['DYNAMIC_READ'\]) threw exception TypeError: Value is not an object.]
expected: FAIL
[WebGL test #17: context.bufferData(context.ARRAY_BUFFER, 16, desktopGL['DYNAMIC_COPY'\]) threw exception TypeError: Value is not an object.]
expected: FAIL
[WebGL test #19: context.texImage2D(context.TEXTURE_2D, 0, context.RGBA, -16, -16, 0, context.RGBA, context.UNSIGNED_BYTE, null) threw exception TypeError: Value is not an object.]
expected: FAIL
[WebGL test #20: context.texImage2D(context.TEXTURE_2D, 0, context.RGBA, 16, 16, 0, context.RGBA, context.UNSIGNED_BYTE, null) threw exception TypeError: Value is not an object.]
expected: FAIL
[WebGL test #23: getError expected: NO_ERROR. Was INVALID_VALUE : after evaluating: context.texSubImage2D(context.TEXTURE_2D, 0, 0, 0, 2, 2, context.RGBA, context.UNSIGNED_BYTE, pixels)]
expected: FAIL
[WebGL test #30: context.renderbufferStorage(context.RENDERBUFFER, context.RGBA4, -2, -2) threw exception TypeError: context.renderbufferStorage is not a function]
expected: FAIL
[WebGL test #31: context.renderbufferStorage(context.RENDERBUFFER, context.RGBA4, 16, 16) threw exception TypeError: context.renderbufferStorage is not a function]
expected: FAIL
[WebGL test #44: context.getError() should be 1281. Was 0.]
expected: FAIL
[WebGL test #46: context.getError() should be 1281. Was 0.]
expected: FAIL
[WebGL test #48: context.getError() should be 1281. Was 0.]
expected: FAIL
[WebGL test #50: context.getError() should be 1281. Was 0.]
expected: FAIL
[WebGL test #52: context.getError() should be 1281. Was 0.]
expected: FAIL
[WebGL test #54: context.getError() should be 1281. Was 0.]
expected: FAIL
[WebGL test #55: context.getError() should be 1281. Was 0.]
expected: FAIL
[WebGL test #56: context.getError() should be 1281. Was 0.]
expected: FAIL
[WebGL test #57: context.getError() should be 1281. Was 0.]
expected: FAIL
[WebGL test #58: context.getError() should be 1281. Was 0.]
expected: FAIL
[WebGL test #59: context.getError() should be 1281. Was 0.]
expected: FAIL
[WebGL test #60: context.getError() should be 1281. Was 0.]
expected: FAIL
[WebGL test #61: context.getError() should be 1281. Was 0.]
expected: FAIL
[WebGL test #62: context.getError() should be 1281. Was 0.]
expected: FAIL
[WebGL test #63: context.getError() should be 1281. Was 0.]
expected: FAIL
[WebGL test #64: context.getError() should be 1281. Was 0.]
expected: FAIL
[WebGL test #65: context.getError() should be 1281. Was 0.]
expected: FAIL
[WebGL test #66: context.getError() should be 1281. Was 0.]
expected: FAIL
[WebGL test #67: context.getError() should be 1281. Was 0.]
expected: FAIL
[WebGL test #68: context.getError() should be 1281. Was 0.]
expected: FAIL
[WebGL test #69: context.getError() should be 1281. Was 0.]
expected: FAIL
[WebGL test #70: context.getError() should be 1281. Was 0.]
expected: FAIL
[WebGL test #71: context.getError() should be 1281. Was 0.]
expected: FAIL
[WebGL test #72: context.getError() should be 1281. Was 0.]
expected: FAIL

View file

@ -1,10 +1,4 @@
[gl-geterror.html]
type: testharness
expected:
if os == "mac": CRASH
[WebGL test #0: Unable to fetch WebGL rendering context for Canvas]
[WebGL test #2: successfullyParsed should be true (of type boolean). Was undefined (of type undefined).]
expected: FAIL
[WebGL test #1: successfullyParsed should be true (of type boolean). Was undefined (of type undefined).]
expected: FAIL