зеркало из https://github.com/mozilla/gecko-dev.git
Bug 562815 part 2b - Add even more tests; r=dholbert
--HG-- extra : rebase_source : bfe07feecc89dc9a882c39d7b5111f71d1f6f57a
This commit is contained in:
Родитель
38599c454e
Коммит
875134cfe4
|
@ -81,6 +81,7 @@ function main()
|
|||
[ testBaseValueChange,
|
||||
testCurrentColorChange,
|
||||
testCurrentColorChangeUsingStyle,
|
||||
testCurrentColorChangeOnFallback,
|
||||
testInheritChange,
|
||||
testInheritChangeUsingStyle,
|
||||
testEmUnitChangeOnProp,
|
||||
|
@ -91,7 +92,9 @@ function main()
|
|||
testRelativeFontSize,
|
||||
testRelativeFontWeight,
|
||||
testRelativeFont,
|
||||
testCalcFontSize
|
||||
testCalcFontSize,
|
||||
testDashArray,
|
||||
testClip
|
||||
];
|
||||
|
||||
while (tests.length) {
|
||||
|
@ -121,6 +124,18 @@ function createAnimBy(attrName, byVal)
|
|||
return gCircle.appendChild(anim);
|
||||
}
|
||||
|
||||
function createAnimFromTo(attrName, fromVal, toVal)
|
||||
{
|
||||
var anim = document.createElementNS(SVGNS,"animate");
|
||||
anim.setAttribute("attributeName", attrName);
|
||||
anim.setAttribute("dur", ANIM_DUR);
|
||||
anim.setAttribute("begin","0s");
|
||||
anim.setAttribute("from", fromVal);
|
||||
anim.setAttribute("to", toVal);
|
||||
anim.setAttribute("fill", "freeze");
|
||||
return gCircle.appendChild(anim);
|
||||
}
|
||||
|
||||
// Common setup code for each test function: seek to 0, and make sure
|
||||
// the previous test cleaned up its animations.
|
||||
function setupTest() {
|
||||
|
@ -197,6 +212,33 @@ function testCurrentColorChangeUsingStyle()
|
|||
gCircle.removeChild(gCircle.firstChild);
|
||||
}
|
||||
|
||||
function getFallbackColor(pServerStr)
|
||||
{
|
||||
return pServerStr.substr(pServerStr.indexOf(" ")+1);
|
||||
}
|
||||
|
||||
function testCurrentColorChangeOnFallback()
|
||||
{
|
||||
setupTest();
|
||||
gCircle.setAttribute("color", "red"); // At first: currentColor=red
|
||||
var anim = createAnimSetTo("fill", "url(#missingGrad) currentColor");
|
||||
|
||||
gSvg.setCurrentTime(0);
|
||||
var fallback =
|
||||
getFallbackColor(SMILUtil.getComputedStyleSimple(gCircle, "fill"));
|
||||
is(fallback, "rgb(255, 0, 0)",
|
||||
"Checking animated fallback fill=currentColor after animating");
|
||||
|
||||
gCircle.setAttribute("color", "lime"); // Change: currentColor=lime
|
||||
gSvg.setCurrentTime(0);
|
||||
fallback = getFallbackColor(SMILUtil.getComputedStyleSimple(gCircle, "fill"));
|
||||
is(fallback, "rgb(0, 255, 0)",
|
||||
"Checking animated fallback fill=currentColor after updating context");
|
||||
|
||||
gCircle.removeAttribute("style");
|
||||
gCircle.removeChild(gCircle.firstChild);
|
||||
}
|
||||
|
||||
function testInheritChange()
|
||||
{
|
||||
setupTest();
|
||||
|
@ -459,6 +501,66 @@ function testCalcFontSize()
|
|||
gCircle.removeChild(gCircle.firstChild);
|
||||
}
|
||||
|
||||
function testDashArray()
|
||||
{
|
||||
// stroke dasharrays don't currently convert units--but if someone ever fixes
|
||||
// that, hopefully this test will fail and remind us not to cache percentage
|
||||
// values in that case
|
||||
setupTest();
|
||||
var oldHeight = gSvg.getAttribute("height");
|
||||
var oldWidth = gSvg.getAttribute("width");
|
||||
gSvg.setAttribute("height", "100px"); // At first: viewport: 100x100px
|
||||
gSvg.setAttribute("width", "100px");
|
||||
var anim = createAnimFromTo("stroke-dasharray", "0 5", "0 50%");
|
||||
|
||||
gSvg.setCurrentTime(TIME_AFTER_ANIM_END);
|
||||
|
||||
// Now we should be up to date
|
||||
is(SMILUtil.getComputedStyleSimple(gCircle, "stroke-dasharray"), "0, 50%",
|
||||
"Checking animated stroke-dasharray after animating");
|
||||
|
||||
gSvg.setAttribute("height", "50px"); // Change viewport: 50x50px
|
||||
gSvg.setAttribute("width", "50px");
|
||||
gSvg.setCurrentTime(TIME_AFTER_ANIM_END);
|
||||
is(SMILUtil.getComputedStyleSimple(gCircle, "stroke-dasharray"), "0, 50%",
|
||||
"Checking animated stroke-dasharray after updating context");
|
||||
|
||||
gSvg.setAttribute("height", oldHeight);
|
||||
gSvg.setAttribute("width", oldWidth);
|
||||
gCircle.removeChild(gCircle.firstChild);
|
||||
}
|
||||
|
||||
function testClip()
|
||||
{
|
||||
setupTest();
|
||||
gCircleParent.setAttribute("font-size", "20px"); // At first: font-size: 20px
|
||||
|
||||
// The clip property only applies to elements that establish a new
|
||||
// viewport so we need to create a nested svg and add animation to that
|
||||
var nestedSVG = document.createElementNS(SVGNS, "svg");
|
||||
nestedSVG.setAttribute("clip", "rect(0px 0px 0px 0px)");
|
||||
gCircleParent.appendChild(nestedSVG);
|
||||
|
||||
var anim = createAnimSetTo("clip", "rect(1em 1em 1em 1em)");
|
||||
// createAnimSetTo will make the animation a child of gCircle so we need to
|
||||
// move it so it targets nestedSVG instead
|
||||
nestedSVG.appendChild(anim);
|
||||
|
||||
gSvg.setCurrentTime(TIME_AFTER_ANIM_END);
|
||||
is(SMILUtil.getComputedStyleSimple(nestedSVG, "clip"),
|
||||
"rect(20px, 20px, 20px, 20px)",
|
||||
"Checking animated clip rect after animating");
|
||||
|
||||
gCircleParent.setAttribute("font-size", "10px"); // Change: font-size: 10px
|
||||
gSvg.setCurrentTime(TIME_AFTER_ANIM_END);
|
||||
is(SMILUtil.getComputedStyleSimple(nestedSVG, "clip"),
|
||||
"rect(10px, 10px, 10px, 10px)",
|
||||
"Checking animated clip rect after updating context");
|
||||
|
||||
gCircleParent.removeAttribute("font-size");
|
||||
gCircleParent.removeChild(nestedSVG);
|
||||
}
|
||||
|
||||
window.addEventListener("load", main, false);
|
||||
]]>
|
||||
</script>
|
||||
|
|
Загрузка…
Ссылка в новой задаче