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

Form constraint validation #25447

Merged
merged 1 commit into from Apr 2, 2020
Merged

Form constraint validation #25447

merged 1 commit into from Apr 2, 2020

Conversation

@teapotd
Copy link
Contributor

teapotd commented Jan 6, 2020

It's almost done, there are few things remaining:

r? @jdm


  • ./mach build -d does not report any errors
  • ./mach test-tidy does not report any errors
  • These changes fix #11444
  • There are tests for these changes
@highfive
Copy link

highfive commented Jan 6, 2020

Heads up! This PR modifies the following files:

  • @asajeffrey: components/script/dom/webidls/HTMLButtonElement.webidl, components/script/dom/htmlselectelement.rs, components/script/dom/webidls/HTMLOutputElement.webidl, components/script/textinput.rs, components/script/dom/webidls/HTMLFormElement.webidl and 15 more
  • @KiChjang: components/script/dom/webidls/HTMLButtonElement.webidl, components/script/dom/htmlselectelement.rs, components/script/dom/webidls/HTMLOutputElement.webidl, components/script/textinput.rs, components/script/dom/webidls/HTMLFormElement.webidl and 15 more
@bors-servo
Copy link
Contributor

bors-servo commented Jan 6, 2020

The latest upstream changes (presumably #25424) made this pull request unmergeable. Please resolve the merge conflicts.

@servo-wpt-sync
Copy link
Collaborator

servo-wpt-sync commented Jan 8, 2020

Error syncing changes upstream. Logs saved in error-snapshot-1578481317370.

@bors-servo
Copy link
Contributor

bors-servo commented Jan 9, 2020

The latest upstream changes (presumably #25462) made this pull request unmergeable. Please resolve the merge conflicts.

@servo-wpt-sync
Copy link
Collaborator

servo-wpt-sync commented Jan 10, 2020

Opened new PR for upstreamable changes.

Completed upstream sync of web-platform-test changes at web-platform-tests/wpt#21135.

@teapotd teapotd mentioned this pull request Jan 11, 2020
3 of 4 tasks complete
@servo-wpt-sync
Copy link
Collaborator

servo-wpt-sync commented Jan 11, 2020

Transplanted upstreamable changes to existing PR.

Completed upstream sync of web-platform-test changes at web-platform-tests/wpt#21135.

3 similar comments
@servo-wpt-sync
Copy link
Collaborator

servo-wpt-sync commented Jan 11, 2020

Transplanted upstreamable changes to existing PR.

Completed upstream sync of web-platform-test changes at web-platform-tests/wpt#21135.

@servo-wpt-sync
Copy link
Collaborator

servo-wpt-sync commented Jan 12, 2020

Transplanted upstreamable changes to existing PR.

Completed upstream sync of web-platform-test changes at web-platform-tests/wpt#21135.

@servo-wpt-sync
Copy link
Collaborator

servo-wpt-sync commented Jan 13, 2020

Transplanted upstreamable changes to existing PR.

Completed upstream sync of web-platform-test changes at web-platform-tests/wpt#21135.

@teapotd teapotd marked this pull request as ready for review Jan 13, 2020
@teapotd
Copy link
Contributor Author

teapotd commented Jan 13, 2020

I think it's ready for a review. Some notes:

  • A few rangeUnderflow and rangeOverflow tests don't pass due to #25493, should be fixed by #25494
  • I hardcoded JSREG_UNICODE flag for now, because there are some issues with mozjs upgrade (servo/mozjs#224, servo/rust-mozjs#493)
  • The stepMismatch verification is problematic due to rounding errors, see whatwg/html#5207. Firefox parses values as decimals to avoid those issues. Current WPT tests also seem to expect exact precision. I think we should go with decimals as well, but it would require adding a crate and changes to value-as-number conversion. I went with epsilon comparison for now.
  • Test for nameless radio button in html/semantics/forms/constraints/form-validation-validity-valueMissing.html is inconsistent with spec, see whatwg/html#5202 (comment).

@jdm Let me know what you think!

@teapotd teapotd changed the title [WIP] Form constraint validation Form constraint validation Jan 13, 2020
@servo-wpt-sync
Copy link
Collaborator

servo-wpt-sync commented Jan 13, 2020

PR title changed; changed existing PR.

Completed upstream sync of web-platform-test changes at web-platform-tests/wpt#21135.

Copy link
Member

jdm left a comment

Great work! I found this code to be quite readable. Thanks for adding all of the useful specification links!

components/script/dom/validation.rs Outdated Show resolved Hide resolved
JS_ClearPendingException(*cx);
}

!ok || !rval.is_null()

This comment has been minimized.

@jdm

jdm Jan 23, 2020

Member

Don't we want ok && !rval.is_null()? Am I misunderstanding what JS_ExecuteRegExpNoStatics returns?

This comment has been minimized.

@teapotd

teapotd Jan 23, 2020

Author Contributor

It returns false on error. If pattern doesn't match it returns true and set rval to null:

https://github.com/servo/mozjs/blob/b2f83932fe9d361face14efd03f2465b9262e687/mozjs/js/src/builtin/RegExp.cpp#L167-L177

I guess errors should be treated the same way as invalid patterns, i.e. element shouldn't suffer from pattern mismatch.

This comment has been minimized.

@teapotd

teapotd Apr 1, 2020

Author Contributor

I changed it to return Result<bool, ()> instead of bool to make it less confusing and errors are ignored in suffers_from_pattern_mismatch.

bors-servo added a commit to servo/mozjs that referenced this pull request Mar 23, 2020
Add RegExp bindings

I finally got around to finishing [form validation](servo/servo#25447) in Servo and it looks like RegExp bindings got lost after SpiderMonkey update. This PR adds `js/RegExp.h` to `jsglue.hpp`.
bors-servo added a commit to servo/mozjs that referenced this pull request Mar 27, 2020
Add RegExp bindings

I finally got around to finishing [form validation](servo/servo#25447) in Servo and it looks like RegExp bindings got lost after SpiderMonkey update. This PR adds `js/RegExp.h` to `jsglue.hpp`.
@bors-servo
Copy link
Contributor

bors-servo commented Apr 1, 2020

💔 Test failed - status-taskcluster

@jdm
Copy link
Member

jdm commented Apr 2, 2020

@bors-servo
Copy link
Contributor

bors-servo commented Apr 2, 2020

Testing commit 8b21e06 with merge fbd1559...

bors-servo added a commit that referenced this pull request Apr 2, 2020
Form constraint validation

It's almost done, there are few things remaining:

- ~Range underflow, range overflow and step mismatch implementation require #25405~
- ~There are some test failures due to missing DOM parts (#25003)~
- ~`pattern` attribute uses JS regexp syntax. Currently I used regex crate, but it's probably incompatible. Should we use SpiderMonkey's regexp via jsapi?~
- Currently validation errors are reported using `println!`. Are there any better options?
- ~["While the user interface is representing input that the user agent cannot convert to punycode, the control is suffering from bad input."](https://html.spec.whatwg.org/multipage/#e-mail-state-(type%3Demail)%3Asuffering-from-bad-input)~

r? @jdm

---
- [x] `./mach build -d` does not report any errors
- [x] `./mach test-tidy` does not report any errors
- [x] These changes fix #11444
- [x] There are tests for these changes
@bors-servo
Copy link
Contributor

bors-servo commented Apr 2, 2020

💔 Test failed - status-taskcluster

@jdm
Copy link
Member

jdm commented Apr 2, 2020

@bors-servo retry

@bors-servo
Copy link
Contributor

bors-servo commented Apr 2, 2020

🔒 Merge conflict

@bors-servo
Copy link
Contributor

bors-servo commented Apr 2, 2020

The latest upstream changes (presumably #26086) made this pull request unmergeable. Please resolve the merge conflicts.

@servo-wpt-sync
Copy link
Collaborator

servo-wpt-sync commented Apr 2, 2020

Transplanted upstreamable changes to existing PR.

Completed upstream sync of web-platform-test changes at web-platform-tests/wpt#21135.

@jdm
Copy link
Member

jdm commented Apr 2, 2020

@bors-servo
Copy link
Contributor

bors-servo commented Apr 2, 2020

📌 Commit 779552e has been approved by jdm

@bors-servo
Copy link
Contributor

bors-servo commented Apr 2, 2020

Testing commit 779552e with merge a651bad...

@bors-servo
Copy link
Contributor

bors-servo commented Apr 2, 2020

☀️ Test successful - status-taskcluster
Approved by: jdm
Pushing a651bad to master...

@bors-servo bors-servo merged commit a651bad into servo:master Apr 2, 2020
2 checks passed
2 checks passed
Community-TC (pull_request) TaskGroup: success
Details
homu Test successful
Details
@teapotd teapotd deleted the teapotd:form-validation branch Apr 29, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

5 participants
You can’t perform that action at this time.