1 description("Test for SVGNumber animation.");
5 var rect
= createSVGElement("rect");
6 rect
.setAttribute("id", "rect");
7 rect
.setAttribute("x", "0");
8 rect
.setAttribute("width", "100");
9 rect
.setAttribute("height", "100");
10 rect
.setAttribute("fill", "green");
11 rect
.setAttribute("opacity", "0");
12 rect
.setAttribute("onclick", "executeTest()");
14 var animate
= createSVGElement("animate");
15 animate
.setAttribute("id", "animation");
16 animate
.setAttribute("attributeName", "opacity");
17 animate
.setAttribute("begin", "click");
18 animate
.setAttribute("dur", "4s");
19 animate
.setAttribute("from", "0");
20 animate
.setAttribute("to", "1");
21 rect
.appendChild(animate
);
22 rootSVGElement
.appendChild(rect
);
24 // Setup animation test
26 // Check initial/end conditions
27 shouldBeCloseEnough("parseFloat(getComputedStyle(rect).opacity)", "0");
31 shouldBeCloseEnough("parseFloat(getComputedStyle(rect).opacity)", "0.5");
35 shouldBeCloseEnough("parseFloat(getComputedStyle(rect).opacity)", "1");
38 function executeTest() {
39 const expectedValues
= [
40 // [animationId, time, sampleCallback]
41 ["animation", 0.0, sample1
],
42 ["animation", 2.0, sample2
],
43 ["animation", 3.999, sample3
],
44 ["animation", 4.001, sample1
]
47 runAnimationTest(expectedValues
);
50 var successfullyParsed
= true;