Bug 1542329 - Special case handing of 0-based ranges in wpt reftests, r=dholbert

If either the total pixels different or max differences per channel
includes 0 then allow the images to be identical irrespective of the
other range (i.e. allow identical images with
maxDifference=100;totalPixels=0-1).

Differential Revision: https://phabricator.services.mozilla.com/D26349

--HG--
extra : moz-landing-system : lando
This commit is contained in:
James Graham 2019-04-05 17:38:47 +00:00
parent cd43c70f3c
commit 6f0759a47b
4 changed files with 36 additions and 6 deletions

View File

@ -414,10 +414,12 @@ max-width: ${width}px; max-height: ${height}px`;
let [allowedDiff, allowedPixels] = allowed;
logger.info(`Allowed ${allowedPixels.join("-")} pixels different, ` +
`maximum difference per channel ${allowedDiff.join("-")}`);
return ((maxDifference >= allowedDiff[0] &&
maxDifference <= allowedDiff[1]) &&
(pixelsDifferent >= allowedPixels[0] ||
pixelsDifferent <= allowedPixels[1]));
return ((pixelsDifferent === 0 && allowedPixels[0] == 0) ||
(maxDifference === 0 && allowedDiff[0] == 0) ||
((maxDifference >= allowedDiff[0] &&
maxDifference <= allowedDiff[1]) &&
(pixelsDifferent >= allowedPixels[0] ||
pixelsDifferent <= allowedPixels[1])));
}
ensureFocus(win) {

View File

@ -0,0 +1,13 @@
<!DOCTYPE html>
<link rel=match href=fuzzy-ref-1.html>
<!-- This exactly matches the reference, and includes the possibilty of
0 pixels different; in this case the maxDifference is ignored --->
<meta name=fuzzy content="fuzzy-ref-1.html:128;0-100">
<style>
div {
width: 100px;
height: 100px;
background-color: green;
}
</style>
<div></div>

View File

@ -0,0 +1,13 @@
<!DOCTYPE html>
<link rel=match href=fuzzy-ref-1.html>
<!-- This exactly matches the reference, and includes the possibilty of
0 difference in the color channel; in this case the pixelsDifferent is ignored --->
<meta name=fuzzy content="fuzzy-ref-1.html:0-128;100">
<style>
div {
width: 100px;
height: 100px;
background-color: green;
}
</style>
<div></div>

View File

@ -309,8 +309,10 @@ class RefTestImplementation(object):
self.logger.info("Allowed %s pixels different, maximum difference per channel %s" %
("-".join(str(item) for item in allowed_different),
"-".join(str(item) for item in allowed_per_channel)))
equal = (allowed_per_channel[0] <= max_per_channel <= allowed_per_channel[1] and
allowed_different[0] <= pixels_different <= allowed_different[1])
equal = ((pixels_different == 0 and allowed_different[0] == 0) or
(max_per_channel == 0 and allowed_per_channel[0] == 0) or
(allowed_per_channel[0] <= max_per_channel <= allowed_per_channel[1] and
allowed_different[0] <= pixels_different <= allowed_different[1]))
return equal if relation == "==" else not equal
def get_differences(self, screenshots):