Source code
Revision control
Copy as Markdown
Other Tools
Test Info:
- This WPT test may be referenced by the following Test IDs:
- /svg/animations/animate-path-from-to-animation-mismatch-diff-seg-counts.tentative.html - WPT Dashboard Interop Dashboard
<!doctype html>
<title>SVG path 'd' attribute from-to animation with different segment counts</title>
<link rel="help" href="https://www.w3.org/TR/SVG2/paths.html#TheDProperty"/>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/resources/SVGAnimationTestCase-testharness.js"></script>
<script src="support/animated-path-helpers.js"></script>
<svg>
<path id="path" fill="green" d="">
<animate id="animation" attributeName="d"
from="M20,20 L60,20 L60,60"
to="M20,20 L60,20 L60,60 L20,60 Z"
begin="0s" dur="2s" fill="freeze"/>
</path>
</svg>
<script>
const rootSVGElement = document.querySelector("svg");
// Setup animation test
function sample1() {
// Discrete animation: at 0%, shows 'from' value
assert_animated_path_equals(path, "M20,20 L60,20 L60,60");
}
function sample2() {
// Discrete animation: at 100%, shows 'to' value
assert_animated_path_equals(path, "M20,20 L60,20 L60,60 L20,60 Z");
}
smil_async_test((t) => {
const expectedValues = [
// [animationId, time, sampleCallback]
["animation", 0.0, sample1],
["animation", 0.999, sample1],
["animation", 1.001, sample2],
["animation", 2.0, sample2],
["animation", 2.001, sample2]
];
runAnimationTest(t, expectedValues);
});
</script>