Auto merge of #24626 - glowe:issue-21810/improve-validation-methods, r=jdm

Issue 21810/improve validation methods

<!-- Please describe your changes on the following line: -->
This is a start at addressing #21810. I'm putting these changes out early to get some feedback on the following items:

1. I added unit tests for the validation methods mentioned in #21810, because I couldn't tell whether any of the existing WPT tests covered them. Are these tests worthwhile? Are any of them unnecessary?
2. I changed the implementation for `is_valid_floating_point_number_string` so that it passed the tests. The previous version of the function wasn't restrictive enough (it allowed certain whitespace characters before the number string).
3. I changed the catch-all condition in `htmlinputelement.rs` to account for the remaining input types that don't have a value sanitization algorithm. This last change seems good to me since we won't be able to add a new input type without adding it to the case and checking the spec for an algorithm.
---
<!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `___` with appropriate data: -->
- [x] `./mach build -d` does not report any errors
- [x] `./mach test-tidy` does not report any errors
- [x] These changes fix #21810

<!-- Either: -->
- [x] There are tests for these changes

<!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.-->

<!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->
This commit is contained in:
bors-servo 2019-12-03 13:11:22 -05:00 committed by GitHub
commit 7ba88e8237
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 21 additions and 8 deletions

View file

@ -659568,7 +659568,7 @@
"testharness"
],
"html/semantics/forms/the-input-element/number.html": [
"64868f02efca707cfe88a51e9bd91574dfbcaad9",
"7d93f208985d305d46324d0ecf34e8c4ff2ad361",
"testharness"
],
"html/semantics/forms/the-input-element/password.html": [

View file

@ -35,7 +35,11 @@
{value: "+1", expected: "", testname: "value = +1"},
{value: "+", expected: "", testname: "value = '+'"},
{value: "-", expected: "", testname: "value = '-'"},
{value: " 1", expected: "", testname: "value with a leading whitespace"},
{value: "\t1", expected: "", testname: "value with a leading tab"},
{value: "\n1", expected: "", testname: "value with a leading newline"},
{value: "\f1", expected: "", testname: "value with a leading form feed"},
{value: "\r1", expected: "", testname: "value with a leading carriage return"},
{value: " 1", expected: "", testname: "value with a leading space"},
{value: "1trailing junk", expected: "", testname: "value = 1trailing junk"}
];
for (var i = 0; i < numbers.length; i++) {