| <!DOCTYPE html> |
| <meta charset="UTF-8"> |
| <script src="../../resources/testharness.js"></script> |
| <script src="../../resources/testharnessreport.js"></script> |
| <div id="target"></div> |
| <script> |
| // The console warnings about "Invalid keyframe value" are expected for this test. |
| |
| setup(() => { |
| CSS.registerProperty({ |
| name: '--length', |
| syntax: '<length>', |
| initialValue: '40px', |
| inherits: false, |
| }); |
| |
| CSS.registerProperty({ |
| name: '--percentage', |
| syntax: '<percentage>', |
| initialValue: '40%', |
| inherits: false, |
| }); |
| }); |
| |
| test(() => { |
| var animation = target.animate({'--length': ['10%', '100px']}, 1); |
| animation.currentTime = 0; |
| assert_equals(getComputedStyle(target).getPropertyValue('--length'), '40px', |
| 'percentage fails to parse and is treated as neutral value'); |
| animation.currentTime = 0.5; |
| assert_equals(getComputedStyle(target).getPropertyValue('--length'), '70px', |
| '--length is being animated'); |
| animation.cancel(); |
| }, "<length> properties don't accept percentages in animation keyframes"); |
| |
| test(() => { |
| var animation = target.animate({'--percentage': ['10px', '100%']}, 1); |
| animation.currentTime = 0; |
| assert_equals(getComputedStyle(target).getPropertyValue('--percentage'), '40%', |
| 'percentage fails to parse and is treated as neutral value'); |
| animation.currentTime = 0.5; |
| assert_equals(getComputedStyle(target).getPropertyValue('--percentage'), '70%', |
| '--percentage is being animated'); |
| animation.cancel(); |
| }, "<percentage> properties don't accept lengths in animation keyframes"); |
| </script> |
| </body> |