Closed Bug 783607 Opened 12 years ago Closed 11 years ago

Write a test to check the precision of <input type=number>

Categories

(Core :: DOM: Core & HTML, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla24

People

(Reporter: raphc, Assigned: mounir)

References

Details

Attachments

(1 file, 2 obsolete files)

Right now we use a double to hold the step attribute value. 
While most of the time the double's precision is enough, there are some cases where it's not enough and it's not possible to calculate the exact value of the allowed value step (http://www.whatwg.org/specs/web-apps/current-work/multipage/common-input-element-attributes.html#concept-input-step), e.g. for an <input type=number> with:
min=0.1,
step=0.2,
value=0.3, 
the element will be in the step mismatch validity step, even though it's actually in a valid state, because the double is not precise enough to handle the 0.1+0.2 addition.
The use of a double precision floating point number can lead to various edge case issues such as the one described above and, since the operations on the step/stepScaleFactor/stepBase/etc are not performance critical, we should use some arbitrary-precision type instead.
Depends on: 853525
Bug 853525 fixed this issue, but it only added tests for <input type=range>. We could also do with similar tests for type=number.
Summary: improve the precision of the input element step attribute. → Write a test to check the precision of <input type=number>
Attached patch Patch (obsolete) — Splinter Review
Assignee: nobody → mounir
Status: NEW → ASSIGNED
Attachment #749234 - Flags: review?(jwatt)
What about test_input_range_rounding.html ?
Attached patch PatchSplinter Review
Is that better? :)
Attachment #749234 - Attachment is obsolete: true
Attachment #749234 - Flags: review?(jwatt)
Attachment #749803 - Flags: review?(jwatt)
Attached patch more realistic patch (obsolete) — Splinter Review
I can't be completely sure that this will pass try since there was a huge amount of churn on the range code in the six weeks between v21 and v22 uplift. Might as well get review to make sure that this is ready as soon as possible assuming Try passes.
Assignee: mounir → jwatt
Attachment #749810 - Flags: review?(mounir)
Comment on attachment 749810 [details] [diff] [review]
more realistic patch

Nice - totally just attached that to the wrong bug.
Attachment #749810 - Attachment is obsolete: true
Attachment #749810 - Flags: review?(mounir)
Assignee: jwatt → mounir
Comment on attachment 749803 [details] [diff] [review]
Patch

Yes. :) Thanks!
Attachment #749803 - Flags: review?(jwatt) → review+
https://hg.mozilla.org/integration/mozilla-inbound/rev/64f43c57b69c
Flags: in-testsuite+
Target Milestone: --- → mozilla24
Version: unspecified → Trunk
https://hg.mozilla.org/mozilla-central/rev/64f43c57b69c
Status: ASSIGNED → RESOLVED
Closed: 11 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: