commit cc2fd0f1fd07075370f2fb1850b9aa29d67af8e1
parent 4270ae3836a4a0495273174c43e50fac9615461b
Author: Fredrik Söderquist <fs@opera.com>
Date: Fri, 3 Oct 2025 08:57:31 +0000
Bug 1990830 [wpt PR 55058] - Move/migrate SVGRect and SVGPoint tests to WPT, a=testonly
Automatic update from web-platform-tests
Move/migrate SVGRect and SVGPoint tests to WPT
Bug: 40779000
Change-Id: If95877c56ddfd4bc1ec34c13e53a99281452ec30
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6983405
Reviewed-by: Philip Rogers <pdr@chromium.org>
Auto-Submit: Fredrik Söderquist <fs@opera.com>
Commit-Queue: Philip Rogers <pdr@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1520548}
--
wpt-commits: 3032c66616551407b6516619ee18beb256a5c8b2
wpt-pr: 55058
Diffstat:
2 files changed, 90 insertions(+), 9 deletions(-)
diff --git a/testing/web-platform/tests/svg/types/scripted/SVGPoint.html b/testing/web-platform/tests/svg/types/scripted/SVGPoint.html
@@ -4,22 +4,63 @@
<script src="/resources/testharnessreport.js"></script>
<script>
test(function() {
- let svgElement = document.createElementNS("http://www.w3.org/2000/svg", "svg");
- let point = svgElement.createSVGPoint();
+ const svgElement = document.createElementNS("http://www.w3.org/2000/svg", "svg");
+ const point = svgElement.createSVGPoint();
// Check initial point values.
assert_equals(point.x, 0);
assert_equals(point.y, 0);
- point.y = 2;
-
- // Check setting valid arguments.
- assert_equals(point.x, 0);
- assert_equals(point.y, 2);
+ // Check assigning points.
+ point.x = 100;
+ assert_equals(point.x, 100);
+ point.y = 200;
+ assert_equals(point.y, 200);
+ point.y = null;
+ assert_equals(point.y, 0);
+ point.y = 200;
// Check setting invalid arguments.
+ assert_throws_js(TypeError, function() { point.x = point; });
+ assert_equals(point.x, 100);
assert_throws_js(TypeError, function() { point.x = NaN; });
+ assert_equals(point.x, 100);
assert_throws_js(TypeError, function() { point.x = Infinity; });
- assert_equals(point.x, 0);
-});
+ assert_equals(point.x, 100);
+
+ assert_throws_js(TypeError, function() { point.y = point; });
+ assert_equals(point.y, 200);
+ assert_throws_js(TypeError, function() { point.y = NaN; });
+ assert_equals(point.y, 200);
+ assert_throws_js(TypeError, function() { point.y = Infinity; });
+ assert_equals(point.y, 200);
+}, `${document.title}, 'x' and 'y' attributes`);
+
+test(function() {
+ const svgElement = document.createElementNS("http://www.w3.org/2000/svg", "svg");
+ const point = svgElement.createSVGPoint();
+
+ point.x = -50;
+ point.y = 100;
+
+ // Multiply with -1,0,0,2,10,10 matrix, should flip x coordinate, multiply y
+ // by two and translate each coordinate by 10.
+ const ctm = svgElement.createSVGMatrix();
+ ctm.a = -1;
+ ctm.d = 2;
+ ctm.e = 10;
+ ctm.f = 10;
+ newPoint = point.matrixTransform(ctm);
+ assert_true(newPoint instanceof SVGPoint);
+ assert_equals(newPoint.x, 60);
+ assert_equals(newPoint.y, 210);
+
+ // Check invalid arguments for 'matrixTransform'.
+ assert_throws_js(TypeError, function() { point.matrixTransform(); });
+ assert_throws_js(TypeError, function() { point.matrixTransform(-1); });
+ assert_throws_js(TypeError, function() { point.matrixTransform(5); });
+ assert_throws_js(TypeError, function() { point.matrixTransform('aString'); });
+ assert_throws_js(TypeError, function() { point.matrixTransform(point); });
+ assert_throws_js(TypeError, function() { point.matrixTransform(svgElement); });
+}, `${document.title}, matrixTransform()`);
</script>
diff --git a/testing/web-platform/tests/svg/types/scripted/SVGRect.html b/testing/web-platform/tests/svg/types/scripted/SVGRect.html
@@ -0,0 +1,40 @@
+<!DOCTYPE html>
+<title>SVGRect interface</title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script>
+ setup(() => {
+ window.svgElement = document.createElementNS("http://www.w3.org/2000/svg", "svg");
+ });
+
+ test(t => {
+ const rect = svgElement.createSVGRect();
+ assert_equals(rect.x, 0, 'initial x');
+ assert_equals(rect.y, 0, 'initial y');
+ assert_equals(rect.width, 0, 'initial width');
+ assert_equals(rect.height, 0, 'initial height');
+ }, `${document.title}, initial values`);
+
+ test(t => {
+ const rect = svgElement.createSVGRect();
+ rect.x = 100;
+ rect.y = 200;
+ rect.width = 300;
+ rect.height = 400;
+ assert_equals(rect.x, 100);
+ assert_equals(rect.y, 200);
+ assert_equals(rect.width, 300);
+ assert_equals(rect.height, 400);
+
+ rect.y = null;
+ assert_equals(rect.y, 0);
+ }, `${document.title}, assignment, numeric values`);
+
+ test(t => {
+ const rect = svgElement.createSVGRect();
+ assert_throws_js(TypeError, () => { rect.x = rect; });
+ assert_throws_js(TypeError, () => { rect.y = 'aString'; });
+ assert_throws_js(TypeError, () => { rect.width = svgElement; });
+ assert_throws_js(TypeError, () => { rect.height = NaN; });
+ }, `${document.title}, assignment, invalid values`);
+</script>