2008-11-04 Anders Carlsson <andersca@apple.com>
[webkit/qt.git] / LayoutTests / animations / keyframes-comma-separated.html
blobb20bf6d325011953561d035ac1b30de082542fad
1 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
2 "http://www.w3.org/TR/html4/loose.dtd">
4 <html lang="en">
5 <head>
6 <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
7 <title>Keyframes test with comma separated keys</title>
8 <style type="text/css" media="screen">
9 #box {
10 position: absolute;
11 left: 0;
12 top: 100px;
13 height: 100px;
14 width: 100px;
15 background-color: blue;
16 -webkit-animation-duration: 1s;
17 -webkit-animation-timing-function: linear;
18 -webkit-animation-name: "anim";
20 @-webkit-keyframes "anim" {
21 from { left: 50px; }
22 20%, 40% { left: 100px; }
23 60%,80%{ left: 200px; }
24 to { left: 300px; }
26 </style>
27 <script type="text/javascript" charset="utf-8">
28 if (window.layoutTestController) {
29 layoutTestController.dumpAsText();
30 layoutTestController.waitUntilDone();
33 result = "PASS";
34 const defaultTolerance = 0.2;
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(which)
46 if (result != "PASS")
47 return;
49 var left = parseInt(window.getComputedStyle(document.getElementById('box')).left);
50 var expected = which ? 200 : 100;
51 if (!isEqual(left, expected))
52 result = "FAIL(was:"+left+", expected:"+expected+")";
55 function start()
57 setTimeout("snapshot(0)", 300);
58 setTimeout("snapshot(1)", 700);
60 window.setTimeout(function() {
61 document.getElementById('result').innerHTML = result;
62 if (window.layoutTestController)
63 layoutTestController.notifyDone();
64 }, 800);
67 document.addEventListener('webkitAnimationStart', start, false);
69 </script>
70 </head>
71 <body>
72 This test performs an animation of the left property. It should stop for 100ms at 100px and 200px
73 We test for those values 50ms after it has stopped at each position. Keys in two of the keyframes
74 are comma separated, so these should be correctly broken out into separate keyframes.
75 <div id="box">
76 </div>
77 <div id="result">
78 </div>
79 </body>
80 </html>