OLD | NEW |
---|---|
1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
2 | |
3 <html> | 2 <html> |
4 <head> | 3 <head> |
4 <meta charset="utf-8"> | |
5 <script src="../resources/testharness.js"></script> | |
6 <script src="../resources/testharnessreport.js"></script> | |
5 <style> | 7 <style> |
6 #container { | 8 #container { |
7 width: 700px; | 9 width: 700px; |
8 background-color: #fcc; | 10 background-color: #fcc; |
9 } | 11 } |
10 | 12 |
11 #container div { | 13 #container div { |
12 position: relative; | 14 position: relative; |
13 background-color: #933; | 15 background-color: #933; |
14 width: 200px; | 16 width: 200px; |
15 height: 50px; | 17 height: 50px; |
16 left: 50px; | 18 left: 50px; |
17 margin-top: 10px; | 19 margin-top: 10px; |
18 } | 20 } |
19 #container.run #left { | 21 #container.run #left { |
20 left: 450px; | 22 left: 450px; |
21 transition-property: left; | 23 transition-property: left; |
22 transition-duration: 1s; | 24 transition-duration: 4s; |
23 transition-timing-function: linear; | 25 transition-timing-function: linear; |
24 } | 26 } |
25 #container.run #translate { | 27 #container.run #translate { |
26 transform: translate(400px, 0px); | 28 transform: translate(400px, 0px); |
27 transition-property: transform; | 29 transition-property: transform; |
28 transition-duration: 1s; | 30 transition-duration: 4s; |
31 transition-delay: -1s; | |
29 transition-timing-function: linear; | 32 transition-timing-function: linear; |
30 } | 33 } |
31 </style> | 34 </style> |
35 </head> | |
36 <body> | |
37 <p> | |
38 Test removes the transition properties while the transition is running, then adds them back in. | |
39 If working properly the transitions should start from the beginning. But there was a bug that | |
suzyh_UTC10 (ex-contributor)
2017/01/06 00:14:07
Reference bug number, if you can find it.
Not sur
Eric Willigers
2017/01/06 01:39:01
Done.
| |
40 would cause the transition to continue to run (although with no visible effect). So when you | |
41 restarted, it would pick up where it left off. | |
42 </p> | |
43 <div id="container"> | |
44 <div id="left">left</div> | |
45 <div id="translate">translate</div> | |
46 </div> | |
32 <script> | 47 <script> |
33 if (window.testRunner) { | 48 'use strict'; |
34 testRunner.dumpAsText(); | 49 function wait() { |
suzyh_UTC10 (ex-contributor)
2017/01/06 00:14:07
Please give this a more descriptive name than 'wai
Eric Willigers
2017/01/06 01:39:01
Done.
| |
35 testRunner.waitUntilDone(); | 50 return container.animate({visibility: ['visible', 'visible']}, 40).rea dy; |
36 } | 51 } |
37 | 52 |
38 function isEqual(actual, desired, tolerance) | 53 async_test(t => { |
39 { | 54 getComputedStyle(container).height; // force style recalc |
40 var diff = Math.abs(actual - desired); | 55 container.className = 'run'; |
41 return diff < tolerance; | 56 getComputedStyle(container).height; // force transition start |
suzyh_UTC10 (ex-contributor)
2017/01/06 00:14:07
Nit: Reword as "force style recalc - transition wi
Eric Willigers
2017/01/06 01:39:01
Done.
| |
42 } | 57 wait().then(() => { |
43 | 58 container.className = ''; |
suzyh_UTC10 (ex-contributor)
2017/01/06 00:14:07
Perhaps before cancelling the transition here, we
Eric Willigers
2017/01/06 01:39:01
Done.
| |
44 function cancelTransition() | 59 getComputedStyle(container).height; // force transition cancel |
45 { | 60 }).then(wait).then(t.step_func_done(() => { |
46 document.getElementById("container").className = ""; | 61 container.className = 'run'; // restart transition |
47 document.body.offsetHeight; | 62 assert_equals(getComputedStyle(left).left, '50px'); |
48 } | 63 assert_equals(getComputedStyle(translate).transform, 'matrix(1, 0, 0, 1, 100, 0)'); |
49 | 64 })); |
50 function restartTransition() | 65 }, 'Transition restarts from the beginning'); |
51 { | |
52 document.getElementById("container").className = "run"; | |
53 document.body.offsetHeight; | |
54 // The transition should restart at the beginning here. After 250 it should be halfway done. | |
55 setTimeout(check, 500); | |
56 } | |
57 | |
58 function check() | |
59 { | |
60 var left = parseFloat(window.getComputedStyle(document.getElementByI d('left')).left); | |
61 result = "left: "; | |
62 if (!isEqual(left, 250, 50)) | |
63 result += "<span style='color:red'>FAIL (was: " + left + ", expe cted: 250)</span>"; | |
64 else | |
65 result += "<span style='color:green'>PASS</span>"; | |
66 | |
67 result += ", transform: "; | |
68 | |
69 var transform = window.getComputedStyle(document.getElementById('tra nslate')).transform; | |
70 transform = transform.split("("); | |
71 transform = transform[1].split(","); | |
72 if (!isEqual(transform[4], 200, 50)) | |
73 result += "<span style='color:red'>FAIL (was: " + transform[4] + ", expected: 200)</span>"; | |
74 else | |
75 result += "<span style='color:green'>PASS</span>"; | |
76 | |
77 document.getElementById('result').innerHTML = result; | |
78 if (window.testRunner) | |
79 testRunner.notifyDone(); | |
80 } | |
81 | |
82 function start() | |
83 { | |
84 document.getElementById("container").className = "run"; | |
85 document.body.offsetHeight; | |
86 setTimeout("cancelTransition()", 200); | |
87 setTimeout("restartTransition()", 400); | |
88 } | |
89 </script> | 66 </script> |
90 </head> | |
91 <body onload="start()"> | |
92 <p> | |
93 Test removes the transition properties while the transition is running, then adds them back in. | |
94 If working properly the transitions should start from the beginning. But the re was a bug that | |
95 would cause the transition to continue to run (although with no visible effe ct). So when you | |
96 restarted, it would pick up where it left off. | |
97 </p> | |
98 <div id="container"> | |
99 <div id="left">left</div> | |
100 <div id="translate">translate</div> | |
101 </div> | |
102 <div id="result"></div> | |
103 </body> | 67 </body> |
104 </html> | 68 </html> |
OLD | NEW |