diff --git a/components/canvas/webgl_paint_task.rs b/components/canvas/webgl_paint_task.rs index a765f93a109b..0866ad300527 100644 --- a/components/canvas/webgl_paint_task.rs +++ b/components/canvas/webgl_paint_task.rs @@ -50,6 +50,20 @@ impl WebGLPaintTask { /// NB: Not gl-related validations (names, lengths, accepted parameters...) are /// done in the corresponding DOM interfaces pub fn handle_webgl_message(&self, message: CanvasWebGLMsg) { + match message { + // *VertexAttrib* generate a GL_INVALID_VALUE error if called with an index above + // GL_MAX_VERTEX_ATTRIBS, so leave early in that case (see for instance + // https://www.khronos.org/opengles/sdk/docs/man/xhtml/glVertexAttrib.xml) + CanvasWebGLMsg::EnableVertexAttribArray(attrib_id) | + CanvasWebGLMsg::VertexAttrib(attrib_id, _, _, _, _) | + CanvasWebGLMsg::VertexAttribPointer2f(attrib_id, _, _, _, _) => { + if attrib_id >= gl::get_integer_v(gl::MAX_VERTEX_ATTRIBS) as u32 { + return + } + }, + _ => () + } + match message { CanvasWebGLMsg::GetContextAttributes(sender) => self.context_attributes(sender), diff --git a/tests/wpt/mozilla/meta/MANIFEST.json b/tests/wpt/mozilla/meta/MANIFEST.json index 3ac785d5da7f..7674e15dfcf0 100644 --- a/tests/wpt/mozilla/meta/MANIFEST.json +++ b/tests/wpt/mozilla/meta/MANIFEST.json @@ -5877,6 +5877,12 @@ "url": "/_mozilla/mozilla/webgl/get_supported_extensions.html" } ], + "mozilla/webgl/vertex_attrib_above_limit.html": [ + { + "path": "mozilla/webgl/vertex_attrib_above_limit.html", + "url": "/_mozilla/mozilla/webgl/vertex_attrib_above_limit.html" + } + ], "mozilla/websocket_connection_fail.html": [ { "path": "mozilla/websocket_connection_fail.html", diff --git a/tests/wpt/mozilla/tests/mozilla/webgl/vertex_attrib_above_limit.html b/tests/wpt/mozilla/tests/mozilla/webgl/vertex_attrib_above_limit.html new file mode 100644 index 000000000000..77d4dfeeee0a --- /dev/null +++ b/tests/wpt/mozilla/tests/mozilla/webgl/vertex_attrib_above_limit.html @@ -0,0 +1,67 @@ + + +Issue #9097: Don't panic calling *VertexAttrib* API with out-of-bounds indices + + + + + + + + + +
+ +
+ + + +