Canvas: arc throws IndexSizeError on negative radius.

This commit is contained in:
Mátyás Mustoha 2015-03-30 11:05:33 +02:00
parent 350a35428a
commit 0a3b4f2f65
3 changed files with 8 additions and 6 deletions

View file

@ -460,15 +460,21 @@ impl<'a> CanvasRenderingContext2DMethods for JSRef<'a, CanvasRenderingContext2D>
Point2D(x as f32, y as f32))).unwrap();
}
fn Arc(self, x: Finite<f64>, y: Finite<f64>, r: Finite<f64>, start: Finite<f64>, end: Finite<f64>, ccw: bool) {
fn Arc(self, x: Finite<f64>, y: Finite<f64>, r: Finite<f64>,
start: Finite<f64>, end: Finite<f64>, ccw: bool) -> Fallible<()> {
let x = *x;
let y = *y;
let r = *r;
let start = *start;
let end = *end;
if r < 0.0 {
return Err(IndexSize);
}
self.renderer.send(CanvasMsg::Arc(Point2D(x as f32, y as f32), r as f32,
start as f32, end as f32, ccw)).unwrap();
Ok(())
}
// https://html.spec.whatwg.org/#dom-context-2d-imagesmoothingenabled

View file

@ -150,6 +150,7 @@ interface CanvasPathMethods {
//void rect(double x, double y, double w, double h);
[Throws]
void arc(double x, double y, double radius, double startAngle, double endAngle, optional boolean anticlockwise = false);
// NOT IMPLEMENTED [LenientFloat] void ellipse(double x, double y, double radiusX, double radiusY, double rotation, double startAngle, double endAngle, boolean anticlockwise);
};

View file

@ -1,5 +0,0 @@
[2d.path.arc.negative.html]
type: testharness
[arc() with negative radius throws INDEX_SIZE_ERR]
expected: FAIL