KeyframeEffect-target.tentative.html (2478B)
1 <!doctype html> 2 <meta charset=utf-8> 3 <title>CSSAnimation.effect.target</title> 4 <!-- TODO: Add a more specific link for this once it is specified. --> 5 <link rel="help" href="https://drafts.csswg.org/css-animations-2/"> 6 <script src="/resources/testharness.js"></script> 7 <script src="/resources/testharnessreport.js"></script> 8 <script src="support/testcommon.js"></script> 9 <style> 10 @keyframes anim { } 11 ::before { 12 content: '' 13 } 14 ::after { 15 content: '' 16 } 17 </style> 18 <div id="log"></div> 19 <script> 20 'use strict'; 21 22 test(t => { 23 const div = addDiv(t); 24 div.style.animation = 'anim 100s'; 25 const animation = div.getAnimations()[0]; 26 assert_equals(animation.effect.target, div, 27 'Animation.target is the animatable div'); 28 }, 'Returned CSS animations have the correct effect target'); 29 30 test(t => { 31 addStyle(t, { '.after::after': 'animation: anim 10s, anim 100s;' }); 32 const div = addDiv(t, { class: 'after' }); 33 const anims = document.getAnimations(); 34 assert_equals(anims.length, 2, 35 'Got animations running on ::after pseudo element'); 36 assert_equals(anims[0].effect.target, anims[1].effect.target, 37 'Both animations return the same target object'); 38 }, 'effect.target should return the same CSSPseudoElement object each time'); 39 40 test(t => { 41 addStyle(t, { '.after::after': 'animation: anim 10s;' }); 42 const div = addDiv(t, { class: 'after' }); 43 const pseudoTarget = document.getAnimations()[0].effect.target; 44 const effect = new KeyframeEffect(pseudoTarget, 45 { background: ["blue", "red"] }, 46 3 * MS_PER_SEC); 47 const newAnim = new Animation(effect, document.timeline); 48 newAnim.play(); 49 const anims = document.getAnimations(); 50 assert_equals(anims.length, 2, 51 'Got animations running on ::after pseudo element'); 52 assert_not_equals(anims[0], newAnim, 53 'The scriped-generated animation appears last'); 54 assert_equals(newAnim.effect.target, pseudoTarget, 55 'The effect.target of the scripted-generated animation is ' + 56 'the same as the one from the argument of ' + 57 'KeyframeEffect constructor'); 58 assert_equals(anims[0].effect.target, newAnim.effect.target, 59 'Both animations return the same target object'); 60 }, 'effect.target from the script-generated animation should return the same ' + 61 'CSSPseudoElement object as that from the CSS generated animation'); 62 63 </script>