Bug 630068 - Throw when attempting to create an arc with a negative radius; r+a=roc
authorMs2ger <ms2ger@gmail.com>
Wed, 02 Feb 2011 08:45:48 +1300
changeset 61742 263e4f35b7975fd80eb6ac0ae7956013c4e82ea8
parent 61741 7aa71efbb69cd7501611fe082f9a347056c17ad1
child 61743 301997f0df6207f0d411015b156f62a8da303e56
push id1
push userroot
push dateTue, 26 Apr 2011 22:38:44 +0000
treeherdermozilla-beta@bfdb6e623a36 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs630068
milestone2.0b11pre
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 630068 - Throw when attempting to create an arc with a negative radius; r+a=roc
content/canvas/src/nsCanvasRenderingContext2D.cpp
content/canvas/test/test_canvas.html
--- a/content/canvas/src/nsCanvasRenderingContext2D.cpp
+++ b/content/canvas/src/nsCanvasRenderingContext2D.cpp
@@ -2137,16 +2137,19 @@ nsCanvasRenderingContext2D::ArcTo(float 
 }
 
 NS_IMETHODIMP
 nsCanvasRenderingContext2D::Arc(float x, float y, float r, float startAngle, float endAngle, PRBool ccw)
 {
     if (!FloatValidate(x,y,r,startAngle,endAngle))
         return NS_ERROR_DOM_SYNTAX_ERR;
 
+    if (r < 0.0)
+        return NS_ERROR_DOM_INDEX_SIZE_ERR;
+
     gfxPoint p(x,y);
 
     if (ccw)
         mThebes->NegativeArc(p, r, startAngle, endAngle);
     else
         mThebes->Arc(p, r, startAngle, endAngle);
     return NS_OK;
 }
--- a/content/canvas/test/test_canvas.html
+++ b/content/canvas/test/test_canvas.html
@@ -10721,17 +10721,17 @@ isPixel(ctx, 50,25, 0,255,0,255, 0);
 
 function test_2d_path_arc_negative() {
 
 var canvas = document.getElementById('c340');
 var ctx = canvas.getContext('2d');
 
 var _thrown = undefined; try {
   ctx.arc(0, 0, -1, 0, 0, true);
-} catch (e) { _thrown = e }; todo(_thrown && _thrown.code == DOMException.INDEX_SIZE_ERR, "should throw INDEX_SIZE_ERR");
+} catch (e) { _thrown = e }; ok(_thrown && _thrown.code == DOMException.INDEX_SIZE_ERR, "should throw INDEX_SIZE_ERR");
 
 
 }
 </script>
 
 <!-- [[[ test_2d.path.arc.nonempty.html ]]] -->
 
 <p>Canvas test: 2d.path.arc.nonempty</p>