mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-10-26 18:09:45 +00:00
LibWeb: Ensure CanvasPath::arc() nonfinite radius argument is ignored
This commit is contained in:
parent
303ebc0a67
commit
08641c9e15
Notes:
github-actions[bot]
2025-10-20 11:13:21 +00:00
Author: https://github.com/tcl3
Commit: 08641c9e15
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/6516
Reviewed-by: https://github.com/AtkinsSJ ✅
3 changed files with 84 additions and 1 deletions
|
|
@ -95,7 +95,7 @@ void CanvasPath::bezier_curve_to(double cp1x, double cp1y, double cp2x, double c
|
|||
|
||||
WebIDL::ExceptionOr<void> CanvasPath::arc(float x, float y, float radius, float start_angle, float end_angle, bool counter_clockwise)
|
||||
{
|
||||
if (radius < 0)
|
||||
if (radius < 0 && isfinite(radius))
|
||||
return WebIDL::IndexSizeError::create(m_self->realm(), Utf16String::formatted("The radius provided ({}) is negative.", radius));
|
||||
return ellipse(x, y, radius, radius, 0, start_angle, end_angle, counter_clockwise);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,6 @@
|
|||
Harness status: OK
|
||||
|
||||
Found 1 tests
|
||||
|
||||
1 Pass
|
||||
Pass arc() with Infinity/NaN is ignored
|
||||
|
|
@ -0,0 +1,77 @@
|
|||
<!DOCTYPE html>
|
||||
<!-- DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. -->
|
||||
<meta charset="UTF-8">
|
||||
<title>Canvas test: 2d.path.arc.nonfinite</title>
|
||||
<script src="../../../../resources/testharness.js"></script>
|
||||
<script src="../../../../resources/testharnessreport.js"></script>
|
||||
<script src="../../../../html/canvas/resources/canvas-tests.js"></script>
|
||||
<link rel="stylesheet" href="../../../../html/canvas/resources/canvas-tests.css">
|
||||
<body class="show_output">
|
||||
|
||||
<h1>2d.path.arc.nonfinite</h1>
|
||||
<p class="desc">arc() with Infinity/NaN is ignored</p>
|
||||
|
||||
|
||||
<p class="output">Actual output:</p>
|
||||
<canvas id="c" class="output" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
|
||||
<p class="output expectedtext">Expected output:<p><img src="../../../../images/green-100x50.png" class="output expected" id="expected" alt="">
|
||||
<ul id="d"></ul>
|
||||
<script>
|
||||
var t = async_test("arc() with Infinity/NaN is ignored");
|
||||
_addTest(function(canvas, ctx) {
|
||||
|
||||
ctx.fillStyle = '#f00';
|
||||
ctx.fillRect(0, 0, 100, 50);
|
||||
ctx.moveTo(0, 0);
|
||||
ctx.lineTo(100, 0);
|
||||
ctx.arc(Infinity, 0, 50, 0, 2*Math.PI, true);
|
||||
ctx.arc(-Infinity, 0, 50, 0, 2*Math.PI, true);
|
||||
ctx.arc(NaN, 0, 50, 0, 2*Math.PI, true);
|
||||
ctx.arc(0, Infinity, 50, 0, 2*Math.PI, true);
|
||||
ctx.arc(0, -Infinity, 50, 0, 2*Math.PI, true);
|
||||
ctx.arc(0, NaN, 50, 0, 2*Math.PI, true);
|
||||
ctx.arc(0, 0, Infinity, 0, 2*Math.PI, true);
|
||||
ctx.arc(0, 0, -Infinity, 0, 2*Math.PI, true);
|
||||
ctx.arc(0, 0, NaN, 0, 2*Math.PI, true);
|
||||
ctx.arc(0, 0, 50, Infinity, 2*Math.PI, true);
|
||||
ctx.arc(0, 0, 50, -Infinity, 2*Math.PI, true);
|
||||
ctx.arc(0, 0, 50, NaN, 2*Math.PI, true);
|
||||
ctx.arc(0, 0, 50, 0, Infinity, true);
|
||||
ctx.arc(0, 0, 50, 0, -Infinity, true);
|
||||
ctx.arc(0, 0, 50, 0, NaN, true);
|
||||
ctx.arc(Infinity, Infinity, 50, 0, 2*Math.PI, true);
|
||||
ctx.arc(Infinity, Infinity, Infinity, 0, 2*Math.PI, true);
|
||||
ctx.arc(Infinity, Infinity, Infinity, Infinity, 2*Math.PI, true);
|
||||
ctx.arc(Infinity, Infinity, Infinity, Infinity, Infinity, true);
|
||||
ctx.arc(Infinity, Infinity, Infinity, 0, Infinity, true);
|
||||
ctx.arc(Infinity, Infinity, 50, Infinity, 2*Math.PI, true);
|
||||
ctx.arc(Infinity, Infinity, 50, Infinity, Infinity, true);
|
||||
ctx.arc(Infinity, Infinity, 50, 0, Infinity, true);
|
||||
ctx.arc(Infinity, 0, Infinity, 0, 2*Math.PI, true);
|
||||
ctx.arc(Infinity, 0, Infinity, Infinity, 2*Math.PI, true);
|
||||
ctx.arc(Infinity, 0, Infinity, Infinity, Infinity, true);
|
||||
ctx.arc(Infinity, 0, Infinity, 0, Infinity, true);
|
||||
ctx.arc(Infinity, 0, 50, Infinity, 2*Math.PI, true);
|
||||
ctx.arc(Infinity, 0, 50, Infinity, Infinity, true);
|
||||
ctx.arc(Infinity, 0, 50, 0, Infinity, true);
|
||||
ctx.arc(0, Infinity, Infinity, 0, 2*Math.PI, true);
|
||||
ctx.arc(0, Infinity, Infinity, Infinity, 2*Math.PI, true);
|
||||
ctx.arc(0, Infinity, Infinity, Infinity, Infinity, true);
|
||||
ctx.arc(0, Infinity, Infinity, 0, Infinity, true);
|
||||
ctx.arc(0, Infinity, 50, Infinity, 2*Math.PI, true);
|
||||
ctx.arc(0, Infinity, 50, Infinity, Infinity, true);
|
||||
ctx.arc(0, Infinity, 50, 0, Infinity, true);
|
||||
ctx.arc(0, 0, Infinity, Infinity, 2*Math.PI, true);
|
||||
ctx.arc(0, 0, Infinity, Infinity, Infinity, true);
|
||||
ctx.arc(0, 0, Infinity, 0, Infinity, true);
|
||||
ctx.arc(0, 0, 50, Infinity, Infinity, true);
|
||||
ctx.lineTo(100, 50);
|
||||
ctx.lineTo(0, 50);
|
||||
ctx.fillStyle = '#0f0';
|
||||
ctx.fill();
|
||||
_assertPixel(canvas, 50,25, 0,255,0,255);
|
||||
_assertPixel(canvas, 90,45, 0,255,0,255);
|
||||
|
||||
});
|
||||
</script>
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue