OLD | NEW |
1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
2 <html> | 2 <html> |
3 <head> | 3 <head> |
4 <style type="text/css"> | 4 <style type="text/css"> |
5 #target { | 5 #target { |
6 position: relative; | 6 position: relative; |
7 height: 50px; | 7 height: 50px; |
8 width: 50px; | 8 width: 50px; |
9 background-color: blue; | 9 background-color: blue; |
10 } | 10 } |
(...skipping 25 matching lines...) Expand all Loading... |
36 var target; | 36 var target; |
37 function go() { | 37 function go() { |
38 target = document.getElementById('target'); | 38 target = document.getElementById('target'); |
39 target.addEventListener('webkitAnimationStart', onStart); | 39 target.addEventListener('webkitAnimationStart', onStart); |
40 target.classList.add('animated'); | 40 target.classList.add('animated'); |
41 } | 41 } |
42 | 42 |
43 function onStart(e) { | 43 function onStart(e) { |
44 log('INFO: Start event fired'); | 44 log('INFO: Start event fired'); |
45 target.removeEventListener('webkitAnimationStart', onStart); | 45 target.removeEventListener('webkitAnimationStart', onStart); |
46 setTimeout(setDisplayNone, 100); | 46 requestAnimationFrame(function() { |
| 47 setTimeout(setDisplayNone, 100); |
| 48 }); |
47 } | 49 } |
48 | 50 |
49 var leftPropertyWhenSetDisplayNone; | 51 var leftPropertyWhenSetDisplayNone; |
50 function setDisplayNone() { | 52 function setDisplayNone() { |
51 leftPropertyWhenSetDisplayNone = getComputedStyle(target).left; | 53 leftPropertyWhenSetDisplayNone = getComputedStyle(target).left; |
52 target.style.display = 'none'; | 54 target.style.display = 'none'; |
53 setTimeout(setDisplayBlock, 100); | 55 requestAnimationFrame(function() { |
| 56 setTimeout(setDisplayBlock, 100); |
| 57 }); |
54 } | 58 } |
55 | 59 |
56 function setDisplayBlock() { | 60 function setDisplayBlock() { |
57 target.addEventListener('webkitAnimationStart', onRestart); | 61 target.addEventListener('webkitAnimationStart', onRestart); |
58 target.style.display = 'block'; | 62 target.style.display = 'block'; |
59 } | 63 } |
60 | 64 |
61 function onRestart(e) { | 65 function onRestart(e) { |
62 log('INFO: Start event fired again'); | 66 log('INFO: Start event fired again'); |
63 var pass = leftPropertyWhenSetDisplayNone > getComputedStyle(target).left; | 67 var pass = leftPropertyWhenSetDisplayNone > getComputedStyle(target).left; |
64 log((pass ? 'PASS' : 'FAIL') + ': Left property was ' + (pass ? '' : 'not
') + 'reset correctly'); | 68 log((pass ? 'PASS' : 'FAIL') + ': Left property was ' + (pass ? '' : 'not
') + 'reset correctly'); |
65 if (window.testRunner) { | 69 if (window.testRunner) { |
66 testRunner.notifyDone(); | 70 testRunner.notifyDone(); |
67 } | 71 } |
68 } | 72 } |
69 </script> | 73 </script> |
70 </head> | 74 </head> |
71 <body onload="go()"> | 75 <body onload="go()"> |
72 <p> | 76 <p> |
73 Tests that setting the display property of a running animation to 'none' | 77 Tests that setting the display property of a running animation to 'none' |
74 terminates the animation, and that setting it a value other than 'none' | 78 terminates the animation, and that setting it a value other than 'none' |
75 causes it to re-start from the start. | 79 causes it to re-start from the start. |
76 </p> | 80 </p> |
77 <div id="target"></div> | 81 <div id="target"></div> |
78 </body> | 82 </body> |
79 </html> | 83 </html> |
OLD | NEW |