blob: 569f51a13236120800c243b8d895c632ad5cfd0f [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 Changing Name of A Keyframes Rule Using CSSOM</title>
<style type="text/css" media="screen">
#box {
position: relative;
left: 0;
top: 0;
height: 100px;
width: 100px;
background-color: blue;
-webkit-animation-duration: 0.5s;
-webkit-animation-timing-function: linear;
-webkit-animation-name: "bar";
}
@-webkit-keyframes "foo" {
from { left: 100px; }
40% { left: 200px; }
60% { left: 200px; }
to { left: 300px; }
}
</style>
<script src="resources/animation-test-helpers.js" type="text/javascript" charset="utf-8"></script>
<script type="text/javascript" charset="utf-8">
const expectedValues = [
// [animation-name, time, element-id, property, expected-value, tolerance]
[null, 0.25, "box", "left", 200, 20],
];
function findKeyframesRule(rule)
{
var ss = document.styleSheets;
for (var i = 0; i < ss.length; ++i) {
for (var j = 0; j < ss[i].cssRules.length; ++j) {
if (ss[i].cssRules[j].type == window.CSSRule.WEBKIT_KEYFRAMES_RULE && ss[i].cssRules[j].name == rule)
return ss[i].cssRules[j];
}
}
return null;
}
function change()
{
// change keyframes name
var keyframes = findKeyframesRule("foo");
keyframes.name = "anim";
document.getElementById('box').style.webkitAnimationName = "anim";
runAnimationTest(expectedValues);
}
function setup()
{
if (window.testRunner) {
testRunner.dumpAsText();
var box = document.getElementById('box');
if (internals.pauseAnimationAtTimeOnElement("bar", 0.5, box))
document.getElementById("pre-result").innerHTML = "FAIL: animation is running";
else
document.getElementById("pre-result").innerHTML = "PASS: animation is not running";
}
setTimeout(change, 200);
}
</script>
</head>
<body onload="setup()">
This test starts by making sure the animation is not running, because the animation-name and the
name of they @keyframes rule do not match. Then it changes the name of the @keyframes rule so they
match and makes sure the animation is now running.
<div id="box">
</div>
<div id="pre-result">
</div>
<div id="result">
</div>
</body>
</html>