Chromium Code Reviews| Index: LayoutTests/web-animations-api/animations-additive-width.html |
| diff --git a/LayoutTests/web-animations-api/animations-additive-width.html b/LayoutTests/web-animations-api/animations-additive-width.html |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..789e5b4351499f1a80ab9b9e3cd533fe33350ad5 |
| --- /dev/null |
| +++ b/LayoutTests/web-animations-api/animations-additive-width.html |
| @@ -0,0 +1,259 @@ |
| +<!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'); |
| + |
| +function testNonNegativeLength(property, parentUnderlyingValue, underlyingValue, keyframePairs, expected) { |
| + var oldUnderlyingValue = element.style[property]; |
| + var oldParentUnderlyingValue = container.style[property]; |
| + |
| + if (parentUnderlyingValue != '') |
| + container.style[property] = parentUnderlyingValue; |
| + |
| + element.style[property] = underlyingValue; |
| + |
| + var players = []; |
| + |
| + 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(); |
| + }); |
| + |
| + container.style[property] = oldParentUnderlyingValue; |
| + element.style[property] = oldUnderlyingValue; |
| +} |
| + |
| +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 + ')'; |
| + |
| + switch (property) { |
| + case 'width': |
| + case 'height': |
| + case 'flexBasis': |
| + case 'minWidth': |
| + case 'minHeight': |
| + case 'columnWidth': |
| + test(function() { |
| + testNonNegativeLength(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); |
| + |
| + break; |
| + } |
| + |
| + switch (property) { |
| + case 'width': |
| + case 'columnWidth': |
| + test(function() { |
| + testNonNegativeLength(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 of auto ignored in add -> add keyframes' + suffix); |
| + |
| + |
| + test(function() { |
| + testNonNegativeLength(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); |
| + |
| + break; |
| + |
| + case 'height': |
| + test(function() { |
| + testNonNegativeLength(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() { |
| + testNonNegativeLength(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); |
| + |
| + |
| + test(function() { |
| + testNonNegativeLength(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); |
| + |
| + break; |
| + } |
| + |
| + test(function() { |
| + testNonNegativeLength(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() { |
| + testNonNegativeLength(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() { |
| + testNonNegativeLength(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() { |
| + testNonNegativeLength(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() { |
| + testNonNegativeLength(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() { |
| + testNonNegativeLength(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() { |
| + testNonNegativeLength(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); |
| + */ |
|
alancutter (OOO until 2018)
2015/02/12 05:55:45
Uncomment and expect failure.
|
| +}); |
| + |
| +</script> |