blob: 0276755a51cd1d3e175df265d5fd9d00fa4d7860 [file] [log] [blame]
<!DOCTYPE html>
<meta charset="UTF-8">
<style>
.parent {
background-position: 60px 60px;
}
.target {
width: 120px;
height: 120px;
display: inline-block;
border: 2px solid black;
background-repeat: no-repeat;
background-image: radial-gradient(20px circle at 20px 20px, red 18px, transparent),
radial-gradient(20px circle at 20px 20px, yellow 18px, transparent),
radial-gradient(20px circle at 20px 20px, lime 18px, transparent),
radial-gradient(20px circle at 20px 20px, blue 18px, transparent);
background-position: 40px 40px;
}
.expected {
margin-right: 10px;
}
</style>
<body>
<script src="resources/interpolation-test.js"></script>
<script>
assertInterpolation({
property: 'background-position',
from: neutralKeyframe,
to: '80px 80px, 80px 80px, 80px 80px, 80px 80px',
}, [
{at: -0.25, is: '30px 30px, 30px 30px, 30px 30px, 30px 30px'},
{at: 0, is: '40px 40px, 40px 40px, 40px 40px, 40px 40px'},
{at: 0.25, is: '50px 50px, 50px 50px, 50px 50px, 50px 50px'},
{at: 0.5, is: '60px 60px, 60px 60px, 60px 60px, 60px 60px'},
{at: 0.75, is: '70px 70px, 70px 70px, 70px 70px, 70px 70px'},
{at: 1, is: '80px 80px, 80px 80px, 80px 80px, 80px 80px'},
{at: 1.25, is: '90px 90px, 90px 90px, 90px 90px, 90px 90px'},
]);
assertInterpolation({
property: 'background-position',
from: 'initial',
to: '80px 80px, 80px 80px, 80px 80px, 80px 80px',
}, [
{at: -0.25, is: '-20px -20px, -20px -20px, -20px -20px, -20px -20px'},
{at: 0, is: ' 0% 0% , 0% 0% , 0% 0% , 0% 0% '}, // TODO(alancutter): Should these be 0px?
{at: 0.25, is: ' 20px 20px, 20px 20px, 20px 20px, 20px 20px'},
{at: 0.5, is: ' 40px 40px, 40px 40px, 40px 40px, 40px 40px'},
{at: 0.75, is: ' 60px 60px, 60px 60px, 60px 60px, 60px 60px'},
{at: 1, is: ' 80px 80px, 80px 80px, 80px 80px, 80px 80px'},
{at: 1.25, is: '100px 100px, 100px 100px, 100px 100px, 100px 100px'},
]);
assertInterpolation({
property: 'background-position',
from: 'inherit',
to: '80px 80px, 80px 80px, 80px 80px, 80px 80px',
}, [
{at: -0.25, is: '55px 55px, 55px 55px, 55px 55px, 55px 55px'},
{at: 0, is: '60px 60px, 60px 60px, 60px 60px, 60px 60px'},
{at: 0.25, is: '65px 65px, 65px 65px, 65px 65px, 65px 65px'},
{at: 0.5, is: '70px 70px, 70px 70px, 70px 70px, 70px 70px'},
{at: 0.75, is: '75px 75px, 75px 75px, 75px 75px, 75px 75px'},
{at: 1, is: '80px 80px, 80px 80px, 80px 80px, 80px 80px'},
{at: 1.25, is: '85px 85px, 85px 85px, 85px 85px, 85px 85px'},
]);
assertInterpolation({
property: 'background-position',
from: 'unset',
to: '80px 80px, 80px 80px, 80px 80px, 80px 80px',
}, [
{at: -0.25, is: '-20px -20px, -20px -20px, -20px -20px, -20px -20px'},
{at: 0, is: ' 0% 0% , 0% 0% , 0% 0% , 0% 0% '},
{at: 0.25, is: ' 20px 20px, 20px 20px, 20px 20px, 20px 20px'},
{at: 0.5, is: ' 40px 40px, 40px 40px, 40px 40px, 40px 40px'},
{at: 0.75, is: ' 60px 60px, 60px 60px, 60px 60px, 60px 60px'},
{at: 1, is: ' 80px 80px, 80px 80px, 80px 80px, 80px 80px'},
{at: 1.25, is: '100px 100px, 100px 100px, 100px 100px, 100px 100px'},
]);
// Test equal number of position values as background images.
assertInterpolation({
property: 'background-position',
from: '0px 0px, 0px 0px, 0px 0px, 0px 0px',
to: '80px 80px, 80px 80px, 80px 80px, 80px 80px',
}, [
{at: -0.25, is: '-20px -20px, -20px -20px, -20px -20px, -20px -20px'},
{at: 0, is: ' 0px 0px, 0px 0px, 0px 0px, 0px 0px'},
{at: 0.25, is: ' 20px 20px, 20px 20px, 20px 20px, 20px 20px'},
{at: 0.5, is: ' 40px 40px, 40px 40px, 40px 40px, 40px 40px'},
{at: 0.75, is: ' 60px 60px, 60px 60px, 60px 60px, 60px 60px'},
{at: 1, is: ' 80px 80px, 80px 80px, 80px 80px, 80px 80px'},
{at: 1.25, is: '100px 100px, 100px 100px, 100px 100px, 100px 100px'},
]);
// Test single position value repeated over background images.
assertInterpolation({
property: 'background-position',
from: 'top 0px left 0px',
to: 'left 80px top 80px',
}, [
{at: -0.25, is: '-20px -20px, -20px -20px, -20px -20px, -20px -20px'},
{at: 0, is: ' 0px 0px, 0px 0px, 0px 0px, 0px 0px'},
{at: 0.25, is: ' 20px 20px, 20px 20px, 20px 20px, 20px 20px'},
{at: 0.5, is: ' 40px 40px, 40px 40px, 40px 40px, 40px 40px'},
{at: 0.75, is: ' 60px 60px, 60px 60px, 60px 60px, 60px 60px'},
{at: 1, is: ' 80px 80px, 80px 80px, 80px 80px, 80px 80px'},
{at: 1.25, is: '100px 100px, 100px 100px, 100px 100px, 100px 100px'},
]);
// Test mismatched numbers of position values.
assertInterpolation({
property: 'background-position',
from: '0px 0px, 80px 0px',
to: '40px 40px, 80px 80px, 0px 80px',
}, [
{at: -0.25, is: '-10px -10px, 80px -20px, 0px -20px, 90px -10px'},
{at: 0, is: ' 0px 0px, 80px 0px, 0px 0px, 80px 0px'},
{at: 0.25, is: ' 10px 10px, 80px 20px, 0px 20px, 70px 10px'},
{at: 0.5, is: ' 20px 20px, 80px 40px, 0px 40px, 60px 20px'},
{at: 0.75, is: ' 30px 30px, 80px 60px, 0px 60px, 50px 30px'},
{at: 1, is: ' 40px 40px, 80px 80px, 0px 80px, 40px 40px'},
{at: 1.25, is: ' 50px 50px, 80px 100px, 0px 100px, 30px 50px'},
]);
</script>
</body>