| OLD | NEW |
| (Empty) | |
| 1 <!DOCTYPE html> |
| 2 <meta charset=utf-8> |
| 3 <title>document.getAnimations tests</title> |
| 4 <link rel="help" href="https://w3c.github.io/web-animations/#dom-document-getani
mations"> |
| 5 <script src="../../../../../resources/testharness.js"></script> |
| 6 <script src="../../../../../resources/testharnessreport.js"></script> |
| 7 <script src="../../testcommon.js"></script> |
| 8 <body> |
| 9 <div id="log"></div> |
| 10 <div id="target"></div> |
| 11 <script> |
| 12 "use strict"; |
| 13 |
| 14 var gKeyFrames = { 'marginLeft': ['100px', '200px'] }; |
| 15 |
| 16 test(function(t) { |
| 17 assert_equals(document.getAnimations().length, 0, |
| 18 'getAnimations returns an empty sequence for a document ' + |
| 19 'with no animations'); |
| 20 }, 'Test document.getAnimations for non-animated content'); |
| 21 |
| 22 test(function(t) { |
| 23 var div = createDiv(t); |
| 24 var anim1 = div.animate(gKeyFrames, 100 * MS_PER_SEC); |
| 25 var anim2 = div.animate(gKeyFrames, 100 * MS_PER_SEC); |
| 26 assert_equals(document.getAnimations().length, 2, |
| 27 'getAnimation returns running animations'); |
| 28 |
| 29 anim1.finish(); |
| 30 anim2.finish(); |
| 31 assert_equals(document.getAnimations().length, 0, |
| 32 'getAnimation only returns running animations'); |
| 33 }, 'Test document.getAnimations for script-generated animations') |
| 34 |
| 35 test(function(t) { |
| 36 var div = createDiv(t); |
| 37 var anim1 = div.animate(gKeyFrames, 100 * MS_PER_SEC); |
| 38 var anim2 = div.animate(gKeyFrames, 100 * MS_PER_SEC); |
| 39 assert_array_equals(document.getAnimations(), |
| 40 [ anim1, anim2 ], |
| 41 'getAnimations() returns running animations'); |
| 42 }, 'Test the order of document.getAnimations with script generated animations') |
| 43 |
| 44 test(function(t) { |
| 45 var effect = new KeyframeEffectReadOnly(null, gKeyFrames, 100 * MS_PER_SEC); |
| 46 var anim = new Animation(effect, document.timeline); |
| 47 anim.play(); |
| 48 |
| 49 assert_equals(document.getAnimations().length, 0, |
| 50 'document.getAnimations() only returns animations targeting ' + |
| 51 'elements in this document'); |
| 52 }, 'Test document.getAnimations with null target'); |
| 53 |
| 54 </script> |
| 55 </body> |
| OLD | NEW |