Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / svg / animations / script-tests / animate-mpath-insert.js
blobc0391b66f3e99744fe301d2b18212c40c42f9711
1 description("test to determine whether inserting mpath dynamically works");
2 createSVGTestCase();
4 rootSVGElement.setAttribute("width", 800)
6 var defs = createSVGElement("defs")
7 var path = createSVGElement("path")
8 path.setAttribute("id", "path")
9 path.setAttribute("d", "M 100,250 C 100,50 400,50 400,250")
10 defs.appendChild(path)
11 rootSVGElement.appendChild(defs)
13 var g = createSVGElement("g")
14 g.setAttribute("id", "g")
16 var rect = createSVGElement("rect")
17 rect.setAttribute("id", "rect")
18 rect.setAttribute("width", "40")
19 rect.setAttribute("height", "40")
20 rect.setAttribute("fill", "green")
21 rect.setAttribute("onclick", "executeTest()")
22 g.appendChild(rect)
24 var animateMotion = createSVGElement("animateMotion")
25 animateMotion.setAttribute("id", "animation")
26 animateMotion.setAttribute("dur", "4s")
27 animateMotion.setAttribute("repeatCount", "1")
28 animateMotion.setAttribute("begin", "click")
30 var mpath = createSVGElement("mpath");
31 mpath.setAttributeNS(xlinkNS, "xlink:href", "#path")
33 animateMotion.appendChild(mpath)
34 g.appendChild(animateMotion)
35 rootSVGElement.appendChild(g)
37 function startSample() {
38 shouldBeCloseEnough("rootSVGElement.getBBox().x", "100", 1);
39 shouldBeCloseEnough("rootSVGElement.getBBox().y", "250", 1);
42 function endSample() {
43 shouldBeCloseEnough("rootSVGElement.getBBox().x", "400", 1);
44 shouldBeCloseEnough("rootSVGElement.getBBox().y", "250", 1);
47 function executeTest() {
48 const expectedValues = [
49 ["animation", 0.001, startSample],
50 ["animation", 3.999, endSample]
53 runAnimationTest(expectedValues);
56 window.clickX = 30;
57 window.clickY = 30;
58 var successfullyParsed = true;