blob: 0eb10cefb5297c220b81be0a4ba8ca5e29fcc23d [file] [log] [blame]
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Test simple fill mode on transform</title>
<style type="text/css" media="screen">
.box {
position: relative;
left: 10px;
top: 10px;
height: 100px;
width: 100px;
transform: translate3d(100px, 0, 0);
animation-delay: 0.1s;
animation-duration: 0.1s;
animation-timing-function: linear;
animation-name: anim;
}
@keyframes anim {
from { transform: translate3d(200px, 0, 0); }
to { transform: translate3d(300px, 0, 0); }
}
#a {
background-color: blue;
animation-fill-mode: none;
}
#b {
background-color: red;
animation-fill-mode: backwards;
}
#c {
background-color: green;
animation-fill-mode: forwards;
}
#d {
background-color: yellow;
animation-fill-mode: both;
}
#e {
background-color: #999;
animation-fill-mode: both;
animation-iteration-count: 2;
animation-direction: alternate;
}
</style>
<script type="text/javascript" charset="utf-8">
const numAnims = 5;
var animsFinished = 0;
const allowance = 5;
const expectedValues = [
{id: "a", start: 100, end: 100},
{id: "b", start: 200, end: 100},
{id: "c", start: 100, end: 300},
{id: "d", start: 200, end: 300},
{id: "e", start: 200, end: 200}
];
var result = "";
if (window.testRunner) {
testRunner.dumpAsText();
testRunner.waitUntilDone();
}
function animationEnded(event) {
if (++animsFinished == numAnims) {
setTimeout(endTest, 0); // this set timeout should be ok in the test environment
// since we're just giving style a chance to resolve
}
};
function endTest() {
for (var i=0; i < expectedValues.length; i++) {
var el = document.getElementById(expectedValues[i].id);
var expectedValue = expectedValues[i].end;
var computedValue = window.getComputedStyle(el).transform;
var realValue = parseFloat(computedValue.split("(")[1].split(",")[4]);
if (Math.abs(expectedValue - realValue) < 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 el = document.getElementById(expectedValues[i].id);
var expectedValue = expectedValues[i].start;
var computedValue = window.getComputedStyle(el).transform;
var realValue = parseFloat(computedValue.split("(")[1].split(",")[4]);
if (Math.abs(expectedValue - realValue) < allowance) {
result += "PASS";
} else {
result += "FAIL";
}
result += " - start of animation - id: " + expectedValues[i].id + " expected: " + expectedValue + " actual: " + realValue + "<br>";
}
document.addEventListener("animationend", animationEnded, false);
};
</script>
</head>
<body>
This test performs an animation of the transform property with four different
fill modes. It animates over 0.1 second with a 0.1 second delay.
It takes snapshots at document load and the end of the animations.
<div id="a" class="box">
None
</div>
<div id="b" class="box">
Backwards
</div>
<div id="c" class="box">
Forwards
</div>
<div id="d" class="box">
Both
</div>
<div id="e" class="box">
Both Iterate
</div>
<div id="result">
</div>
</body>
</html>