2011-05-26 Rob Buis <rbuis@rim.com>
[WebKit-https.git] / LayoutTests / svg / animations / script-tests / animate-insert-begin.js
1 description("Test behavior of dynamically inserting animate with begin attribute");
2 createSVGTestCase();
3
4
5 // Setup test document
6 var rect = createSVGElement("rect");
7 rect.setAttribute("id", "rect");
8 rect.setAttribute("x", "0");
9 rect.setAttribute("y", "45");
10 rect.setAttribute("width", "10");
11 rect.setAttribute("height", "10");
12 rect.setAttribute("fill", "green");
13 rect.setAttribute("onclick", "executeTest()");
14
15 var animate = createSVGElement("animate");
16 animate.setAttribute("id", "animation");
17 animate.setAttribute("attributeName", "x");
18 animate.setAttribute("begin", "0");
19 animate.setAttribute("from", "0");
20 animate.setAttribute("to", "90");
21 animate.setAttribute("dur", "3s");
22 animate.setAttribute("fill", "freeze");
23 rect.appendChild(animate);
24 rootSVGElement.appendChild(rect);
25
26 // Setup animation test
27 function sample1() {
28     shouldBe("rect.x.baseVal.value", "0");
29 }
30
31 function sample2() {
32     shouldBe("rect.x.baseVal.value", "90");
33 }
34
35 function executeTest() {
36     const expectedValues = [
37         // [animationId, time, elementId, sampleCallback]
38         ["animation", 0.0,    "rect", sample1],
39         ["animation", 3.0,    "rect", sample2],
40     ];
41
42     runAnimationTest(expectedValues);
43 }
44
45 // Begin test async
46 window.setTimeout("triggerUpdate(5, 50)", 0);
47 var successfullyParsed = true;