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);
}
diff --git a/Tests/LibWeb/Text/expected/wpt-import/html/canvas/element/path-objects/2d.path.arc.nonfinite.txt b/Tests/LibWeb/Text/expected/wpt-import/html/canvas/element/path-objects/2d.path.arc.nonfinite.txt
new file mode 100644
index 00000000000..149a3d81ba3
--- /dev/null
+++ b/Tests/LibWeb/Text/expected/wpt-import/html/canvas/element/path-objects/2d.path.arc.nonfinite.txt
@@ -0,0 +1,6 @@
+Harness status: OK
+
+Found 1 tests
+
+1 Pass
+Pass arc() with Infinity/NaN is ignored
\ No newline at end of file
diff --git a/Tests/LibWeb/Text/input/wpt-import/html/canvas/element/path-objects/2d.path.arc.nonfinite.html b/Tests/LibWeb/Text/input/wpt-import/html/canvas/element/path-objects/2d.path.arc.nonfinite.html
new file mode 100644
index 00000000000..f7032e03748
--- /dev/null
+++ b/Tests/LibWeb/Text/input/wpt-import/html/canvas/element/path-objects/2d.path.arc.nonfinite.html
@@ -0,0 +1,77 @@
+
+
+
+Canvas test: 2d.path.arc.nonfinite
+
+
+
+
+
+
+2d.path.arc.nonfinite
+arc() with Infinity/NaN is ignored
+
+
+Actual output:
+
+Expected output:
+
+
+