<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
<html>
<title>Test by-animations adding to previous underlying values</title>
<script src="../../resources/testharness.js"></script>
<script src="../../resources/testharnessreport.js"></script>
<script src="resources/SVGAnimationTestCase-testharness.js"></script>
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<!-- an1: Change width from 10 to 50 in 4s -->
<!-- an2: Change width from 10 to 100 in 4s starting at 5s -->
<rect width="10" height="100" fill="green">
<animate id="an1" attributeType="XML" attributeName="width" fill="remove" by="40" begin="0s" dur="4s"/>
<animate id="an2" attributeType="XML" attributeName="width" additive="sum" fill="freeze" by="90" begin="5s" dur="4s"/>
</rect>
</svg>
<script>
var rootSVGElement = document.querySelector("svg");
var rect = rootSVGElement.ownerDocument.getElementsByTagName("rect")[0];
var epsilon = 0.15;
// Setup animation test
function sample1() {
assert_approx_equals(rect.width.animVal.value, 10, epsilon, "1-1");
assert_equals(rect.width.baseVal.value, 10, "1-2");
}
function sample2() {
assert_approx_equals(rect.width.animVal.value, 30, epsilon, "2-1");
assert_equals(rect.width.baseVal.value, 10, "2-2");
}
function sample3() {
assert_approx_equals(rect.width.animVal.value, 50, epsilon, "3-1");
assert_equals(rect.width.baseVal.value, 10, "3-2");
}
function sample4() {
assert_approx_equals(rect.width.animVal.value, 10, epsilon, "4-1");
assert_equals(rect.width.baseVal.value, 10, "4-2");
}
function sample5() {
assert_approx_equals(rect.width.animVal.value, 55, epsilon, "5-1");
assert_equals(rect.width.baseVal.value, 10, "5-2");
}
function sample6() {
console.log(rootSVGElement.getCurrentTime() + " - 6");
assert_approx_equals(rect.width.animVal.value, 100, epsilon, "6-1");
assert_equals(rect.width.baseVal.value, 10, "6-2");
}
smil_async_test(t => {
const expectedValues = [
// [animationId, time, sampleCallback]
["an1", 0.0, sample1],
["an1", 2.0, sample2],
["an1", 3.999, sample3],
["an1", 4.001, sample4],
["an1", 7.0, sample5],
["an1", 9.0, sample6],
["an1", 60.0, sample6]
];
runAnimationTest(t, expectedValues);
});
</script>
</html>