blob: 8cac81949b6a7ab148060023524e759f01282c00 [file] [log] [blame]
<!DOCTYPE HTML>
<title>SVGPoint interface</title>
<script src="../../resources/testharness.js"></script>
<script src="../../resources/testharnessreport.js"></script>
<script>
test(function() {
// This test checks the SVGPoint API.
var svgElement = document.createElementNS("http://www.w3.org/2000/svg", "svg");
var point = svgElement.createSVGPoint();
// Check initial point values.
assert_equals(point.x, 0);
assert_equals(point.y, 0);
// Check assigning points.
point.x = 100;
assert_equals(point.x, 100);
point.y = 200;
assert_equals(point.y, 200);
// Check assigning invalid points.
point.x = point;
assert_equals(point.x, NaN);
point.y = null;
assert_equals(point.y, 0);
// Reset to -50, 100
point.x = -50;
point.y = 100;
// Check 'matrixTransform' method - multiply with -1,0,0,2,10,10 matrix, should flip x coordinate, multiply y by two and translate each coordinate by 10.
var 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(new TypeError(), function() { point.matrixTransform(); });
assert_throws(new TypeError(), function() { point.matrixTransform(-1); });
assert_throws(new TypeError(), function() { point.matrixTransform(5); });
assert_throws(new TypeError(), function() { point.matrixTransform('aString'); });
assert_throws(new TypeError(), function() { point.matrixTransform(point); });
assert_throws(new TypeError(), function() { point.matrixTransform(svgElement); });
});
</script>