Closed Bug 1754015 Opened 4 years ago Closed 4 years ago

Assert.jsm should throw when comparing NaN with another number

Categories

(Testing :: General, defect)

Default
defect

Tracking

(firefox99 fixed)

RESOLVED FIXED
99 Branch
Tracking Status
firefox99 --- fixed

People

(Reporter: florian, Assigned: florian)

References

Details

Attachments

(1 file)

Assert.greater(NaN, 0) currently returns true.

I noticed browser_test_procinfo.js was pretty broken (bug 1754012) but still passed, because of this bug. It did something like:

let total = 0;
for (let object of objects) {
  total += object.bogus_property_name;
}
Assert.greater(total, 0);

0 + undefined is NaN.

Any comparison with NaN returns false. But greater is implemented using a lhs <= rhs comparison, which returns false, thus Assert.greater checks always pass when one of the operands is NaN.

compareNumbers does have checks for the type of operands, implemented as typeof lhs == "number", but typeof NaN is "number".

Pushed by fqueze@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/8f11731d9aee Assert.jsm should throw when comparing a NaN number, r=Gijs.
Depends on: 1754217
Pushed by fqueze@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/d5b887e2deaf Assert.jsm should throw when comparing a NaN number, r=Gijs.
Status: ASSIGNED → RESOLVED
Closed: 4 years ago
Resolution: --- → FIXED
Target Milestone: --- → 99 Branch

(In reply to Cristina Cozmuta (:CrissCozmuta) from comment #3)

Backed out for causing failures on test_nsIX509CertValidity.js

I relanded after this was fixed in bug 1754217.

Flags: needinfo?(florian)
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: