Assert.jsm should throw when comparing NaN with another number
Categories
(Testing :: General, defect)
Tracking
(firefox99 fixed)
| 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".
| Assignee | ||
Comment 1•4 years ago
|
||
Comment 3•4 years ago
|
||
Backed out for causing failures on test_nsIX509CertValidity.js
Backout link : https://hg.mozilla.org/integration/autoland/rev/734a68144915c34759b8fd5fdd63b1e525ad6aa5
Link to failure log: https://treeherder.mozilla.org/logviewer?job_id=367050282&repo=autoland&lineNumber=1638
Comment 5•4 years ago
|
||
| bugherder | ||
| Assignee | ||
Comment 6•4 years ago
|
||
(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.
Description
•