Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve dirtying algorithm for form validation tests #2181

Merged
merged 1 commit into from
Oct 2, 2015
Merged

Improve dirtying algorithm for form validation tests #2181

merged 1 commit into from
Oct 2, 2015

Conversation

cvrebert
Copy link
Contributor

The set_dirty() function in html/semantics/forms/constraints/support/validator.js makes an empty selection using setSelectionRange() and then performs document.execCommand("Delete"), apparently assuming that this is a no-op.

At least in Chrome, that's not the case! Chrome deletes the last character in the input!

As document.execCommand() is notoriously not well-standardized, unrelated tests should avoid relying on its behavior in edge cases (such as empty selections).
So the new strategy is to add an extra character to the input's value, select this character, and then delete this character.

@hoppipolla-critic-bot
Copy link

Critic review: https://critic.hoppipolla.co.uk/r/5832

This is an external review system which you may optionally use for the code review of your pull request.

In order to help critic track your changes, please do not make in-place history rewrites (e.g. via git rebase -i or git commit --amend) when updating this pull request.

@cvrebert
Copy link
Contributor Author

CCing @Ms2ger on the advice of @sideshowbarker

@cvrebert
Copy link
Contributor Author

cvrebert commented Oct 1, 2015

@zcorpan Replied to your comment.

@zcorpan
Copy link
Member

zcorpan commented Oct 1, 2015

OK LGTM. Can you rebase?

The set_dirty() function in html/semantics/forms/constraints/support/validator.js
makes an empty selection using setSelectionRange() and then
performs document.execCommand("Delete"), apparently assuming
that this is a no-op.

At least in Chrome, that's not the case!
Chrome deletes the last character in the input!

As document.execCommand() is notoriously not well-standardized, unrelated tests
should avoid relying on its behavior in edge cases (such as empty selections).
So the new strategy is to add an extra character to the input's value,
select this character, and then delete this character.
@cvrebert
Copy link
Contributor Author

cvrebert commented Oct 1, 2015

@zcorpan Rebased.

zcorpan added a commit that referenced this pull request Oct 2, 2015
Improve dirtying algorithm for form validation tests
@zcorpan zcorpan merged commit 6acb690 into web-platform-tests:master Oct 2, 2015
@cvrebert cvrebert deleted the dirtying branch October 2, 2015 07:02
@cvrebert cvrebert added the html label Oct 9, 2015
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.

None yet

3 participants