blob: 78ec69169d08147cc3adf52d017f78901afa5fd7 [file] [log] [blame]
<!doctype html>
<html lang="en">
<head>
<title>Test animation direction reverse with fill modes</title>
<style>
.box {
position: relative;
left: 100px;
height: 100px;
width: 100px;
-webkit-animation-delay: 0.1s;
-webkit-animation-duration: 0.1s;
-webkit-animation-timing-function: linear;
-webkit-animation-name: anim;
-webkit-animation-direction: reverse;
}
@-webkit-keyframes anim {
from { left: 200px; }
to { left: 300px; }
}
#none {
background-color: blue;
-webkit-animation-fill-mode: none;
}
#backwards {
background-color: red;
-webkit-animation-fill-mode: backwards;
}
#forwards {
background-color: green;
-webkit-animation-fill-mode: forwards;
}
#both {
background-color: yellow;
-webkit-animation-fill-mode: both;
}
#both_iterating {
background-color: cyan;
-webkit-animation-fill-mode: both;
-webkit-animation-iteration-count: 2;
-webkit-animation-direction: alternate;
}
#both_iterating_reverse {
background-color: #999;
-webkit-animation-fill-mode: both;
-webkit-animation-iteration-count: 2;
-webkit-animation-direction: alternate-reverse;
}
</style>
<script src="resources/animation-test-helpers.js"></script>
<script type="text/javascript" charset="utf-8">
const numAnims = 6;
var animsFinished = 0;
const allowance = 5;
const expectedValues = [
{id: "none", start: "100px", end: "100px"},
{id: "backwards", start: "300px", end: "100px"},
{id: "forwards", start: "100px", end: "200px"},
{id: "both", start: "300px", end: "200px"},
{id: "both_iterating", start: "200px", end: "200px"},
{id: "both_iterating_reverse", start: "300px", end: "300px"}
];
var result = "";
if (window.testRunner) {
testRunner.dumpAsText();
testRunner.waitUntilDone();
}
function animationEnded(event) {
if (++animsFinished == numAnims) {
// This call to setTimeout should be ok in the test environment
// since we're just giving style a chance to resolve.
setTimeout(endTest, 0);
}
};
function endTest() {
for (var i = 0; i < expectedValues.length; i++) {
var realValue = getPropertyValue("left", expectedValues[i].id);
var expectedValue = expectedValues[i].end;
if (comparePropertyValue(realValue, expectedValue, allowance))
result += "PASS";
else
result += "FAIL";
result += " - end of animation - id: " + expectedValues[i].id + " expected: " + expectedValue + " actual: " + realValue + "<br>";
}
document.getElementById('result').innerHTML = result;
if (window.testRunner)
testRunner.notifyDone();
}
window.onload = function () {
for (var i = 0; i < expectedValues.length; i++) {
var realValue = getPropertyValue("left", expectedValues[i].id);
var expectedValue = expectedValues[i].start;
if (comparePropertyValue(realValue, expectedValue, allowance))
result += "PASS";
else
result += "FAIL";
result += " - start of animation - id: " + expectedValues[i].id + " expected: " + expectedValue + " actual: " + realValue + "<br>";
}
document.addEventListener("webkitAnimationEnd", animationEnded, false);
};
</script>
</head>
<body>
<div>
This test performs an animation of the left property with direction reverse
and four different fill modes. It animates over 0.1 seconds with a 0.1
second delay. It takes snapshots at document load and the end of the
animation.
</div>
<div id="none" class="box">
None
</div>
<div id="backwards" class="box">
Backwards
</div>
<div id="forwards" class="box">
Forwards
</div>
<div id="both" class="box">
Both
</div>
<div id="both_iterating" class="box">
Both iterating
</div>
<div id="both_iterating_reverse" class="box">
Both iterating reverse
</div>
<div id="result">
</div>
</body>
</html>