diff --git a/components/script/dom/webglrenderingcontext.rs b/components/script/dom/webglrenderingcontext.rs index 7cab80a22f1..b3b3fbc5ea6 100644 --- a/components/script/dom/webglrenderingcontext.rs +++ b/components/script/dom/webglrenderingcontext.rs @@ -2137,24 +2137,28 @@ impl WebGLRenderingContextMethods for WebGLRenderingContext { constants::POINTS | constants::LINE_STRIP | constants::LINE_LOOP | constants::LINES | constants::TRIANGLE_STRIP | constants::TRIANGLE_FAN | - constants::TRIANGLES => { - if self.current_program.get().is_none() { - return self.webgl_error(InvalidOperation); - } - - if first < 0 || count < 0 { - return self.webgl_error(InvalidValue); - } - - if !self.validate_framebuffer_complete() { - return; - } - - self.send_command(WebGLCommand::DrawArrays(mode, first, count)); - self.mark_as_dirty(); - }, - _ => self.webgl_error(InvalidEnum), + constants::TRIANGLES => {}, + _ => { + return self.webgl_error(InvalidEnum); + } } + if first < 0 || count < 0 { + return self.webgl_error(InvalidValue); + } + if self.current_program.get().is_none() { + return self.webgl_error(InvalidOperation); + } + if let Some(array_buffer) = self.bound_buffer_array.get() { + if count > 0 && (first as u64 + count as u64 > array_buffer.capacity() as u64) { + return self.webgl_error(InvalidOperation); + } + } + if !self.validate_framebuffer_complete() { + return; + } + + self.send_command(WebGLCommand::DrawArrays(mode, first, count)); + self.mark_as_dirty(); } // https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.11 diff --git a/tests/wpt/mozilla/meta/webgl/conformance-1.0.3/conformance/more/functions/drawArraysOutOfBounds.html.ini b/tests/wpt/mozilla/meta/webgl/conformance-1.0.3/conformance/more/functions/drawArraysOutOfBounds.html.ini deleted file mode 100644 index 7eaba400214..00000000000 --- a/tests/wpt/mozilla/meta/webgl/conformance-1.0.3/conformance/more/functions/drawArraysOutOfBounds.html.ini +++ /dev/null @@ -1,5 +0,0 @@ -[drawArraysOutOfBounds.html] - type: testharness - [WebGL test #0: testDrawArraysEmpty] - expected: FAIL - diff --git a/tests/wpt/mozilla/meta/webgl/conformance-1.0.3/conformance/rendering/draw-arrays-out-of-bounds.html.ini b/tests/wpt/mozilla/meta/webgl/conformance-1.0.3/conformance/rendering/draw-arrays-out-of-bounds.html.ini index 64503c921e5..18a9a05ee2b 100644 --- a/tests/wpt/mozilla/meta/webgl/conformance-1.0.3/conformance/rendering/draw-arrays-out-of-bounds.html.ini +++ b/tests/wpt/mozilla/meta/webgl/conformance-1.0.3/conformance/rendering/draw-arrays-out-of-bounds.html.ini @@ -1,3 +1,5 @@ [draw-arrays-out-of-bounds.html] type: testharness - expected: TIMEOUT + [WebGL test #12: getError expected: INVALID_OPERATION. Was NO_ERROR : after evaluating: gl.drawArrays(gl.TRIANGLES, 3, 2)] + expected: FAIL +