Source code

Revision control

Copy as Markdown

Other Tools

Test Info:

SVG Preview (Scaled)

Preview of https://hg.mozilla.org/mozilla-central/raw-file/tip/testing/web-platform/tests/svg/types/scripted/SVGGeometryElement.getPointAtLength-03.svg
<title>When SVGGeometryElement.getPointAtLength is called with an element that is not in the document, either succeed or throw exception</title>
<html:script src="/resources/testharness.js"/>
<html:script src="/resources/testharnessreport.js"/>
<script><![CDATA[
test(function() {
var pathElement = document.createElementNS("http://www.w3.org/2000/svg", "path");
assert_throws_dom("InvalidStateError", function() { pathElement.getPointAtLength(700) });
}, document.title + " with SVGPathElement");
test(function() {
var rectElement = document.createElementNS("http://www.w3.org/2000/svg", "rect");
rectElement.setAttribute("rx", 0);
rectElement.setAttribute("ry", 0);
rectElement.setAttribute("width", 200);
rectElement.setAttribute("height", 300);
try {
let rectPoint = rectElement.getPointAtLength(300);
assert_equals(rectPoint.x, 200, 'unexpected x position');
assert_equals(rectPoint.y, 100, 'unexpected y position');
} catch (e) {
assert_equals(e.name || e.type, 'InvalidStateError', 'Wrong exception, expected InvalidStateError');
}
}, document.title + " with SVGRectElement");
test(function() {
var circleElement = document.createElementNS("http://www.w3.org/2000/svg", "circle");
circleElement.setAttribute("r", 10);
try {
let circlePoint = circleElement.getPointAtLength(100);
assert_approx_equals(circlePoint.x, 10, 0.2, 'unexpected x position');
assert_approx_equals(circlePoint.y, 0, 0.2, 'unexpected y position');
} catch (e) {
assert_equals(e.name || e.type, 'InvalidStateError', 'Wrong exception, expected InvalidStateError');
}
}, document.title + " with SVGCircleElement");
]]></script>
</svg>