implement range input sanitization

This commit is contained in:
tigercosmos 2018-01-14 00:01:47 +08:00
parent 525758ea5e
commit b29230bd76
6 changed files with 75 additions and 19 deletions

View file

@ -550473,7 +550473,7 @@
"testharness"
],
"html/semantics/forms/the-input-element/range.html": [
"dd51c517a149c51e939a30dcad5e93f196e35cff",
"e992526fb5f117456a870e52c84eab5a7f4b14ab",
"testharness"
],
"html/semantics/forms/the-input-element/required_attribute.html": [

View file

@ -9,6 +9,6 @@
[range input value equals 100]
expected: FAIL
[range input value equals 2]
[range input value set to an integer]
expected: FAIL

View file

@ -21,9 +21,6 @@
[default value when both min and max attributes are given, while min > max]
expected: FAIL
[The default step scale factor is 1, unless min attribute has non-integer value]
expected: FAIL
[Step scale factor behavior when min attribute has integer value but max attribute is non-integer ]
expected: FAIL

View file

@ -34,6 +34,9 @@
<input type="range" id="stepdown_beyond_min" min=3 max=11 value=6 step=3 />
<input type="range" id="illegal_min_and_max" min="ab" max="f" />
<input type="range" id="illegal_value_and_step" min=0 max=5 value="ppp" step="xyz" />
<input type="range" id="should_skip_whitespace" value=" 123"/>
<input type="range" id="exponent_value1" value=""/>
<input type="range" id="exponent_value2" value=""/>
</div>
<div id="log">
@ -280,6 +283,35 @@
}
);
test(
function() {
var e = document.getElementById('should_skip_whitespace');
assert_equals(e.value, "123")
}, "Skip ASCII whitespace within input", {
"help" : "https://html.spec.whatwg.org/multipage/#best-representation-of-the-number-as-a-floating-point-number"
}
);
test(
function() {
var e = document.getElementById('exponent_value1');
e.value = 1e2;
assert_equals(e.value, "100")
}, "Multiply value by ten raised to the exponentth power with `e`", {
"help" : "https://html.spec.whatwg.org/multipage/#best-representation-of-the-number-as-a-floating-point-number"
}
);
test(
function() {
var e = document.getElementById('exponent_value2');
e.value = 1E2;
assert_equals(e.value, "100")
}, "Multiply value by ten raised to the exponentth power with `E`", {
"help" : "https://html.spec.whatwg.org/multipage/#best-representation-of-the-number-as-a-floating-point-number"
}
);
</script>
</body>