1 <!DOCTYPE html PUBLIC
"-//W3C//DTD HTML 4.01 Transitional//EN"
2 "http://www.w3.org/TR/html4/loose.dtd">
6 <meta http-equiv=
"Content-Type" content=
"text/html; charset=utf-8">
7 <title>Test Changing Name of A Keyframes Rule Using CSSOM
</title>
8 <style type=
"text/css" media=
"screen">
15 background-color: blue;
16 -webkit-animation-duration:
0.5s;
17 -webkit-animation-timing-function: linear;
18 -webkit-animation-name:
"bar";
20 @-webkit-keyframes
"foo" {
27 <script type=
"text/javascript" charset=
"utf-8">
28 if (window.layoutTestController) {
29 layoutTestController.dumpAsText();
30 layoutTestController.waitUntilDone();
34 const defaultTolerance =
10;
36 function isEqual(actual, desired, tolerance)
38 if (tolerance == undefined || tolerance ==
0)
39 tolerance = defaultTolerance;
40 var diff = Math.abs(actual - desired);
41 return diff < tolerance;
44 function snapshot(expected)
49 var prop = parseInt(window.getComputedStyle(document.getElementById('box')).left);
50 if (!isEqual(prop, expected))
51 result =
"FAIL('left' property was:"+prop+
", expected:"+expected+
")";
54 function findKeyframesRule(rule)
56 var ss = document.styleSheets;
57 for (var i =
0; i < ss.length; ++i) {
58 for (var j =
0; j < ss[i].cssRules.length; ++j) {
59 if (ss[i].cssRules[j].type == window.CSSRule.WEBKIT_KEYFRAMES_RULE && ss[i].cssRules[j].name == rule)
60 return ss[i].cssRules[j];
69 // change keyframes name
70 var keyframes = findKeyframesRule(
"foo");
71 keyframes.name =
"anim";
72 document.getElementById('box').style.webkitAnimationName =
"anim";
77 document.removeEventListener('webkitAnimationStart', start, false);
78 setTimeout(
"snapshot(200)",
250);
79 window.setTimeout(function() {
80 document.getElementById('result').innerHTML = result;
81 if (window.layoutTestController)
82 layoutTestController.notifyDone();
86 document.addEventListener('webkitAnimationStart', start, false);
87 setTimeout(
"snapshot(0)",
100);
88 setTimeout(
"change()",
200);
93 This test starts by making sure the animation is not running, because the animation-name and the
94 name of they @keyframes rule do not match. Then it changes the name of the @keyframes rule so they
95 match and makes sure the animation is now running.