OLD | NEW |
| (Empty) |
1 <!doctype html> | |
2 <script src="../resources/testharness.js"></script> | |
3 <script src="../resources/testharnessreport.js"></script> | |
4 <style> | |
5 .start { | |
6 animation: anim 1ms; | |
7 } | |
8 | |
9 @keyframes anim { | |
10 0% { | |
11 transform: translate3d(0, 0, 1px); | |
12 } | |
13 100% { | |
14 transform: translate3d(0, 0, 0); | |
15 } | |
16 } | |
17 </style> | |
18 <body>x | |
19 <script> | |
20 'use strict'; | |
21 async_test(function(t) { | |
22 | |
23 requestAnimationFrame(function() { | |
24 document.body.classList.add('start'); | |
25 | |
26 // Force a style resolve, to ensure the animation is created. | |
27 document.body.offsetTop; | |
28 | |
29 var animation = document.body.getAnimations()[0]; | |
30 setTimeout(function() { | |
31 if (animation.playState === 'pending') { | |
32 var passed = false; | |
33 document.body.addEventListener('animationstart', function() { | |
34 passed = true; | |
35 }); | |
36 document.body.addEventListener('animationend', function() { | |
37 t.step(function() { | |
38 assert_true(passed); | |
39 t.done(); | |
40 }); | |
41 }); | |
42 } else { | |
43 // The animation is no longer pending. | |
44 | |
45 // We missed the opportunity to add a start event listener | |
46 // before the animation started. This test might flakily | |
47 // pass even if the implementation is incorrect. | |
48 t.done(); | |
49 } | |
50 }, 0); | |
51 }); | |
52 }); | |
53 </script> | |
OLD | NEW |