Skip to content

Fix "Skip ASCII whitespace within input" test - #35519

Merged
josepharhar merged 4 commits into
web-platform-tests:masterfrom
josepharhar:fixrange
Aug 24, 2022
Merged

josepharhar merged 4 commits into
web-platform-tests:masterfrom
josepharhar:fixrange

Conversation

@josepharhar

Copy link
Copy Markdown
Contributor

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

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"/>

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done, thanks for the suggestion!

function() {
var e = document.getElementById('should_skip_whitespace');
assert_equals(e.value, "50")
assert_equals(e.value, "49")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, let's go back to 50 and update the test description then. Thank you both.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, I changed the value back to " 123" and the expected value to 50, and updated the test description. Does it look good?

@josepharhar
josepharhar merged commit bc183f1 into web-platform-tests:master Aug 24, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants