Tx,y,c
be the value of
colour channel `c` at pixel coordinates `x`, `y` in the test image and
Rx,y,c
be the corresponding value in the
reference image, and let width
and height
be
the dimensions of the image in pixels. Then maxDifference =
maxx=[0,width) y=[0,height), c={r,g,b}(|Tx,y,c -
Rx,y,c|)
.
To specify the fuzziness in the test file one may add a `` element (or, in the case of more complex tests, to any
page containing the `` elements). In the simplest
case this has a `content` attribute containing the parameters above,
separated by a colon e.g.
```
```
would allow for a difference of exactly 15 / 255 on any color channel
and 300 exactly pixels total difference. The argument names are optional
and may be elided; the above is the same as:
```
```
The values may also be given as ranges e.g.
```
```
or
```
```
In this case the maximum pixel difference must be in the range
`10-15` and the total number of different pixels must be in the range
`200-300`.
In cases where a single test has multiple possible refs and the
fuzziness is not the same for all refs, a ref may be specified by
prefixing the `content` value with the relative url for the ref e.g.
```
```
One meta element is required per reference requiring a unique
fuzziness value, but any unprefixed value will automatically be
applied to any ref that doesn't have a more specific value.
## Limitations
In some cases, a test cannot be a reftest. For example, there is no
way to create a reference for underlining, since the position and
thickness of the underline depends on the UA, the font, and/or the
platform. However, once it's established that underlining an inline
element works, it's possible to construct a reftest for underlining
a block element, by constructing a reference using underlines on a
`````` that wraps all the content inside the block.
## Example Reftests
This example follows the recommended approach in being a
self-describing test as it has a simple statement on the page
describing how it should render to pass the tests.
### Test File
This test verifies that a right-to-left rendering of **SAW** within a
`````` element displays as **WAS**.
```html
Pass if you see WAS displayed below.
SAW ``` ### Reference File The reference file must look exactly like the test file, except that the code behind it is different. * All metadata is removed. * The ```title``` need not match. * The markup that created the actual test data is different: here, the same effect is created with very mundane, dependable technology. ```htmlPass if you see WAS displayed below.
WAS
``` [general guidelines]: general-guidelines [rendering]: rendering