Bug 38434 - Use HTML5 number parsing in HTMLProgressElement
Summary: Use HTML5 number parsing in HTMLProgressElement
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: DOM (show other bugs)
Version: 528+ (Nightly build)
Hardware: PC OS X 10.5
: P2 Normal
Assignee: Nobody
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-05-02 07:07 PDT by Yael
Modified: 2010-05-03 11:21 PDT (History)
0 users

See Also:


Attachments
Patch (6.70 KB, patch)
2010-05-02 07:21 PDT, Yael
darin: review-
Details | Formatted Diff | Diff
Patch addressing comment #2. (7.31 KB, patch)
2010-05-03 06:05 PDT, Yael
darin: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Yael 2010-05-02 07:07:33 PDT
Suggested in https://bugs.webkit.org/show_bug.cgi?id=38140#c12 and https://bugs.webkit.org/show_bug.cgi?id=38140#c15 to use the more strict HTML5 parsing code.
Comment 1 Yael 2010-05-02 07:21:07 PDT
Created attachment 54878 [details]
Patch
Comment 2 Darin Adler 2010-05-02 23:50:28 PDT
Comment on attachment 54878 [details]
Patch

> +        Use parseToDoubleForNumberType instead of toDouble.

Where are the tests for the behavior changes this creates? We require tests for any bug fixes. Or is this refactoring only?

> +        Throw an exception when the number is NaN or Infinity.

All the test changes seem to be for this independent half of the patch.

> +    if (isnan(value) || !isfinite(value)) {

The isnan check here is redundant and should be removed. The isfinite function returns false for NAN.

review- because of a lack of test for the HTML5 number parsing change and because the extra check should be omitted.
Comment 3 Yael 2010-05-03 06:05:31 PDT
Created attachment 54920 [details]
Patch addressing comment #2.

Add more tests for parseToDoubleForNumberType and remove redundant isnan().
Comment 4 Darin Adler 2010-05-03 08:19:18 PDT
Comment on attachment 54920 [details]
Patch addressing comment #2.

> +try {
>  p.value = "200A";
> -p.max = 100;
> -shouldBe("p.value", "0");
> -shouldBe("p.max", "100");
> -shouldBe("p.position", "0");
> +} catch (e) {
> +debug(e.message);
> +}

The shouldThrow function is a cleaner way to do a test like this.
Comment 5 Yael 2010-05-03 11:21:42 PDT
Committed r58687: <http://trac.webkit.org/changeset/58687>