Repository navigation
Fix "Skip ASCII whitespace within input" test - #35519
Conversation
This test sets the range input's value greater than the default maximum, causing the value not to be set properly. By changing it to 50, the value will be set properly. The underlying test of skipping whitespace should still work fine since the value assigned into the input is " 50". This was identified in web-platform-tests/interop#107
| <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="should_skip_whitespace" value=" 50"/> |
There was a problem hiding this comment.
What if we use another value than 50, for example " 49"?
The reason I am concerned about using 50 is that all browsers were getting 50 already when the value was " 123". Therefore, it is not surprising if they still get 50 when you update the value to " 50".
Since this test is about the leading space getting skipped, we need to make sure the browsers are actually parsing this properly and update the value. Therefore, we should test something else than 50, no?
There was a problem hiding this comment.
Done, thanks for the suggestion!
| function() { | ||
| var e = document.getElementById('should_skip_whitespace'); | ||
| assert_equals(e.value, "50") | ||
| assert_equals(e.value, "49") |
There was a problem hiding this comment.
I haven't tried Chrome / Firefox but this is failing in Safari at least. Curious if this is a bug in WebKit or if other engines are aligned.
There was a problem hiding this comment.
This is failing in all 3 browsers actually so the browsers are aligned in not skipping the leading space here.
Seems this test change doesn't align it with major browser engines.
There was a problem hiding this comment.
Yep, chrome also changes " 49" to "50".
I guess that the desired behavior seems sane, but I'm also open to deleting the test since the behavior is already interoperable if that's what people want to do.
I read into this more, and apparently the spec says that we should be passing this test: servo/servo#19761 (comment)
There was a problem hiding this comment.
The reason is this, I think:
The value sanitization algorithm is as follows: If the value of the element is not a valid floating-point number, then set it to the best representation, as a floating-point number, of the default value.
The leading space makes it invalid and therefore the default value ends up being used. So I think what we want is to update the test description only. Or is there another way to read the specification here?
There was a problem hiding this comment.
Ok, let's go back to 50 and update the test description then. Thank you both.
There was a problem hiding this comment.
Ok, I changed the value back to " 123" and the expected value to 50, and updated the test description. Does it look good?
This test sets the range input's value greater than the default maximum,
causing the value not to be set properly. By changing it to 50, the
value will be set properly.
The underlying test of skipping whitespace should still work fine since
the value assigned into the input is " 50".
This was identified in web-platform-tests/interop#107