ScopedVariant::Compare Error Handling

This change adds better error handling to ScopedVariant::Compare.

Currently, ScopedVariant::Compare relies on VarCmp to compare variants.
Although VarCmp is only documented as returning VARCMP_LT, VARCMP_EQ,
VARCMP_GT, and VARCMP_NULL, VarCmp may also return HRESULT error codes
in some implementations. For example, VarCmp on variant types VT_UNKNOWN
and VT_ARRAY is unsupported and will result in an hresult error code.
The VarCmp documentation says "It compares strings, integers, and
floating points, but not arrays or records.". The current
ScopedVariant::Compare implementation does not expect this error which
leads to misleading results. For example, comparing an Unknown variant
to any other variant type is reported as equal.

This change addresses this bug by adding a DCHECK to the VarCmp results
to catch invalid comparisons on debug builds and updates the default
case to not equals so that even if two uncomparable variants were
compared in a release build, they would be reported as not equal.

ScopedVariant::Compare on uncomparable types is replaced in accessibility
callers.

Documentation:
https://docs.microsoft.com/en-us/windows/desktop/api/oleauto/nf-oleauto-varcmp

Bug: 957788
Change-Id: I5a87d818845f31df4cf264ba21e4d9fa2d19f8d7
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1590512
Commit-Queue: Frank Poole <frpoole@microsoft.com>
Reviewed-by: Bruce Dawson <brucedawson@chromium.org>
Reviewed-by: Dominic Mazzoni <dmazzoni@chromium.org>
Reviewed-by: Kevin Babbitt <kbabbitt@microsoft.com>
Cr-Commit-Position: refs/heads/master@{#661586}
4 files changed