playwright/tests
Andrey Lushnikov 6d82460a02
feat: implement a new image comparison function (#19166)
This patch implements a new image comparison function, codenamed
"ssim-cie94". The goal of the new comparison function is to cancel out
browser non-determenistic rendering.

To use the new comparison function:

```ts
await expect(page).toHaveScreenshot({
  comparator: 'ssim-cie94',
});
```

As of Nov 30, 2022, we identified the following sources of
non-determenistic rendering for Chromium:
- Anti-aliasing for certain shapes might be different due to the
  way skia rasterizes certain shapes.
- Color blending might be different on `x86` and `aarch64`
architectures.

The new function employs a few heuristics to fight these
differences.

Consider two non-equal image pixels `(r1, g1, b1)` and `(r2, g2, b2)`:
1. If the [CIE94] metric is less then 1.0, then we consider these pixels
   **EQUAL**. (The value `1.0` is the [just-noticeable difference] for
   [CIE94].). Otherwise, proceed to next step.
1. If all the 8 neighbors of the first pixel match its color, or
   if the 8 neighbors of the second pixel match its color, then these
   pixels are **DIFFERENT**. (In case of anti-aliasing, some of the
   direct neighbors have to be blended up or down.) Otherwise, proceed
   to next step.
1. If SSIM in some locality around the different pixels is more than
   0.99, then consider this pixels to be **EQUAL**. Otherwise, mark them
   as **DIFFERENT**. (Local SSIM for anti-aliased pixels turns out to be
   very close to 1.0).

[CIE94]: https://en.wikipedia.org/wiki/Color_difference#CIE94
[just-noticeable difference]:
https://en.wikipedia.org/wiki/Just-noticeable_difference
2022-12-02 15:22:05 -08:00
..
android test: gardening (#18623) 2022-11-07 15:35:21 -08:00
assets fix(chromium): detach from shared workers (#18976) 2022-11-22 15:20:42 -08:00
components test(ct): vue cli router (#18603) 2022-11-08 08:40:29 -08:00
config test: fix WebKit socks proxy tests (#19035) 2022-11-23 13:03:38 -10:00
electron fix(electron): tolerate connection closed during quit (#18993) 2022-11-22 11:50:35 -08:00
image_tools feat: implement a new image comparison function (#19166) 2022-12-02 15:22:05 -08:00
installation feat(playwright-test): introduce snapshotPathTemplate configuration (#18568) 2022-11-09 15:29:07 -08:00
library feat(recorder): make it work with [contenteditable] (#19066) 2022-12-01 12:41:03 -08:00
page feat(recorder): make it work with [contenteditable] (#19066) 2022-12-01 12:41:03 -08:00
playwright-test feat: implement a new image comparison function (#19166) 2022-12-02 15:22:05 -08:00
stress fix(leak): do not retain test fixtures in worker fixtures (#14363) 2022-05-23 16:54:56 -07:00
webview2 fix(electron): stall node while browser is starting (#18804) 2022-11-14 22:01:54 -08:00
index.d.ts test: added tests for WebSocket over Socks proxy (#7235) 2021-06-24 18:50:16 +02:00
tsconfig.json chore: move protocol and trace types into the top-level packages (#17486) 2022-09-20 18:41:51 -07:00