blob: 712c2c8dd407930d9f5182b65d1b29729f3fc1bb [file] [log] [blame]
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
<html>
<head>
<script src="../../resources/js-test-pre.js"></script>
<script src="../dynamic-updates/resources/SVGTestCase.js"></script>
<script src="resources/SVGAnimationTestCase.js"></script>
</head>
<body onload="runSMILTest()">
<h1>SVG 1.1 dynamic animation tests</h1>
<p id="description"></p>
<div id="console"></div>
<script>
description("test to determine whether inserting mpath dynamically works");
createSVGTestCase();
rootSVGElement.setAttribute("width", 800)
var defs = createSVGElement("defs")
var path = createSVGElement("path")
path.setAttribute("id", "path")
path.setAttribute("d", "M 100,250 C 100,50 400,50 400,250")
defs.appendChild(path)
rootSVGElement.appendChild(defs)
var g = createSVGElement("g")
g.setAttribute("id", "g")
var rect = createSVGElement("rect")
rect.setAttribute("id", "rect")
rect.setAttribute("width", "40")
rect.setAttribute("height", "40")
rect.setAttribute("fill", "green")
rect.setAttribute("onclick", "executeTest()")
g.appendChild(rect)
var animateMotion = createSVGElement("animateMotion")
animateMotion.setAttribute("id", "animation")
animateMotion.setAttribute("dur", "4s")
animateMotion.setAttribute("repeatCount", "1")
animateMotion.setAttribute("begin", "click")
var mpath = createSVGElement("mpath");
mpath.setAttributeNS(xlinkNS, "xlink:href", "#path")
animateMotion.appendChild(mpath)
g.appendChild(animateMotion)
rootSVGElement.appendChild(g)
function startSample() {
shouldBeCloseEnough("rootSVGElement.getBBox().x", "100", 1);
shouldBeCloseEnough("rootSVGElement.getBBox().y", "250", 1);
}
function endSample() {
shouldBeCloseEnough("rootSVGElement.getBBox().x", "400", 1);
shouldBeCloseEnough("rootSVGElement.getBBox().y", "250", 1);
}
function executeTest() {
const expectedValues = [
["animation", 0.001, startSample],
["animation", 3.999, endSample]
];
runAnimationTest(expectedValues);
}
window.clickX = 30;
window.clickY = 30;
var successfullyParsed = true;
</script>
</body>
</html>