Computed style of fill/stroke properties incorrect on references
[WebKit-https.git] / LayoutTests / transitions / cancel-transition.html
1 <!DOCTYPE html>
2
3 <html>
4 <head>
5     <style>
6         #container {
7             height: 300px;
8             width: 700px;
9             background: #fcc;
10             font-family: ArialRoundedMTBold, sans-serif;
11             font-size: 200%;
12         }
13   
14         #container div {
15             position: absolute;
16             background-color: #933;
17             width: 200px;
18             height: 100px;
19             left: 50px;
20         }
21         #a {
22             top: 100px;
23         }
24         #container.run #a {
25             left: 450px;
26             -webkit-transition-property: left;
27             -webkit-transition-duration: 0.5s;
28             -webkit-transition-timing-function: linear;
29         }
30         #b {
31             top: 250px;
32         }
33         #container.run #b {
34             -webkit-transform: translate(400px, 0px);
35             -webkit-transition-property: -webkit-transform;
36             -webkit-transition-duration: 0.5s;
37             -webkit-transition-timing-function: linear;
38         }
39     </style>
40     <script>
41         if (window.testRunner) {
42             testRunner.dumpAsText();
43             testRunner.waitUntilDone();
44         }
45
46         result = "<span style='color:red'>CHECK NOT COMPLETED</span>";
47
48         function isEqual(actual, desired, tolerance)
49         {
50             var diff = Math.abs(actual - desired);
51             return diff < tolerance;
52         }
53
54         function cancelTransition()
55         {
56             document.getElementById("container").className = "";
57         }
58
59         function restartTransition()
60         {
61             document.getElementById("container").className = "run";
62             // The transition should restart at the beginning here. After 250 it should be halfway done.
63             setTimeout("check()", 250);
64         }
65
66         function check()
67         {
68             var left = parseFloat(window.getComputedStyle(document.getElementById('a')).left);
69             result = "left:";
70             if (!isEqual(left, 250, 50))
71                 result += "<span style='color:red'>FAIL(was:" + left + ", s/b:150)</span>";
72             else
73                 result += "<span style='color:green'>PASS</span>";
74             
75             result += ", webkitTransform:";
76             
77             var transform = window.getComputedStyle(document.getElementById('b')).webkitTransform;
78             transform = transform.split("(");
79             transform = transform[1].split(",");
80             if (!isEqual(transform[4], 200, 50))
81                 result += "<span style='color:red'>FAIL(was:" + transform[4] + ", s/b:50)</span>";
82             else
83                 result += "<span style='color:green'>PASS</span>";
84             
85             document.getElementById('result').innerHTML = result;
86             if (window.testRunner)
87                 testRunner.notifyDone();
88         }
89
90         function start()
91         {
92             document.getElementById("container").className = "run";
93             setTimeout("cancelTransition()", 100);
94             setTimeout("restartTransition()", 200);
95         }
96     </script>
97 </head>
98 <body onload="start()">
99 <p>
100     Test removes the transition properties while the transition is running, then adds them back in.
101     If working properly the transitions should start from the beginning. But there was a bug that
102     would cause the transition to continue to run (although with no visible effect). So when you
103     restarted, it would pick up where it left off.
104 </p>
105 <div id="container">
106     <div id="a" class="tester">left</div>
107     <div id="b" class="tester">translate</div>
108 </div>
109 <div id="result">
110 </div>
111 </body>
112 </html>