Index: LayoutTests/web-animations-api/animations-additive-length.html |
diff --git a/LayoutTests/web-animations-api/animations-additive-length.html b/LayoutTests/web-animations-api/animations-additive-length.html |
new file mode 100644 |
index 0000000000000000000000000000000000000000..e338cf0ea01dc35d231fe16106595dc8979a357e |
--- /dev/null |
+++ b/LayoutTests/web-animations-api/animations-additive-length.html |
@@ -0,0 +1,249 @@ |
+<!DOCTYPE html> |
+<script src="../resources/testharness.js"></script> |
+<script src="../resources/testharnessreport.js"></script> |
+ |
+<style> |
+#element, #container { |
+ outline-style: solid; |
+ outline-width: 0; |
+ border-style: solid; |
+ border-width: 0; |
+} |
+</style> |
+ |
+<div id='container'> |
+ <div id='element'></div> |
+</div> |
+ |
+<script> |
+ |
+var container = document.getElementById('container'); |
+var element = document.getElementById('element'); |
+ |
+var players = []; |
+ |
+function testLength(property, parentUnderlyingValue, underlyingValue, keyframePairs, expected) { |
+ container.style[property] = parentUnderlyingValue; |
+ element.style[property] = underlyingValue; |
+ |
+ // Clear existing players (from a previous failed test) |
+ players.forEach(function(player) { |
+ player.cancel(); |
+ }); |
+ |
+ keyframePairs.forEach(function(keyframePair) { |
+ var keyframeA = {}; |
+ var keyframeB = {}; |
+ keyframeA['composite'] = keyframePair[0].composite; |
+ keyframeB['composite'] = keyframePair[1].composite; |
+ |
+ keyframeA[property] = keyframePair[0].value; |
+ keyframeB[property] = keyframePair[1].value; |
+ |
+ var player = element.animate([keyframeA, keyframeB], {duration: 1, fill: 'forwards'}); |
+ player.pause(); |
+ |
+ players.push(player); |
+ }); |
+ |
+ for (var t in expected) { |
+ players.forEach(function(player) { |
+ player.currentTime = t; |
+ }); |
+ |
+ assert_equals(getComputedStyle(element)[property], expected[t]); |
+ } |
+ |
+ players.forEach(function(player) { |
+ player.cancel(); |
+ }); |
+} |
+ |
+function resetLength(property) { |
+ container.style[property] = ''; |
+ element.style[property] = ''; |
+} |
+ |
+var properties = [ |
+ 'borderBottomWidth', |
+ 'borderLeftWidth', |
+ 'borderRightWidth', |
+ 'borderTopWidth', |
+ 'flexBasis', |
+ 'fontSize', |
+ 'height', |
+ 'maxHeight', |
+ 'maxWidth', |
+ 'minHeight', |
+ 'minWidth', |
+ 'motionPosition', |
+ 'outlineWidth', |
+ 'paddingBottom', |
+ 'paddingLeft', |
+ 'paddingRight', |
+ 'paddingTop', |
+ 'perspective', |
+ 'shapeMargin', |
+ 'width', |
+]; |
+ |
+properties.forEach(function(property) { |
+ var suffix = ' (for ' + property + ')'; |
+ |
+ // Cases in which auto can be used, but won't be resolved |
+ switch (property) { |
+ case 'width': |
+ case 'height': |
+ case 'flexBasis': |
+ case 'minWidth': |
+ case 'minHeight': |
+ test(function() { |
+ testLength(property, '', 'auto', [[{value: '100px', composite: 'replace'}, {value: '200px', composite: 'replace'}]], { |
+ 0.0: '100px', |
+ 0.25: '125px', |
+ 0.5: '150px', |
+ 0.75: '175px', |
+ 1.0: '200px', |
+ }); |
+ }, 'Underlying value of auto ignored in replace -> replace keyframes' + suffix); |
+ |
+ test(function() { |
+ testLength(property, '500px', '300px', [[{value: 'auto', composite: 'add'}, {value: 'auto', composite: 'add'}]], { |
+ 0.0: '300px', |
+ 0.25: '300px', |
+ 0.5: '300px', |
+ 0.75: '300px', |
+ 1.0: '300px', |
+ }); |
+ }, 'Add -> add auto keyframes ignored with underlying value length' + suffix); |
+ |
+ break; |
+ } |
+ |
+ // Cases in which we expect auto to be resolved |
+ switch (property) { |
+ case 'width': |
+ test(function() { |
+ testLength(property, '500px', 'auto', [[{value: '100px', composite: 'add'}, {value: '200px', composite: 'add'}]], { |
+ 0.0: '500px', |
+ 0.25: '500px', |
+ 0.5: '500px', |
+ 0.75: '500px', |
+ 1.0: '500px', |
+ }); |
+ }, 'Underlying value auto ignored in add -> add length keyframes' + suffix); |
+ |
+ break; |
+ |
+ case 'height': |
+ test(function() { |
+ testLength(property, '500px', 'auto', [[{value: '100px', composite: 'add'}, {value: '200px', composite: 'add'}]], { |
+ 0.0: '0px', |
+ 0.25: '0px', |
+ 0.5: '0px', |
+ 0.75: '0px', |
+ 1.0: '0px', |
+ }); |
+ }, 'Underlying value of auto ignored in add -> add keyframes' + suffix); |
+ |
+ break; |
+ } |
+ |
+ test(function() { |
+ testLength(property, '', '300px', [[{value: '100px', composite: 'replace'}, {value: '200px', composite: 'replace'}]], { |
+ 0.0: '100px', |
+ 0.25: '125px', |
+ 0.5: '150px', |
+ 0.75: '175px', |
+ 1.0: '200px', |
+ }); |
+ }, 'Underlying value length ignored in replace -> replace keyframes' + suffix); |
+ |
+ test(function() { |
+ testLength(property, '', '300px', [[{value: '100px', composite: 'add'}, {value: '200px', composite: 'add'}]], { |
+ 0.0: '400px', |
+ 0.25: '425px', |
+ 0.5: '450px', |
+ 0.75: '475px', |
+ 1.0: '500px', |
+ }); |
+ }, 'Underlying value length added in add -> add keyframes' + suffix); |
+ |
+ test(function() { |
+ testLength(property, '500px', 'inherit', [[{value: '100px', composite: 'add'}, {value: '200px', composite: 'add'}]], { |
+ 0.0: '600px', |
+ 0.25: '625px', |
+ 0.5: '650px', |
+ 0.75: '675px', |
+ 1.0: '700px', |
+ }); |
+ }, 'Underlying value of inherit added to in add -> add keyframes' + suffix); |
+ |
+ test(function() { |
+ testLength(property, '', '1000px', [ |
+ [{value: '100px', composite: 'replace'}, {value: '200px', composite: 'replace'}], |
+ [{value: '300px', composite: 'replace'}, {value: '400px', composite: 'replace'}] |
+ ], { |
+ 0.0: '300px', |
+ 0.25: '325px', |
+ 0.5: '350px', |
+ 0.75: '375px', |
+ 1.0: '400px', |
+ }); |
+ }, 'Replace -> replace animations override earlier replace -> replace animations' + suffix); |
+ |
+ test(function() { |
+ testLength(property, '', '1000px', [ |
+ [{value: '100px', composite: 'add'}, {value: '200px', composite: 'add'}], |
+ [{value: '300px', composite: 'replace'}, {value: '400px', composite: 'replace'}] |
+ ], { |
+ 0.0: '300px', |
+ 0.25: '325px', |
+ 0.5: '350px', |
+ 0.75: '375px', |
+ 1.0: '400px', |
+ }); |
+ }, 'Replace -> replace animations override earlier add -> add animations' + suffix); |
+ |
+ test(function() { |
+ testLength(property, '', '1000px', [ |
+ [{value: '100px', composite: 'replace'}, {value: '200px', composite: 'replace'}], |
+ [{value: '300px', composite: 'add'}, {value: '400px', composite: 'add'}] |
+ ], { |
+ 0.0: '400px', |
+ 0.25: '450px', |
+ 0.5: '500px', |
+ 0.75: '550px', |
+ 1.0: '600px', |
+ }); |
+ }, 'Add -> add animations add on to earlier replace -> replace animations' + suffix); |
+ |
+ test(function() { |
+ testLength(property, '', '1000px', [ |
+ [{value: '100px', composite: 'add'}, {value: '200px', composite: 'add'}], |
+ [{value: '300px', composite: 'add'}, {value: '400px', composite: 'add'}] |
+ ], { |
+ 0.0: '1400px', |
+ 0.25: '1450px', |
+ 0.5: '1500px', |
+ 0.75: '1550px', |
+ 1.0: '1600px', |
+ }); |
+ }, 'Multiple add -> add animations add on to underlying value' + suffix); |
+ |
+ // The new Interpolation code path doesn't yet support interpolation |
+ // (and addition) of inherit/initial/unset values |
+ test(function() { |
+ testLength(property, '500px', '300px', [[{value: '100px', composite: 'add'}, {value: 'inherit', composite: 'add'}]], { |
+ 0.0: '400px', |
+ 0.25: '500px', |
+ 0.5: '600px', |
+ 0.75: '700px', |
+ 1.0: '800px', |
+ }); |
+ }, 'inherit added in add -> add keyframes' + suffix); |
+ |
+ resetLength(property); |
+}); |
+ |
+</script> |