testing/web-platform/tests/infrastructure/reftest/reftest_fuzzy.html
author jgraham <james@hoppipolla.co.uk>
Tue, 26 Mar 2019 13:55:29 +0000
changeset 467268 18fb7bd95d12a7f535be2fda194e4b5cab9620db
permissions -rw-r--r--
Bug 1478472 [wpt PR 12187] - Add support for fuzzy matching in reftests., a=testonly Automatic update from web-platform-tests Add support for fuzzy matching in reftests (#12187) This allows fuzzy matching in reftests in which a comparison can succeed if the images are different within a specified tolerance. It is useful in the case of antialiasing, and in other scenarios where it's not possible to make an exact match in all cases. Differences between tests are characterised by two values: * The maximum difference for any pixel on any color channel (in the range 0 to 255) * The maximum total number of differing pixels The fuzziness can be supplied in two places, according to whether it's a property of the test or of the implementation: * In the reftest itself, using a <meta name=fuzzy> tag * In the expectation metadata file using a fuzzy: key that takes a list The general format of the fuzziness specifier is range = [name "="] [digits, "-"], digits fuzziness = [ url, "-" ], range, ";", range name = "maxDifference" | "totalPixels" The first range represents the maximum difference of any channel per pixel and the second represents the total number of pixel differences. So for example a specifier could be: * "maxDifference=10;totalPixels=300" - meaning a difference of exactly 10 per color channel and exactly 300 pixels different in total (all ranges are inclusive). * "5-10;200-300" - meaning a maximum difference of between 5 and 10 per color channel and between 200 and 300 pixels differing in total The definition of url is a little different between the meta element and the expecation metadata. In the first case the url is resolved against the current file, and applies to any reference in the current file with that name. So for example <meta name="fuzzy" content="option-1-ref.html:5;200"> would allow a fuzziness of up to 5 on a specific channel and up to 200 opixels different for comparisons involving the file containing the meta element and option-1-ref.html. In the case of expectation metadata, the metadata is always associated with the root test, so urls are always resolved relative to that. In the case as above where only a single URL is supplied, any reference document with that URL will have the fuzziness applied for whatever comparisons it's involved in e.g. [test1.html] fuzzy: option-1-ref.html:5;200 would apply the fuziness to any comparison involving option-1-ref.html whilst running the set of reftests rooted on test1.html. To specify an exact comparison for the fuzziness, one can also supply a full reference pair e.g. [test1.html] fuzzy: subtest.html==option-1-ref.html:5;200 in which case the fuzziness would only apply to "match" comparison involving subtest.html on the lhs and option-1-ref.html on the rhs (both resolved relative to test1.html). -- wpt-commits: 1f570a686843ca10f151a79956ee16110f4a4d42 wpt-pr: 12187

<!DOCTYPE html>
<link rel=match href=fuzzy-ref-1.html>
<!-- This meta is overridden in the corresponding ini file -->
<meta name=fuzzy content="fuzzy-ref-1.html:128;100">
<style>
div {
  width: 99px;
  height: 100px;
  background-color: green;
}
</style>
<div></div>