gecko/dom/smil/test/test_smilChangeAfterFrozen.xhtml
Robert O'Callahan cc8b720bee Bug 946065. Part 3: Move content/smil to dom/smil. r=Ms2ger
--HG--
rename : content/smil/SMILBoolType.cpp => dom/smil/SMILBoolType.cpp
rename : content/smil/SMILBoolType.h => dom/smil/SMILBoolType.h
rename : content/smil/SMILEnumType.cpp => dom/smil/SMILEnumType.cpp
rename : content/smil/SMILEnumType.h => dom/smil/SMILEnumType.h
rename : content/smil/SMILIntegerType.cpp => dom/smil/SMILIntegerType.cpp
rename : content/smil/SMILIntegerType.h => dom/smil/SMILIntegerType.h
rename : content/smil/SMILStringType.cpp => dom/smil/SMILStringType.cpp
rename : content/smil/SMILStringType.h => dom/smil/SMILStringType.h
rename : content/smil/crashtests/483584-1.svg => dom/smil/crashtests/483584-1.svg
rename : content/smil/crashtests/483584-2.svg => dom/smil/crashtests/483584-2.svg
rename : content/smil/crashtests/523188-1.svg => dom/smil/crashtests/523188-1.svg
rename : content/smil/crashtests/525099-1.svg => dom/smil/crashtests/525099-1.svg
rename : content/smil/crashtests/526536-1.svg => dom/smil/crashtests/526536-1.svg
rename : content/smil/crashtests/526875-1.svg => dom/smil/crashtests/526875-1.svg
rename : content/smil/crashtests/526875-2.svg => dom/smil/crashtests/526875-2.svg
rename : content/smil/crashtests/529387-1-helper.svg => dom/smil/crashtests/529387-1-helper.svg
rename : content/smil/crashtests/529387-1.xhtml => dom/smil/crashtests/529387-1.xhtml
rename : content/smil/crashtests/531550-1.svg => dom/smil/crashtests/531550-1.svg
rename : content/smil/crashtests/537157-1.svg => dom/smil/crashtests/537157-1.svg
rename : content/smil/crashtests/541297-1.svg => dom/smil/crashtests/541297-1.svg
rename : content/smil/crashtests/547333-1.svg => dom/smil/crashtests/547333-1.svg
rename : content/smil/crashtests/548899-1.svg => dom/smil/crashtests/548899-1.svg
rename : content/smil/crashtests/551620-1.svg => dom/smil/crashtests/551620-1.svg
rename : content/smil/crashtests/554141-1.svg => dom/smil/crashtests/554141-1.svg
rename : content/smil/crashtests/554202-1.svg => dom/smil/crashtests/554202-1.svg
rename : content/smil/crashtests/554202-2.svg => dom/smil/crashtests/554202-2.svg
rename : content/smil/crashtests/555026-1.svg => dom/smil/crashtests/555026-1.svg
rename : content/smil/crashtests/556841-1.svg => dom/smil/crashtests/556841-1.svg
rename : content/smil/crashtests/572938-1.svg => dom/smil/crashtests/572938-1.svg
rename : content/smil/crashtests/572938-2.svg => dom/smil/crashtests/572938-2.svg
rename : content/smil/crashtests/572938-3.svg => dom/smil/crashtests/572938-3.svg
rename : content/smil/crashtests/572938-4.svg => dom/smil/crashtests/572938-4.svg
rename : content/smil/crashtests/588287-1.svg => dom/smil/crashtests/588287-1.svg
rename : content/smil/crashtests/588287-2.svg => dom/smil/crashtests/588287-2.svg
rename : content/smil/crashtests/590425-1.html => dom/smil/crashtests/590425-1.html
rename : content/smil/crashtests/592477-1.xhtml => dom/smil/crashtests/592477-1.xhtml
rename : content/smil/crashtests/594653-1.svg => dom/smil/crashtests/594653-1.svg
rename : content/smil/crashtests/596796-1.svg => dom/smil/crashtests/596796-1.svg
rename : content/smil/crashtests/605345-1.svg => dom/smil/crashtests/605345-1.svg
rename : content/smil/crashtests/606101-1.svg => dom/smil/crashtests/606101-1.svg
rename : content/smil/crashtests/608295-1.html => dom/smil/crashtests/608295-1.html
rename : content/smil/crashtests/608549-1.svg => dom/smil/crashtests/608549-1.svg
rename : content/smil/crashtests/611927-1.svg => dom/smil/crashtests/611927-1.svg
rename : content/smil/crashtests/615002-1.svg => dom/smil/crashtests/615002-1.svg
rename : content/smil/crashtests/615872-1.svg => dom/smil/crashtests/615872-1.svg
rename : content/smil/crashtests/641388-1.html => dom/smil/crashtests/641388-1.html
rename : content/smil/crashtests/641388-2.html => dom/smil/crashtests/641388-2.html
rename : content/smil/crashtests/650732-1.svg => dom/smil/crashtests/650732-1.svg
rename : content/smil/crashtests/665334-1.svg => dom/smil/crashtests/665334-1.svg
rename : content/smil/crashtests/669225-1.svg => dom/smil/crashtests/669225-1.svg
rename : content/smil/crashtests/669225-2.svg => dom/smil/crashtests/669225-2.svg
rename : content/smil/crashtests/670313-1.svg => dom/smil/crashtests/670313-1.svg
rename : content/smil/crashtests/678822-1.svg => dom/smil/crashtests/678822-1.svg
rename : content/smil/crashtests/678847-1.svg => dom/smil/crashtests/678847-1.svg
rename : content/smil/crashtests/678938-1.svg => dom/smil/crashtests/678938-1.svg
rename : content/smil/crashtests/690994-1.svg => dom/smil/crashtests/690994-1.svg
rename : content/smil/crashtests/691337-1.svg => dom/smil/crashtests/691337-1.svg
rename : content/smil/crashtests/691337-2.svg => dom/smil/crashtests/691337-2.svg
rename : content/smil/crashtests/697640-1.svg => dom/smil/crashtests/697640-1.svg
rename : content/smil/crashtests/699325-1.svg => dom/smil/crashtests/699325-1.svg
rename : content/smil/crashtests/709907-1.svg => dom/smil/crashtests/709907-1.svg
rename : content/smil/crashtests/720103-1.svg => dom/smil/crashtests/720103-1.svg
rename : content/smil/crashtests/crashtests.list => dom/smil/crashtests/crashtests.list
rename : content/smil/moz.build => dom/smil/moz.build
rename : content/smil/nsDOMTimeEvent.cpp => dom/smil/nsDOMTimeEvent.cpp
rename : content/smil/nsDOMTimeEvent.h => dom/smil/nsDOMTimeEvent.h
rename : content/smil/nsISMILAttr.h => dom/smil/nsISMILAttr.h
rename : content/smil/nsISMILType.h => dom/smil/nsISMILType.h
rename : content/smil/nsSMILAnimationController.cpp => dom/smil/nsSMILAnimationController.cpp
rename : content/smil/nsSMILAnimationController.h => dom/smil/nsSMILAnimationController.h
rename : content/smil/nsSMILAnimationFunction.cpp => dom/smil/nsSMILAnimationFunction.cpp
rename : content/smil/nsSMILAnimationFunction.h => dom/smil/nsSMILAnimationFunction.h
rename : content/smil/nsSMILCSSProperty.cpp => dom/smil/nsSMILCSSProperty.cpp
rename : content/smil/nsSMILCSSProperty.h => dom/smil/nsSMILCSSProperty.h
rename : content/smil/nsSMILCSSValueType.cpp => dom/smil/nsSMILCSSValueType.cpp
rename : content/smil/nsSMILCSSValueType.h => dom/smil/nsSMILCSSValueType.h
rename : content/smil/nsSMILCompositor.cpp => dom/smil/nsSMILCompositor.cpp
rename : content/smil/nsSMILCompositor.h => dom/smil/nsSMILCompositor.h
rename : content/smil/nsSMILCompositorTable.h => dom/smil/nsSMILCompositorTable.h
rename : content/smil/nsSMILFloatType.cpp => dom/smil/nsSMILFloatType.cpp
rename : content/smil/nsSMILFloatType.h => dom/smil/nsSMILFloatType.h
rename : content/smil/nsSMILInstanceTime.cpp => dom/smil/nsSMILInstanceTime.cpp
rename : content/smil/nsSMILInstanceTime.h => dom/smil/nsSMILInstanceTime.h
rename : content/smil/nsSMILInterval.cpp => dom/smil/nsSMILInterval.cpp
rename : content/smil/nsSMILInterval.h => dom/smil/nsSMILInterval.h
rename : content/smil/nsSMILKeySpline.cpp => dom/smil/nsSMILKeySpline.cpp
rename : content/smil/nsSMILKeySpline.h => dom/smil/nsSMILKeySpline.h
rename : content/smil/nsSMILMappedAttribute.cpp => dom/smil/nsSMILMappedAttribute.cpp
rename : content/smil/nsSMILMappedAttribute.h => dom/smil/nsSMILMappedAttribute.h
rename : content/smil/nsSMILMilestone.h => dom/smil/nsSMILMilestone.h
rename : content/smil/nsSMILNullType.cpp => dom/smil/nsSMILNullType.cpp
rename : content/smil/nsSMILNullType.h => dom/smil/nsSMILNullType.h
rename : content/smil/nsSMILParserUtils.cpp => dom/smil/nsSMILParserUtils.cpp
rename : content/smil/nsSMILParserUtils.h => dom/smil/nsSMILParserUtils.h
rename : content/smil/nsSMILRepeatCount.cpp => dom/smil/nsSMILRepeatCount.cpp
rename : content/smil/nsSMILRepeatCount.h => dom/smil/nsSMILRepeatCount.h
rename : content/smil/nsSMILSetAnimationFunction.cpp => dom/smil/nsSMILSetAnimationFunction.cpp
rename : content/smil/nsSMILSetAnimationFunction.h => dom/smil/nsSMILSetAnimationFunction.h
rename : content/smil/nsSMILTargetIdentifier.h => dom/smil/nsSMILTargetIdentifier.h
rename : content/smil/nsSMILTimeContainer.cpp => dom/smil/nsSMILTimeContainer.cpp
rename : content/smil/nsSMILTimeContainer.h => dom/smil/nsSMILTimeContainer.h
rename : content/smil/nsSMILTimeValue.cpp => dom/smil/nsSMILTimeValue.cpp
rename : content/smil/nsSMILTimeValue.h => dom/smil/nsSMILTimeValue.h
rename : content/smil/nsSMILTimeValueSpec.cpp => dom/smil/nsSMILTimeValueSpec.cpp
rename : content/smil/nsSMILTimeValueSpec.h => dom/smil/nsSMILTimeValueSpec.h
rename : content/smil/nsSMILTimeValueSpecParams.h => dom/smil/nsSMILTimeValueSpecParams.h
rename : content/smil/nsSMILTimedElement.cpp => dom/smil/nsSMILTimedElement.cpp
rename : content/smil/nsSMILTimedElement.h => dom/smil/nsSMILTimedElement.h
rename : content/smil/nsSMILTypes.h => dom/smil/nsSMILTypes.h
rename : content/smil/nsSMILValue.cpp => dom/smil/nsSMILValue.cpp
rename : content/smil/nsSMILValue.h => dom/smil/nsSMILValue.h
rename : content/smil/test/db_smilAnimateMotion.js => dom/smil/test/db_smilAnimateMotion.js
rename : content/smil/test/db_smilCSSFromBy.js => dom/smil/test/db_smilCSSFromBy.js
rename : content/smil/test/db_smilCSSFromTo.js => dom/smil/test/db_smilCSSFromTo.js
rename : content/smil/test/db_smilCSSPaced.js => dom/smil/test/db_smilCSSPaced.js
rename : content/smil/test/db_smilCSSPropertyList.js => dom/smil/test/db_smilCSSPropertyList.js
rename : content/smil/test/db_smilMappedAttrList.js => dom/smil/test/db_smilMappedAttrList.js
rename : content/smil/test/mochitest.ini => dom/smil/test/mochitest.ini
rename : content/smil/test/moz.build => dom/smil/test/moz.build
rename : content/smil/test/smilAnimateMotionValueLists.js => dom/smil/test/smilAnimateMotionValueLists.js
rename : content/smil/test/smilExtDoc_helper.svg => dom/smil/test/smilExtDoc_helper.svg
rename : content/smil/test/smilTestUtils.js => dom/smil/test/smilTestUtils.js
rename : content/smil/test/smilXHR_helper.svg => dom/smil/test/smilXHR_helper.svg
rename : content/smil/test/test_smilAccessKey.xhtml => dom/smil/test/test_smilAccessKey.xhtml
rename : content/smil/test/test_smilAnimateMotion.xhtml => dom/smil/test/test_smilAnimateMotion.xhtml
rename : content/smil/test/test_smilAnimateMotionInvalidValues.xhtml => dom/smil/test/test_smilAnimateMotionInvalidValues.xhtml
rename : content/smil/test/test_smilAnimateMotionOverrideRules.xhtml => dom/smil/test/test_smilAnimateMotionOverrideRules.xhtml
rename : content/smil/test/test_smilBackwardsSeeking.xhtml => dom/smil/test/test_smilBackwardsSeeking.xhtml
rename : content/smil/test/test_smilCSSFontStretchRelative.xhtml => dom/smil/test/test_smilCSSFontStretchRelative.xhtml
rename : content/smil/test/test_smilCSSFromBy.xhtml => dom/smil/test/test_smilCSSFromBy.xhtml
rename : content/smil/test/test_smilCSSFromTo.xhtml => dom/smil/test/test_smilCSSFromTo.xhtml
rename : content/smil/test/test_smilCSSInherit.xhtml => dom/smil/test/test_smilCSSInherit.xhtml
rename : content/smil/test/test_smilCSSInvalidValues.xhtml => dom/smil/test/test_smilCSSInvalidValues.xhtml
rename : content/smil/test/test_smilCSSPaced.xhtml => dom/smil/test/test_smilCSSPaced.xhtml
rename : content/smil/test/test_smilChangeAfterFrozen.xhtml => dom/smil/test/test_smilChangeAfterFrozen.xhtml
rename : content/smil/test/test_smilContainerBinding.xhtml => dom/smil/test/test_smilContainerBinding.xhtml
rename : content/smil/test/test_smilCrossContainer.xhtml => dom/smil/test/test_smilCrossContainer.xhtml
rename : content/smil/test/test_smilDynamicDelayedBeginElement.xhtml => dom/smil/test/test_smilDynamicDelayedBeginElement.xhtml
rename : content/smil/test/test_smilExtDoc.xhtml => dom/smil/test/test_smilExtDoc.xhtml
rename : content/smil/test/test_smilFillMode.xhtml => dom/smil/test/test_smilFillMode.xhtml
rename : content/smil/test/test_smilGetSimpleDuration.xhtml => dom/smil/test/test_smilGetSimpleDuration.xhtml
rename : content/smil/test/test_smilGetStartTime.xhtml => dom/smil/test/test_smilGetStartTime.xhtml
rename : content/smil/test/test_smilHyperlinking.xhtml => dom/smil/test/test_smilHyperlinking.xhtml
rename : content/smil/test/test_smilInvalidValues.html => dom/smil/test/test_smilInvalidValues.html
rename : content/smil/test/test_smilKeySplines.xhtml => dom/smil/test/test_smilKeySplines.xhtml
rename : content/smil/test/test_smilKeyTimes.xhtml => dom/smil/test/test_smilKeyTimes.xhtml
rename : content/smil/test/test_smilKeyTimesPacedMode.xhtml => dom/smil/test/test_smilKeyTimesPacedMode.xhtml
rename : content/smil/test/test_smilMappedAttrFromBy.xhtml => dom/smil/test/test_smilMappedAttrFromBy.xhtml
rename : content/smil/test/test_smilMappedAttrFromTo.xhtml => dom/smil/test/test_smilMappedAttrFromTo.xhtml
rename : content/smil/test/test_smilMappedAttrPaced.xhtml => dom/smil/test/test_smilMappedAttrPaced.xhtml
rename : content/smil/test/test_smilMinTiming.html => dom/smil/test/test_smilMinTiming.html
rename : content/smil/test/test_smilRepeatDuration.html => dom/smil/test/test_smilRepeatDuration.html
rename : content/smil/test/test_smilRepeatTiming.xhtml => dom/smil/test/test_smilRepeatTiming.xhtml
rename : content/smil/test/test_smilReset.xhtml => dom/smil/test/test_smilReset.xhtml
rename : content/smil/test/test_smilRestart.xhtml => dom/smil/test/test_smilRestart.xhtml
rename : content/smil/test/test_smilSetCurrentTime.xhtml => dom/smil/test/test_smilSetCurrentTime.xhtml
rename : content/smil/test/test_smilSync.xhtml => dom/smil/test/test_smilSync.xhtml
rename : content/smil/test/test_smilSyncTransform.xhtml => dom/smil/test/test_smilSyncTransform.xhtml
rename : content/smil/test/test_smilSyncbaseTarget.xhtml => dom/smil/test/test_smilSyncbaseTarget.xhtml
rename : content/smil/test/test_smilTextZoom.xhtml => dom/smil/test/test_smilTextZoom.xhtml
rename : content/smil/test/test_smilTimeEvents.xhtml => dom/smil/test/test_smilTimeEvents.xhtml
rename : content/smil/test/test_smilTiming.xhtml => dom/smil/test/test_smilTiming.xhtml
rename : content/smil/test/test_smilTimingZeroIntervals.xhtml => dom/smil/test/test_smilTimingZeroIntervals.xhtml
rename : content/smil/test/test_smilUpdatedInterval.xhtml => dom/smil/test/test_smilUpdatedInterval.xhtml
rename : content/smil/test/test_smilValues.xhtml => dom/smil/test/test_smilValues.xhtml
rename : content/smil/test/test_smilXHR.xhtml => dom/smil/test/test_smilXHR.xhtml
extra : rebase_source : 4038f574b020b79d3725efd91eeef457d9d6a0b0
2014-01-03 14:49:22 +13:00

570 lines
20 KiB
HTML

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Test for SMIL when things change after an animation is frozen</title>
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<script type="text/javascript" src="smilTestUtils.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
</head>
<body>
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=533291">Mozilla Bug 533291</a>
<p id="display"></p>
<!-- Bug 628848: The following should be display: none but we currently don't
handle percentage lengths properly when the whole fragment is display: none
-->
<div id="content" style="visibility: hidden">
<svg id="svg" xmlns="http://www.w3.org/2000/svg" width="120px" height="120px"
onload="this.pauseAnimations()">
<g id="circleParent">
<circle cx="0" cy="20" r="15" fill="blue" id="circle"/>
</g>
</svg>
</div>
<pre id="test">
<script class="testbody" type="text/javascript">
<![CDATA[
/** Test for SMIL values that are context-sensitive **/
/* See bugs 533291 and 562815.
The format of each test is basically:
1) create some animated and frozen state
2) test the animated values
3) change the context
4) test that context-sensitive animation values have changed
Ideally, after changing the context (3), the animated state would instantly
update. However, this is not currently the case for many situations.
For CSS properties we have bug 545282 - In animations involving 'inherit'
/ 'currentColor', changes to inherited value / 'color' don't show up in
animated value immediately
For SVG lengths we have bug 508206 - Relative units used in
animation don't update immediately
(There are a few of todo_is's in the following tests so that if those bugs
are ever resolved we'll know to update this test case accordingly.)
So in between (3) and (4) we force a sample. This is currently done by
calling SVGSVGElement.setCurrentTime with the same current time which has the
side effect of forcing a sample.
What we *are* testing is that we're not too zealous with caching animation
values whilst in the frozen state. Normally we'd say, "Hey, we're frozen,
let's just use the same animation result as last time" but for some
context-sensitive animation values that doesn't work.
*/
/* Global Variables */
const SVGNS = "http://www.w3.org/2000/svg";
// Animation parameters -- not used for <set> animation
const ANIM_DUR = "4s";
const TIME_ANIM_END = "4";
const TIME_AFTER_ANIM_END = "5";
const gSvg = document.getElementById("svg");
const gCircle = document.getElementById("circle");
const gCircleParent = document.getElementById("circleParent");
SimpleTest.waitForExplicitFinish();
// MAIN FUNCTION
// -------------
function main()
{
ok(gSvg.animationsPaused(), "should be paused by <svg> load handler");
is(gSvg.getCurrentTime(), 0, "should be paused at 0 in <svg> load handler");
const tests =
[ testBaseValueChange,
testCurrentColorChange,
testCurrentColorChangeUsingStyle,
testCurrentColorChangeOnFallback,
testInheritChange,
testInheritChangeUsingStyle,
testEmUnitChangeOnProp,
testEmUnitChangeOnPropBase,
testEmUnitChangeOnLength,
testPercentUnitChangeOnProp,
testPercentUnitChangeOnLength,
testRelativeFontSize,
testRelativeFontWeight,
testRelativeFont,
testCalcFontSize,
testDashArray,
testClip
];
while (tests.length) {
tests.shift()();
}
SimpleTest.finish();
}
// HELPER FUNCTIONS
// ----------------
function createAnimSetTo(attrName, toVal)
{
var anim = document.createElementNS(SVGNS,"set");
anim.setAttribute("attributeName", attrName);
anim.setAttribute("to", toVal);
return gCircle.appendChild(anim);
}
function createAnimBy(attrName, byVal)
{
var anim = document.createElementNS(SVGNS,"animate");
anim.setAttribute("attributeName", attrName);
anim.setAttribute("dur", ANIM_DUR);
anim.setAttribute("begin","0s");
anim.setAttribute("by", byVal);
anim.setAttribute("fill", "freeze");
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() {
gSvg.setCurrentTime(0);
if (gCircle.firstChild) {
ok(false, "Previous test didn't clean up after itself.");
}
}
// THE TESTS
// ---------
function testBaseValueChange()
{
setupTest();
var anim = createAnimBy("cx", "50");
gSvg.setCurrentTime(TIME_ANIM_END);
is(gCircle.cx.animVal.value, 50,
"Checking animated cx as anim ends");
gSvg.setCurrentTime(TIME_AFTER_ANIM_END);
is(gCircle.cx.animVal.value, 50,
"Checking animated cx after anim ends");
gCircle.setAttribute("cx", 20);
is(gCircle.cx.animVal.value, 70,
"Checking animated cx after anim ends & after changing base val");
anim.parentNode.removeChild(anim); // clean up
}
function testCurrentColorChange()
{
gCircle.setAttribute("color", "red"); // At first: currentColor=red
var anim = createAnimSetTo("fill", "currentColor");
gSvg.setCurrentTime(0); // trigger synchronous sample
is(SMILUtil.getComputedStyleSimple(gCircle, "fill"), "rgb(255, 0, 0)",
"Checking animated fill=currentColor after animating");
gCircle.setAttribute("color", "lime"); // Change: currentColor=lime
// Bug 545282: We should really detect this change and update immediately but
// currently we don't until we get sampled again
todo_is(SMILUtil.getComputedStyleSimple(gCircle, "fill"), "rgb(0, 255, 0)",
"Checking animated fill=currentColor after updating context but before " +
"sampling");
gSvg.setCurrentTime(0);
is(SMILUtil.getComputedStyleSimple(gCircle, "fill"), "rgb(0, 255, 0)",
"Checking animated fill=currentColor after updating context");
// Clean up
gCircle.removeAttribute("color");
gCircle.removeChild(gCircle.firstChild);
}
function testCurrentColorChangeUsingStyle()
{
setupTest();
gCircle.setAttribute("style", "color: red"); // At first: currentColor=red
var anim = createAnimSetTo("fill", "currentColor");
gSvg.setCurrentTime(0);
is(SMILUtil.getComputedStyleSimple(gCircle, "fill"), "rgb(255, 0, 0)",
"Checking animated fill=currentColor after animating (using style attr)");
gCircle.setAttribute("style", "color: lime"); // Change: currentColor=lime
gSvg.setCurrentTime(0);
is(SMILUtil.getComputedStyleSimple(gCircle, "fill"), "rgb(0, 255, 0)",
"Checking animated fill=currentColor after updating context "
+ "(using style attr)");
// Clean up
gCircle.removeAttribute("style");
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();
gCircleParent.setAttribute("fill", "red"); // At first: inherit=red
var anim = createAnimSetTo("fill", "inherit");
gSvg.setCurrentTime(0);
is(SMILUtil.getComputedStyleSimple(gCircle, "fill"), "rgb(255, 0, 0)",
"Checking animated fill=inherit after animating");
gCircleParent.setAttribute("fill", "lime"); // Change: inherit=lime
gSvg.setCurrentTime(0);
is(SMILUtil.getComputedStyleSimple(gCircle, "fill"), "rgb(0, 255, 0)",
"Checking animated fill=inherit after updating context");
gCircleParent.removeAttribute("fill");
gCircle.removeChild(gCircle.firstChild);
}
function testInheritChangeUsingStyle()
{
setupTest();
gCircleParent.setAttribute("style", "fill: red"); // At first: inherit=red
var anim = createAnimSetTo("fill", "inherit");
gSvg.setCurrentTime(0);
is(SMILUtil.getComputedStyleSimple(gCircle, "fill"), "rgb(255, 0, 0)",
"Checking animated fill=inherit after animating (using style attr)");
gCircleParent.setAttribute("style", "fill: lime"); // Change: inherit=lime
gSvg.setCurrentTime(0);
is(SMILUtil.getComputedStyleSimple(gCircle, "fill"), "rgb(0, 255, 0)",
"Checking animated fill=inherit after updating context "
+ "(using style attr)");
gCircleParent.removeAttribute("style");
gCircle.removeChild(gCircle.firstChild);
}
function testEmUnitChangeOnProp()
{
setupTest();
gCircleParent.setAttribute("font-size", "10px"); // At first: font-size: 10px
var anim = createAnimSetTo("font-size", "2em");
gSvg.setCurrentTime(0);
is(SMILUtil.getComputedStyleSimple(gCircle, "font-size"), "20px",
"Checking animated font-size=2em after animating ends");
gCircleParent.setAttribute("font-size", "20px"); // Change: font-size: 20px
gSvg.setCurrentTime(0);
is(SMILUtil.getComputedStyleSimple(gCircle, "font-size"), "40px",
"Checking animated font-size=2em after updating context");
gCircleParent.removeAttribute("font-size");
gCircle.removeChild(gCircle.firstChild);
}
function testEmUnitChangeOnPropBase()
{
// Test the case where the base value for our animation sandwich is
// context-sensitive.
// Currently, this is taken care of by the compositor which keeps a cached
// base value and compares it with the current base value. This test then just
// serves as a regression test in case the compositor's behaviour changes.
setupTest();
gSvg.setAttribute("font-size", "10px"); // At first: font-size: 10px
gCircleParent.setAttribute("font-size", "1em"); // Base: 10px
var anim = createAnimBy("font-size", "10px");
gSvg.setCurrentTime(TIME_AFTER_ANIM_END);
is(SMILUtil.getComputedStyleSimple(gCircle, "font-size"), "20px",
"Checking animated font-size=20px after anim ends");
gSvg.setAttribute("font-size", "20px"); // Change: font-size: 20px
gSvg.setCurrentTime(TIME_AFTER_ANIM_END);
is(SMILUtil.getComputedStyleSimple(gCircle, "font-size"), "30px",
"Checking animated font-size=30px after updating context");
gCircleParent.removeAttribute("font-size");
gCircle.removeChild(gCircle.firstChild);
}
function testEmUnitChangeOnLength()
{
setupTest();
gCircleParent.setAttribute("font-size", "10px"); // At first: font-size: 10px
var anim = createAnimSetTo("cx", "2em");
gSvg.setCurrentTime(0);
is(gCircle.cx.animVal.value, 20,
"Checking animated length=2em after animating");
gCircleParent.setAttribute("font-size", "20px"); // Change: font-size: 20px
// Bug 508206: We should really detect this change and update immediately but
// currently we don't until we get sampled again
todo_is(gCircle.cx.animVal.value, 40,
"Checking animated length=2em after updating context but before sampling");
gSvg.setCurrentTime(0);
is(gCircle.cx.animVal.value, 40,
"Checking animated length=2em after updating context and after " +
"resampling");
gCircleParent.removeAttribute("font-size");
gCircle.removeChild(gCircle.firstChild);
}
function testPercentUnitChangeOnProp()
{
setupTest();
gCircleParent.setAttribute("font-size", "10px"); // At first: font-size: 10px
var anim = createAnimSetTo("font-size", "150%");
gSvg.setCurrentTime(0);
is(SMILUtil.getComputedStyleSimple(gCircle, "font-size"), "15px",
"Checking animated font-size=150% after animating");
gCircleParent.setAttribute("font-size", "20px"); // Change: font-size: 20px
gSvg.setCurrentTime(0);
is(SMILUtil.getComputedStyleSimple(gCircle, "font-size"), "30px",
"Checking animated font-size=150% after updating context");
gCircleParent.removeAttribute("font-size");
gCircle.removeChild(gCircle.firstChild);
}
function testPercentUnitChangeOnLength()
{
setupTest();
var oldHeight = gSvg.getAttribute("height");
gSvg.setAttribute("height", "100px"); // At first: viewport height: 100px
var anim = createAnimSetTo("cy", "100%");
gSvg.setCurrentTime(0); // Force synchronous sample so animation takes effect
// Due to bug 627594 (SVGLength.value for percent value lengths doesn't
// reflect updated viewport until reflow) the following will fail.
// Check that it does indeed fail so that when that bug is fixed this test
// can be updated.
todo_is(gCircle.cy.animVal.value, 100,
"Checking animated length=100% after animating but before reflow");
gSvg.forceRedraw();
// Even after doing a reflow though we'll still fail due to bug 508206
// (Relative units used in animation don't update immediately)
todo_is(gCircle.cy.animVal.value, 100,
"Checking animated length=100% after animating but before resampling");
gSvg.setCurrentTime(0);
// Now we should be up to date
is(gCircle.cy.animVal.value, 100,
"Checking animated length=100% after animating");
gSvg.setAttribute("height", "50px"); // Change: height: 50px
gSvg.forceRedraw(); // Bug 627594
gSvg.setCurrentTime(0); // Bug 508206
is(gCircle.cy.animVal.value, 50,
"Checking animated length=100% after updating context");
gSvg.setAttribute("height", oldHeight);
gCircle.removeChild(gCircle.firstChild);
}
function testRelativeFontSize()
{
setupTest();
gCircleParent.setAttribute("font-size", "10px"); // At first: font-size: 10px
var anim = createAnimSetTo("font-size", "larger");
gSvg.setCurrentTime(0);
var fsize = parseInt(SMILUtil.getComputedStyleSimple(gCircle, "font-size"));
// CSS 2 suggests a scaling factor of 1.2 so we should be looking at something
// around about 12 or so
ok(fsize > 10 && fsize < 20,
"Checking animated font-size > 10px after animating");
gCircleParent.setAttribute("font-size", "20px"); // Change: font-size: 20px
gSvg.setCurrentTime(0);
fsize = parseInt(SMILUtil.getComputedStyleSimple(gCircle, "font-size"));
ok(fsize > 20, "Checking animated font-size > 20px after updating context");
gCircleParent.removeAttribute("font-size");
gCircle.removeChild(gCircle.firstChild);
}
function testRelativeFontWeight()
{
setupTest();
gCircleParent.setAttribute("font-weight", "100"); // At first: font-weight 100
var anim = createAnimSetTo("font-weight", "bolder");
// CSS 2: 'bolder': Specifies the next weight that is assigned to a font
// that is darker than the inherited one. If there is no such weight, it
// simply results in the next darker numerical value (and the font remains
// unchanged), unless the inherited value was '900', in which case the
// resulting weight is also '900'.
gSvg.setCurrentTime(0);
var weight =
parseInt(SMILUtil.getComputedStyleSimple(gCircle, "font-weight"));
ok(weight > 100, "Checking animated font-weight > 100 after animating");
gCircleParent.setAttribute("font-weight", "800"); // Change: font-weight 800
gSvg.setCurrentTime(0);
weight = parseInt(SMILUtil.getComputedStyleSimple(gCircle, "font-weight"));
is(weight, 900,
"Checking animated font-weight = 900 after updating context");
gCircleParent.removeAttribute("font-weight");
gCircle.removeChild(gCircle.firstChild);
}
function testRelativeFont()
{
// Test a relative font-size as part of a 'font' spec since the code path
// is different in this case
// It turns out that, due to the way we store shorthand font properties, we
// don't need to worry about marking such values as context-sensitive since we
// seem to store them in their relative form. If, however, we change the way
// we store shorthand font properties in the future, this will serve as
// a useful regression test.
setupTest();
gCircleParent.setAttribute("font-size", "10px"); // At first: font-size: 10px
// We must be sure to set every part of the shorthand property to some
// non-context sensitive value because we want to test that even if only the
// font-size is relative we will update it appropriately.
var anim =
createAnimSetTo("font", "normal normal bold larger/normal sans-serif");
gSvg.setCurrentTime(0);
var fsize = parseInt(SMILUtil.getComputedStyleSimple(gCircle, "font-size"));
ok(fsize > 10 && fsize < 20,
"Checking size of shorthand 'font' > 10px after animating");
gCircleParent.setAttribute("font-size", "20px"); // Change: font-size: 20px
gSvg.setCurrentTime(0);
fsize = parseInt(SMILUtil.getComputedStyleSimple(gCircle, "font-size"));
ok(fsize > 20,
"Checking size of shorthand 'font' > 20px after updating context");
gCircleParent.removeAttribute("font-size");
gCircle.removeChild(gCircle.firstChild);
}
function testCalcFontSize()
{
setupTest();
gCircleParent.setAttribute("font-size", "10px"); // At first: font-size: 10px
var anim = createAnimSetTo("font-size", "-moz-calc(110% + 0.1em)");
gSvg.setCurrentTime(0);
var fsize = parseInt(SMILUtil.getComputedStyleSimple(gCircle, "font-size"));
// Font size should be 1.1 * 10px + 0.1 * 10px = 12
is(fsize, 12, "Checking animated calc font-size == 12px after animating");
gCircleParent.setAttribute("font-size", "20px"); // Change: font-size: 20px
gSvg.setCurrentTime(0);
fsize = parseInt(SMILUtil.getComputedStyleSimple(gCircle, "font-size"));
is(fsize, 24, "Checking animated calc font-size == 24px after updating " +
"context");
gCircleParent.removeAttribute("font-size");
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>
</pre>
</body>
</html>