Bug 590181 part 1 - Fix tests to avoid rounding errors. Original patch from jlebar. r=dbaron

This commit is contained in:
Mike Hommey 2011-04-28 15:48:59 +02:00
parent 0d02596cb7
commit c84f4c8776
4 changed files with 40 additions and 25 deletions

View File

@ -5,7 +5,7 @@
</head>
<body style="line-height: 3; width: 500px; height: 250px;">
<span style="background: url(repeatable-diagonal-gradient.png); background-clip: padding-box; background-clip: padding; background-origin: content-box; background-origin: content; border: medium transparent solid; border-width: 7px 4px 2px 18px; padding: 2px 2% 3% 2px; -moz-background-inline-policy: each-box; background-inline-policy: each-box;">
<span style="background: url(repeatable-diagonal-gradient.png); background-clip: padding-box; background-clip: padding; background-origin: content-box; background-origin: content; border: medium transparent solid; border-width: 7px 4px 2px 18px; padding: 2px 10px 15px 2px; -moz-background-inline-policy: each-box; background-inline-policy: each-box;">
blah<br>
blah<br>
blah

View File

@ -3,10 +3,10 @@
<style>
p {
height: 200px;
width: 400px;
height: 256px;
width: 512px;
background: blue;
border-radius: 13px 14px 14px 5px / 3px 2px 10px 3px;
border-radius: 21px 6px 12px 29px / 5px 16px 10px 3px;
}
</style>

View File

@ -3,10 +3,20 @@
<style>
p {
height: 200px;
width: 400px;
/* We use powers of two here to avoid floating-point issues.
See bug 590181. */
height: 256px;
width: 512px;
background: blue;
border-radius: -moz-calc(2% + 5px) -moz-calc(4% - 2px) -moz-calc(10px + 1%) -moz-calc(2% - 3px) / -moz-calc(3% - (1px + 1%)) -moz-calc(1%) -moz-calc(10px) 3px;
border-radius: -moz-calc((1/32 * 100%) + 5px)
-moz-calc((1/64 * 100%) - 2px)
-moz-calc(10px + (1/256 * 100%))
-moz-calc((1/16 * 100%) - 3px) /
-moz-calc((1/32 * 100%) - (1px + (1/128 * 100%)))
-moz-calc(1/16 * 100%)
-moz-calc(10px)
3px;
}
</style>

View File

@ -555,8 +555,10 @@ function test_radius_transition(prop) {
// FIXME: Test a square for now, since we haven't updated to the spec
// for vertical components being relative to the height.
div.style.setProperty("width", "200px", "");
div.style.setProperty("height", "200px", "");
// Note: We use powers of two here so the floating-point math comes out
// nicely.
div.style.setProperty("width", "256px", "");
div.style.setProperty("height", "256px", "");
div.style.setProperty("border", "none", "");
div.style.setProperty("padding", "0", "");
@ -570,14 +572,14 @@ function test_radius_transition(prop) {
"radius-valued property " + prop + ": interpolation of radius");
check_distance(prop, "3px", "6px", "15px");
div.style.setProperty("-moz-transition-property", "none", "");
div.style.setProperty(prop, "5%", "");
is(cs.getPropertyValue(prop), "10px",
div.style.setProperty(prop, "12.5%", "");
is(cs.getPropertyValue(prop), "32px",
"radius-valued property " + prop + ": computed value before transition");
div.style.setProperty("-moz-transition-property", prop, "");
div.style.setProperty(prop, "25%", "");
is(cs.getPropertyValue(prop), "20px",
is(cs.getPropertyValue(prop), "40px",
"radius-valued property " + prop + ": interpolation of radius");
check_distance(prop, "5%", "10%", "25%");
check_distance(prop, "12.5%", "15.625%", "25%");
div.style.setProperty("-moz-transition-property", "none", "");
div.style.setProperty(prop, "3px 8px", "");
is(cs.getPropertyValue(prop), "3px 8px",
@ -588,24 +590,25 @@ function test_radius_transition(prop) {
"radius-valued property " + prop + ": interpolation of radius");
check_distance(prop, "3px 8px", "6px 9px", "15px 12px");
div.style.setProperty("-moz-transition-property", "none", "");
div.style.setProperty(prop, "5% 15%", "");
is(cs.getPropertyValue(prop), "10px 30px",
div.style.setProperty(prop, "12.5% 6.25%", "");
is(cs.getPropertyValue(prop), "32px 16px",
"radius-valued property " + prop + ": computed value before transition");
div.style.setProperty("-moz-transition-property", prop, "");
div.style.setProperty(prop, "25%", "");
is(cs.getPropertyValue(prop), "20px 35px",
is(cs.getPropertyValue(prop), "40px 28px",
"radius-valued property " + prop + ": interpolation of radius");
check_distance(prop, "5% 15%", "10% 17.5%", "25%");
check_distance(prop, "12.5% 6.25%", "15.625% 10.9375%", "25%");
div.style.setProperty("-moz-transition-property", "none", "");
div.style.setProperty(prop, "8% 12%", "");
is(cs.getPropertyValue(prop), "16px 24px",
div.style.setProperty(prop, "6.25% 12.5%", "");
is(cs.getPropertyValue(prop), "16px 32px",
"radius-valued property " + prop + ": computed value before transition");
div.style.setProperty("-moz-transition-property", prop, "");
div.style.setProperty(prop, "40px 20px", "");
is(cs.getPropertyValue(prop), "22px 23px",
div.style.setProperty(prop, "64px 16px", "");
is(cs.getPropertyValue(prop), "28px",
"radius-valued property " + prop + ": interpolation of radius with mixed units");
check_distance(prop, "8% 12%", "-moz-calc(6% + 10px) -moz-calc(5px + 9%)",
"40px 20px");
check_distance(prop, "6.25% 12.5%",
"-moz-calc(4.6875% + 16px) -moz-calc(9.375% + 4px)",
"64px 16px");
test_length_percent_calc_transition(prop);
@ -914,9 +917,11 @@ function test_transform_transition(prop) {
expected_uncomputed: 'translateY(-30%)',
expected: 'matrix(1, 0, 0, 1, 0px, -15px)' },
{ start: 'none', end: 'rotate(90deg) translate(20%, 20%) rotate(-90deg)',
expected_uncomputed: 'rotate(22.5deg) translate(5%, 5%) rotate(-22.5deg)' },
expected_uncomputed: 'rotate(22.5deg) translate(5%, 5%) rotate(-22.5deg)',
round_error_ok: true },
{ start: 'none', end: 'rotate(-90deg) translate(20%, 20%) rotate(90deg)',
expected_uncomputed: 'rotate(-22.5deg) translate(5%, 5%) rotate(22.5deg)' },
expected_uncomputed: 'rotate(-22.5deg) translate(5%, 5%) rotate(22.5deg)',
round_error_ok: true },
// test percent translation using matrix decomposition
{ start: 'rotate(45deg) rotate(-45deg)',
end: 'rotate(90deg) translate(20%, 20%) rotate(-90deg)',