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

Implement minlength attribute for text inputs #13315

Merged
merged 1 commit into from Sep 21, 2016
Merged

Conversation

@Phrohdoh
Copy link
Contributor

Phrohdoh commented Sep 19, 2016

This is not ready to be merged:
I need help writing tests as I am not familiar with the methods used in the maxlength tests (introduced in tests/unit/script/textinput.rs).

I also need to write the minlength-manual test.

Closes #13313
This depends on #13314 (and includes the commit from it so will need to be rebased once that patch lands).

I am just looking for a quick review to make sure I am on the right path.


  • ./mach build -d does not report any errors
  • ./mach test-tidy does not report any errors
  • These changes fix #13313
  • There are will be tests for these changes

This change is Reviewable

@highfive
Copy link

highfive commented Sep 19, 2016

Thanks for the pull request, and welcome! The Servo team is excited to review your changes, and you should hear from @connorgbrewster (or someone else) soon.

@highfive
Copy link

highfive commented Sep 19, 2016

Heads up! This PR modifies the following files:

  • @KiChjang: components/script/dom/htmltextareaelement.rs, components/script/dom/webidls/HTMLInputElement.webidl, components/script/dom/webidls/HTMLTextAreaElement.webidl, components/script/dom/htmlinputelement.rs, components/script/textinput.rs

<div style="display: none">
<input id="none" />
<input id="negative" type="-5" />

This comment has been minimized.

@emilio

emilio Sep 19, 2016

Member

I think here you want minlength=-5 instead of type?

This comment has been minimized.

@Phrohdoh

Phrohdoh Sep 19, 2016

Author Contributor

I thought the same but just blindly followed the maxlength example.

This comment has been minimized.

@Phrohdoh

Phrohdoh Sep 19, 2016

Author Contributor

I've fixed this locally.

Copy link
Member

cbrewster left a comment

Thanks for doing this!
Overall this looks good to me, just one question.

@@ -479,6 +487,12 @@ impl HTMLInputElementMethods for HTMLInputElement {
// https://html.spec.whatwg.org/multipage/#dom-input-maxlength
make_limited_int_setter!(SetMaxLength, "maxlength", DEFAULT_MAX_LENGTH);

// https://html.spec.whatwg.org/multipage/#dom-input-minlength // This doesn't exist?

This comment has been minimized.

@cbrewster

cbrewster Sep 19, 2016

Member

The spec link exists for me.

let minGtMax = document.getElementById("min-greater-than-max");
assert_equals(minGtMax.minLength, 0);
assert_equals(minGtMax.minLength, minGtMax.maxLength);
}, "A minLength value greater than maxLength results in minLength = maxLength = 0");

This comment has been minimized.

@cbrewster

cbrewster Sep 19, 2016

Member

Where is this logic happening? I might just be missing it.

This comment has been minimized.

@Phrohdoh

Phrohdoh Sep 19, 2016

Author Contributor

I have not implemented this yet because TextInput::replace_selection(DOMString) is quite complex and I haven't worked out what it will need to look like (after doing this the rest should come easily).

This comment has been minimized.

@cbrewster

cbrewster Sep 19, 2016

Member

Ok, we can leave the test expectation as failing if you want to open an issue for it.

@cbrewster
Copy link
Member

cbrewster commented Sep 19, 2016

Also it looks like there are some unit tests that need to be updated after these changes.

@cbrewster
Copy link
Member

cbrewster commented Sep 19, 2016

Ahh also, we should actually enforce the min length and add unit tests. (Sorry for missing that, its a Monday).

relevant code: components/script/textinput.rs

@Phrohdoh
Copy link
Contributor Author

Phrohdoh commented Sep 19, 2016

Indeed tests are desired, but

I need help writing tests as I am not familiar with the methods used in the maxlength tests

Regarding enforcing minlength @jdm and I spoke about that on IRC today and I believe the consensus was to only enforce this on form validation.

If you have a greater-than-zero minLength editing the text becomes unnecessarily complex once the current content's length is equal to minLength.

Is form validation not built into Servo at all at this point?

@cbrewster
Copy link
Member

cbrewster commented Sep 20, 2016

@Phrohdoh fair enough. I believe this is the latest efforts on form validation #10169. So I believe you won't need to worry about that right now.

If you squash this, fix those comments, and update the unit tests (so they compile), we should be good to go!

@jdm
Copy link
Member

jdm commented Sep 20, 2016

Form validation is being tracked in #11444 and should be implemented by a group of students at NCSU this term.

@Phrohdoh
Copy link
Contributor Author

Phrohdoh commented Sep 20, 2016

Excellent, I will try to get the unit tests working again this afternoon!

@Phrohdoh
Copy link
Contributor Author

Phrohdoh commented Sep 20, 2016

@ConnorGBrewster The unit tests have been fixed.

function() {
document.getElementById("assign-non-numeric").minLength = "not-a-number";
assert_equals(document.getElementById("assign-non-numeric").minLength, 0);
}, "Assigning non-numeric to minlength sets minlength to 0");

This comment has been minimized.

@jdm

jdm Sep 20, 2016

Member

As mentioned on IRC, this behaviour cannot be exposed to the web since it's not part of the specification.

This comment has been minimized.

@jdm

jdm Sep 20, 2016

Member

Sorry, misread the code. Ignore this comment.

@cbrewster
Copy link
Member

cbrewster commented Sep 20, 2016

Thank you!
@bors-servo r+

@bors-servo
Copy link
Contributor

bors-servo commented Sep 20, 2016

📌 Commit 54e83bd has been approved by ConnorGBrewster

@bors-servo
Copy link
Contributor

bors-servo commented Sep 20, 2016

Testing commit 54e83bd with merge b0da5d5...

bors-servo added a commit that referenced this pull request Sep 20, 2016
…rewster

Implement minlength attribute for text inputs

<!-- Please describe your changes on the following line: -->
**This is not ready to be merged:
I need help writing tests as I am not familiar with the methods used in the `maxlength` tests (introduced in  tests/unit/script/textinput.rs).**

I also need to write the `minlength-manual` test.

Closes #13313
This depends on #13314 (and includes the commit from it so will need to be rebased once that patch lands).

I am just looking for a quick review to make sure I am on the right path.

---
<!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: -->
- [X] `./mach build -d` does not report any errors
- [X] `./mach test-tidy` does not report any errors
- [X] These changes fix #13313

<!-- Either: -->
- [X] There ~~are~~ *will be* tests for these changes

<!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/13315)
<!-- Reviewable:end -->
@bors-servo
Copy link
Contributor

bors-servo commented Sep 20, 2016

💔 Test failed - linux-rel

@cbrewster
Copy link
Member

cbrewster commented Sep 20, 2016

Looks like some test expectations will need updated

Tests with unexpected results:
  ▶ Unexpected subtest result in /html/dom/interfaces.html:
  └ PASS [expected FAIL] HTMLInputElement interface: attribute minLength

  ▶ Unexpected subtest result in /html/dom/interfaces.html:
  └ PASS [expected FAIL] HTMLInputElement interface: document.createElement("input") must inherit property "minLength" with the proper type (22)

  ▶ Unexpected subtest result in /html/dom/interfaces.html:
  └ PASS [expected FAIL] HTMLInputElement interface: createInput("text") must inherit property "minLength" with the proper type (22)

  ▶ Unexpected subtest result in /html/dom/interfaces.html:
  └ PASS [expected FAIL] HTMLInputElement interface: createInput("hidden") must inherit property "minLength" with the proper type (22)

  ▶ Unexpected subtest result in /html/dom/interfaces.html:
  └ PASS [expected FAIL] HTMLInputElement interface: createInput("search") must inherit property "minLength" with the proper type (22)

  ▶ Unexpected subtest result in /html/dom/interfaces.html:
  └ PASS [expected FAIL] HTMLInputElement interface: createInput("tel") must inherit property "minLength" with the proper type (22)

  ▶ Unexpected subtest result in /html/dom/interfaces.html:
  └ PASS [expected FAIL] HTMLInputElement interface: createInput("url") must inherit property "minLength" with the proper type (22)

  ▶ Unexpected subtest result in /html/dom/interfaces.html:
  └ PASS [expected FAIL] HTMLInputElement interface: createInput("email") must inherit property "minLength" with the proper type (22)

  ▶ Unexpected subtest result in /html/dom/interfaces.html:
  └ PASS [expected FAIL] HTMLInputElement interface: createInput("password") must inherit property "minLength" with the proper type (22)

  ▶ Unexpected subtest result in /html/dom/interfaces.html:
  └ PASS [expected FAIL] HTMLInputElement interface: createInput("date") must inherit property "minLength" with the proper type (22)

  ▶ Unexpected subtest result in /html/dom/interfaces.html:
  └ PASS [expected FAIL] HTMLInputElement interface: createInput("month") must inherit property "minLength" with the proper type (22)

  ▶ Unexpected subtest result in /html/dom/interfaces.html:
  └ PASS [expected FAIL] HTMLInputElement interface: createInput("week") must inherit property "minLength" with the proper type (22)

  ▶ Unexpected subtest result in /html/dom/interfaces.html:
  └ PASS [expected FAIL] HTMLInputElement interface: createInput("time") must inherit property "minLength" with the proper type (22)

  ▶ Unexpected subtest result in /html/dom/interfaces.html:
  └ PASS [expected FAIL] HTMLInputElement interface: createInput("datetime-local") must inherit property "minLength" with the proper type (22)

  ▶ Unexpected subtest result in /html/dom/interfaces.html:
  └ PASS [expected FAIL] HTMLInputElement interface: createInput("number") must inherit property "minLength" with the proper type (22)

  ▶ Unexpected subtest result in /html/dom/interfaces.html:
  └ PASS [expected FAIL] HTMLInputElement interface: createInput("range") must inherit property "minLength" with the proper type (22)

  ▶ Unexpected subtest result in /html/dom/interfaces.html:
  └ PASS [expected FAIL] HTMLInputElement interface: createInput("color") must inherit property "minLength" with the proper type (22)

  ▶ Unexpected subtest result in /html/dom/interfaces.html:
  └ PASS [expected FAIL] HTMLInputElement interface: createInput("checkbox") must inherit property "minLength" with the proper type (22)

  ▶ Unexpected subtest result in /html/dom/interfaces.html:
  └ PASS [expected FAIL] HTMLInputElement interface: createInput("radio") must inherit property "minLength" with the proper type (22)

  ▶ Unexpected subtest result in /html/dom/interfaces.html:
  └ PASS [expected FAIL] HTMLInputElement interface: createInput("file") must inherit property "minLength" with the proper type (22)

  ▶ Unexpected subtest result in /html/dom/interfaces.html:
  └ PASS [expected FAIL] HTMLInputElement interface: createInput("submit") must inherit property "minLength" with the proper type (22)

  ▶ Unexpected subtest result in /html/dom/interfaces.html:
  └ PASS [expected FAIL] HTMLInputElement interface: createInput("image") must inherit property "minLength" with the proper type (22)

  ▶ Unexpected subtest result in /html/dom/interfaces.html:
  └ PASS [expected FAIL] HTMLInputElement interface: createInput("reset") must inherit property "minLength" with the proper type (22)

  ▶ Unexpected subtest result in /html/dom/interfaces.html:
  └ PASS [expected FAIL] HTMLInputElement interface: createInput("button") must inherit property "minLength" with the proper type (22)
@KiChjang
Copy link
Member

KiChjang commented Sep 20, 2016

@bors-servo r=ConnorGBrewster

@bors-servo
Copy link
Contributor

bors-servo commented Sep 20, 2016

📌 Commit 90cd009 has been approved by ConnorGBrewster

@bors-servo
Copy link
Contributor

bors-servo commented Sep 21, 2016

Testing commit 90cd009 with merge 7320195...

bors-servo added a commit that referenced this pull request Sep 21, 2016
…rewster

Implement minlength attribute for text inputs

<!-- Please describe your changes on the following line: -->
**This is not ready to be merged:
I need help writing tests as I am not familiar with the methods used in the `maxlength` tests (introduced in  tests/unit/script/textinput.rs).**

I also need to write the `minlength-manual` test.

Closes #13313
This depends on #13314 (and includes the commit from it so will need to be rebased once that patch lands).

I am just looking for a quick review to make sure I am on the right path.

---
<!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: -->
- [X] `./mach build -d` does not report any errors
- [X] `./mach test-tidy` does not report any errors
- [X] These changes fix #13313

<!-- Either: -->
- [X] There ~~are~~ *will be* tests for these changes

<!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/13315)
<!-- Reviewable:end -->
@bors-servo
Copy link
Contributor

bors-servo commented Sep 21, 2016

💔 Test failed - linux-rel

@Phrohdoh
Copy link
Contributor Author

Phrohdoh commented Sep 21, 2016

Well.. that is an odd failure.

I thought I had fixed this.

Looks like I need to update the proto.
If someone could point me in the right direction that would be much appreciated.

Ran 7569 tests finished in 1025.0 seconds.
  • 7568 ran as expected. 1678 tests skipped.
  • 1 tests had unexpected subtest results

Tests with unexpected results:
  ▶ Unexpected subtest result in /html/dom/interfaces.html:
  │ FAIL [expected PASS] HTMLTextAreaElement interface: document.createElement("textarea") must inherit property "minLength" with the proper type (8)
  │   → assert_inherits: property "minLength" not found in prototype chain
  │ 
  │ IdlInterface.prototype.test_interface_of/<@http://web-platform.test:8000/resources/idlharness.js:1549:25
  │ Test.prototype.step@http://web-platform.test:8000/resources/testharness.js:1401:20
  │ test@http://web-platform.test:8000/resources/testharness.js:501:9
  │ IdlInterface.prototype.test_interface_of@http://web-platform.test:8000/resources/idlharness.js:1543:13
  │ IdlInterface.prototype.test_object@http://web-platform.test:8000/resources/idlharness.js:1455:9
  │ IdlArray.prototype.test/<@http://web-platform.test:8000/resources/idlharness.js:403:17
  │ IdlArray.prototype.test@http://web-platform.test:8000/resources/idlharness.js:401:13
  └ window.onload@http://web-platform.test:8000/html/dom/interfaces.html:208:3

  ▶ Unexpected subtest result in /html/dom/interfaces.html:
  │ FAIL [expected PASS] HTMLTextAreaElement interface: attribute minLength
  │   → assert_true: The prototype object must have a property "minLength" expected true got false
  │ 
  │ IdlInterface.prototype.test_member_attribute/<@http://web-platform.test:8000/resources/idlharness.js:1158:13
  │ Test.prototype.step@http://web-platform.test:8000/resources/testharness.js:1401:20
  │ test@http://web-platform.test:8000/resources/testharness.js:501:9
  │ IdlInterface.prototype.test_member_attribute@http://web-platform.test:8000/resources/idlharness.js:1113:5
  │ IdlInterface.prototype.test_members@http://web-platform.test:8000/resources/idlharness.js:1395:17
  │ IdlInterface.prototype.test@http://web-platform.test:8000/resources/idlharness.js:740:5
  │ IdlArray.prototype.test@http://web-platform.test:8000/resources/idlharness.js:398:9
  └ window.onload@http://web-platform.test:8000/html/dom/interfaces.html:208:3
@jdm
Copy link
Member

jdm commented Sep 21, 2016

You only changed HTMLInputElement; those failure relate to HTMLTextAreaElement.

@Phrohdoh
Copy link
Contributor Author

Phrohdoh commented Sep 21, 2016

Indeed but these are not the same errors.
These errors fail but were expected to pass while the previous ones passed but expected to fail.
I do not know where the prototype definitions live so that I may modify them.

@jdm
Copy link
Member

jdm commented Sep 21, 2016

@bors-servo: r=ConnorGBrewster

@bors-servo
Copy link
Contributor

bors-servo commented Sep 21, 2016

📌 Commit 2cb5adf has been approved by ConnorGBrewster

bors-servo added a commit that referenced this pull request Sep 21, 2016
…rewster

Implement minlength attribute for text inputs

<!-- Please describe your changes on the following line: -->
**This is not ready to be merged:
I need help writing tests as I am not familiar with the methods used in the `maxlength` tests (introduced in  tests/unit/script/textinput.rs).**

I also need to write the `minlength-manual` test.

Closes #13313
This depends on #13314 (and includes the commit from it so will need to be rebased once that patch lands).

I am just looking for a quick review to make sure I am on the right path.

---
<!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: -->
- [X] `./mach build -d` does not report any errors
- [X] `./mach test-tidy` does not report any errors
- [X] These changes fix #13313

<!-- Either: -->
- [X] There ~~are~~ *will be* tests for these changes

<!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/13315)
<!-- Reviewable:end -->
@bors-servo
Copy link
Contributor

bors-servo commented Sep 21, 2016

Testing commit 2cb5adf with merge c0bcd6f...

@bors-servo
Copy link
Contributor

bors-servo commented Sep 21, 2016

@bors-servo bors-servo merged commit 2cb5adf into servo:master Sep 21, 2016
2 of 3 checks passed
2 of 3 checks passed
continuous-integration/appveyor/pr AppVeyor build failed
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
homu Test successful
Details
@Phrohdoh
Copy link
Contributor Author

Phrohdoh commented Sep 21, 2016

Awesome! 🎉

@Phrohdoh Phrohdoh deleted the Phrohdoh:textinput-minlength-13313 branch Sep 21, 2016
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.

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