Bug 1849630 [wpt PR 41567] - Refactor how wpt handles fuzzy color matching, a=testonly
commit9e4d6c4574f037b17fcbf66beabf64e550bbde1b
authorAaron Krajeski <aaronhk@chromium.org>
Fri, 8 Sep 2023 19:11:06 +0000 (8 19:11 +0000)
committermoz-wptsync-bot <wptsync@mozilla.com>
Wed, 13 Sep 2023 11:37:41 +0000 (13 11:37 +0000)
treed189ede81504db5a0e55ae031aa25eae0c3df844
parent104bc4d66e494b2a7e4237fcae0e51678a7b6191
Bug 1849630 [wpt PR 41567] - Refactor how wpt handles fuzzy color matching, a=testonly

Automatic update from web-platform-tests
Refactor how wpt handles fuzzy color matching

Both computed and valid color tests previous looked for exact matching
of strings. This became untenable with color-mix and relative color
syntax because of potential float rounding errors. e.g.:

color-mix(in lch, color(srgb 1 0 0) 100%, black)
Will simply return red in the lch color space.
chromium: lch(54.29     106.854   40.856)
firefox:  lch(54.2905   106.846   40.855)
safari:   lch(54.288002 106.83335 40.852623)

These numbers are all obviously extremely similar. If we want more
alignment on how floats are serialized, it should be tested elsewhere.

This CL adds a custom comparsionFunction to css valid and computed
tests. For colors this test will strip out numbers and compare them
with an epislon, then compare other parts of the string directly to
validate formatting and color space. The algorithm itself is moved
from computed-testcommon.js

Bug: 1474922
Change-Id: I30f9271db6aac0392848ae09e0defd48f5aa2dcc
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4799569
Commit-Queue: Aaron Krajeski <aaronhk@chromium.org>
Reviewed-by: Rune Lillesveen <futhark@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1188331}

--

wpt-commits: 34fa76976c8bce2eaa2e3cb97c88b2358ffd71ae
wpt-pr: 41567
testing/web-platform/tests/css/css-color/parsing/color-computed-color-mix-function.html
testing/web-platform/tests/css/css-color/parsing/color-computed-relative-color.html
testing/web-platform/tests/css/css-color/parsing/color-mix-out-of-gamut.html
testing/web-platform/tests/css/css-color/parsing/color-valid-relative-color.html
testing/web-platform/tests/css/support/color-testcommon.js [new file with mode: 0644]
testing/web-platform/tests/css/support/computed-testcommon.js
testing/web-platform/tests/css/support/parsing-testcommon.js