| OLD | NEW |
| 1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
| 2 <html> | 2 <html> |
| 3 <head> | 3 <head> |
| 4 <title>Tests that unprefixed animation events are correctly fired.</title> | 4 <title>Tests that prefixed animation events are correctly fired when using htm
l event listeners.</title> |
| 5 <style> | 5 <style> |
| 6 #box { | 6 #box { |
| 7 position: relative; | 7 position: relative; |
| 8 left: 100px; | 8 left: 100px; |
| 9 top: 10px; | 9 top: 10px; |
| 10 height: 100px; | 10 height: 100px; |
| 11 width: 100px; | 11 width: 100px; |
| 12 animation-duration: 0.3s; | 12 animation-duration: 0.3s; |
| 13 animation-name: anim; | 13 animation-name: anim; |
| 14 background-color: #999; | 14 background-color: #999; |
| 15 animation-iteration-count: 3; | 15 animation-iteration-count: 3; |
| 16 } | 16 } |
| 17 @keyframes anim { | 17 @keyframes anim { |
| 18 from { left: 200px; } | 18 from { left: 200px; } |
| 19 to { left: 300px; } | 19 to { left: 300px; } |
| 20 } | 20 } |
| 21 </style> | 21 </style> |
| 22 <script> | 22 <script> |
| 23 if (window.testRunner) { | 23 if (window.testRunner) { |
| 24 testRunner.dumpAsText(); | 24 testRunner.dumpAsText(); |
| 25 testRunner.waitUntilDone(); | 25 testRunner.waitUntilDone(); |
| 26 } | 26 } |
| 27 | 27 |
| 28 function fail() { | 28 function fail() { |
| 29 document.getElementById('result').innerHTML = 'FAIL: Got ' + iterationEven
tReceived + ' animationCount events.'; | 29 document.getElementById('result').innerHTML = 'FAIL: Got ' + iterationEven
tReceived + ' animationCount events.'; |
| 30 } | 30 } |
| 31 | 31 |
| 32 var iterationEventReceived = 0; | 32 var iterationEventReceived = 0; |
| 33 var startEventReceived = false; | 33 var startEventReceived = false; |
| 34 document.addEventListener('animationstart', function() { | 34 |
| 35 function recordAnimationStart() { |
| 35 startEventReceived = true; | 36 startEventReceived = true; |
| 36 }, false); | 37 } |
| 37 document.addEventListener('animationiteration', function() { | 38 |
| 39 function recordAnimationIteration() { |
| 38 ++iterationEventReceived; | 40 ++iterationEventReceived; |
| 39 }, false); | 41 } |
| 40 | 42 |
| 41 document.addEventListener('animationend', function() { | 43 function recordAnimationEnd() { |
| 42 if (iterationEventReceived <= 2 && startEventReceived) | 44 if (iterationEventReceived > 0 && iterationEventReceived <= 2 && startEv
entReceived) |
| 43 document.getElementById('result').innerHTML = 'PASS: All events have
been received as expected.'; | 45 document.getElementById('result').innerHTML = 'PASS: All events have
been received as expected.'; |
| 44 else | 46 else |
| 45 fail(); | 47 fail(); |
| 46 if (window.testRunner) | 48 if (window.testRunner) |
| 47 testRunner.notifyDone(); | 49 testRunner.notifyDone(); |
| 48 }, false); | |
| 49 | |
| 50 onload = function() | |
| 51 { | |
| 52 // Animation begins once we append the DOM node to the document. | |
| 53 var boxNode = document.createElement('div'); | |
| 54 boxNode.id = 'box'; | |
| 55 document.body.appendChild(boxNode); | |
| 56 } | 50 } |
| 57 </script> | 51 </script> |
| 58 </head> | 52 </head> |
| 59 <body> | 53 <body> |
| 60 Tests that unprefixed animation events are correctly fired. | 54 Tests that prefixed animation events are correctly fired when using html event l
isteners. |
| 61 <pre id="result">FAIL: No animation events received</pre> | 55 <pre id="result">FAIL: No animation events received</pre> |
| 56 <div id="box" onwebkitanimationstart="recordAnimationStart();" onwebkitanimation
end="recordAnimationEnd();" onwebkitanimationiteration="recordAnimationIteration
();"></div> |
| 62 </body> | 57 </body> |
| 63 </html> | 58 </html> |
| OLD | NEW |