zero-intrinsic-iteration-duration.tentative.html (3416B)
1 <!DOCTYPE html> 2 <html> 3 <head> 4 <meta charset="utf-8"> 5 <link rel="help" src="https://drafts.csswg.org/scroll-animations-1/#named-timeline-range"> 6 <script src="/resources/testharness.js"></script> 7 <script src="/resources/testharnessreport.js"></script> 8 <script src="/web-animations/testcommon.js"></script> 9 <script src="support/testcommon.js"></script> 10 <script src="/web-animations/resources/keyframe-utils.js"></script> 11 <script src="/scroll-animations/scroll-timelines/testcommon.js"></script> 12 <title>Animation range updates play state</title> 13 </head> 14 <style type="text/css"> 15 @keyframes anim { 16 from { background-color: blue; } 17 to { background-color: white; } 18 } 19 #scroller { 20 border: 10px solid lightgray; 21 overflow-y: scroll; 22 overflow-x: hidden; 23 width: 300px; 24 height: 200px; 25 } 26 #target { 27 margin-top: 800px; 28 margin-bottom: 800px; 29 margin-left: 10px; 30 margin-right: 10px; 31 width: 100px; 32 height: 100px; 33 z-index: -1; 34 background-color: green; 35 animation: anim auto linear; 36 animation-timeline: --t1; 37 view-timeline: --t1; 38 } 39 </style> 40 <body> 41 <div id="scroller"> 42 <div id="target"></div> 43 </div> 44 </body> 45 <script type="text/javascript"> 46 async function runTest() { 47 promise_test(async t => { 48 const anim = target.getAnimations()[0]; 49 await anim.ready; 50 51 let duration = anim.effect.getComputedTiming().duration; 52 assert_percents_equal(duration, CSS.percent(100), 53 'Default duration is 100%'); 54 55 // Start and end boundaries coincide. 56 anim.rangeStart = "entry 100%"; 57 anim.rangeEnd = "contain 0%"; 58 duration = anim.effect.getComputedTiming().duration; 59 assert_percents_equal(duration, CSS.percent(0), 60 "Duration is zero when boundaries coincide"); 61 62 // Start > end, clamp at zero duration. 63 anim.rangeEnd = "entry 0%" 64 duration = anim.effect.getComputedTiming().duration; 65 assert_percents_equal(duration, CSS.percent(0), 66 "Duration is zero when start > end"); 67 68 anim.rangeStart = "normal"; 69 anim.rangeEnd = "normal"; 70 duration = anim.effect.getComputedTiming().duration; 71 assert_percents_equal(duration, CSS.percent(100), 72 "Duration is 100% after range reset"); 73 74 // Consumed 100% of timeline duration with delays 75 anim.effect.updateTiming({ 76 delay: CSS.percent(60), 77 endDelay: CSS.percent(40) 78 }); 79 duration = anim.effect.getComputedTiming().duration; 80 assert_percents_equal(duration, CSS.percent(0), 81 "Duration is 0% after delays sum to 100%"); 82 83 // Delays sum to > 100% 84 anim.effect.updateTiming({ 85 delay: CSS.percent(60), 86 endDelay: CSS.percent(60) 87 }); 88 duration = anim.effect.getComputedTiming().duration; 89 assert_percents_equal(duration, CSS.percent(0), 90 "Duration is 0% after delays sum to > 100%"); 91 92 anim.effect.updateTiming({ 93 delay: CSS.percent(40), 94 endDelay: CSS.percent(40) 95 }); 96 duration = anim.effect.getComputedTiming().duration; 97 assert_percents_equal( 98 duration, CSS.percent(20), 99 "Duration is 20% if normal range and delays sum to 80%"); 100 101 }, 'Intrinsic iteration duration is non-negative'); 102 } 103 104 105 window.onload = runTest; 106 </script>