Bug 1626471 [wpt PR 22585] - geometry: Propagate NaN in min/max operations, a=testonly
commit734a07a61b7cf1f865fdf26b4377611257ed0b90
authorBlink WPT Bot <blink-w3c-test-autoroller@chromium.org>
Fri, 3 Apr 2020 10:04:32 +0000 (3 10:04 +0000)
committermoz-wptsync-bot <wptsync@mozilla.com>
Mon, 6 Apr 2020 12:43:51 +0000 (6 12:43 +0000)
tree8fe9e52de813f1b966b92a2fc5579828d74d60ab
parente2dc34f83ce40cf166de2f6f208fb2a091a26752
Bug 1626471 [wpt PR 22585] - geometry: Propagate NaN in min/max operations, a=testonly

Automatic update from web-platform-tests
geometry: Propagate NaN in min/max operations (#22585)

Currently in some geometry classes we are using std::min() and
std::max() over numbers specified in IDL as "unrestricted double",
meaning they could take the special value NaN. These STL helpers
internally use the < operator, as in

    std::min(a, b) = a < b ? a : b.

However, the IEEE 794 < operator always returns false when _either_
operand is NaN, so the result of min(0, NaN) and min(NaN, 0) could,
confusingly, be different.

This is difference is in fact visible through JavaScript. For instance,

    new DOMQuad({ x: NaN }, { x: 0 }, { x: 0 }, { x: 0 }).getBounds().x

gives NaN, but

    new DOMQuad({ x: 0 }, { x: 0 }, { x: 0 }, { x: NaN }).getBounds().x

gives 0.

A similar problem is present for DOMRect/DOMRectReadOnly as well.

This CL implements [1], which is to adopt semantics similar to
JavaScript's Math.min() and Math.max(), which propagates NaN from either
operand. This also aligns our behavior with WebKit.

[1]: https://github.com/w3c/fxtf-drafts/pull/395

Fixed: 1066499
Change-Id: Id9a4282fa00dafcfe9c5616643efbe2eaace411e
--

wpt-commits: 452d7c5e1a0b683ccfbfaf6fcac833b3e96bb32e
wpt-pr: 22585
testing/web-platform/tests/css/geometry/DOMQuad-001.html
testing/web-platform/tests/css/geometry/DOMQuad-nan.html [new file with mode: 0644]
testing/web-platform/tests/css/geometry/DOMRect-nan.html [new file with mode: 0644]