Commit d4fc9ba5 authored by Kei Nakashima's avatar Kei Nakashima Committed by Commit Bot

Removed willValidate check from ListedElement::CustomError

This change is for following the HTML standard.
Accordingly, added willValidate check to validationMessage.
It's for keeping the current behavior of validationMessage after this CL.

Bug: 1038224
Change-Id: Ied5f6bcdc5eda495de6d3925435e73d856b23b15
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2015912
Commit-Queue: Kei Nakashima <keinakashima@google.com>
Reviewed-by: default avatarKent Tamura <tkent@chromium.org>
Reviewed-by: default avatarYuki Shiino <yukishiino@chromium.org>
Cr-Commit-Position: refs/heads/master@{#735726}
parent 18784145
...@@ -227,7 +227,7 @@ bool HTMLInputElement::RangeOverflow() const { ...@@ -227,7 +227,7 @@ bool HTMLInputElement::RangeOverflow() const {
} }
String HTMLInputElement::validationMessage() const { String HTMLInputElement::validationMessage() const {
if (CustomError()) if (willValidate() && CustomError())
return CustomValidationMessage(); return CustomValidationMessage();
return input_type_->ValidationMessage(*input_type_view_).first; return input_type_->ValidationMessage(*input_type_view_).first;
......
...@@ -314,8 +314,7 @@ void ListedElement::UpdateWillValidateCache() { ...@@ -314,8 +314,7 @@ void ListedElement::UpdateWillValidateCache() {
} }
bool ListedElement::CustomError() const { bool ListedElement::CustomError() const {
return ToHTMLElement().willValidate() && return !custom_validation_message_.IsEmpty();
!custom_validation_message_.IsEmpty();
} }
bool ListedElement::HasBadInput() const { bool ListedElement::HasBadInput() const {
...@@ -371,7 +370,9 @@ void ListedElement::SetCustomValidationMessage(const String& message) { ...@@ -371,7 +370,9 @@ void ListedElement::SetCustomValidationMessage(const String& message) {
} }
String ListedElement::validationMessage() const { String ListedElement::validationMessage() const {
return CustomError() ? custom_validation_message_ : String(); return ToHTMLElement().willValidate() && CustomError()
? custom_validation_message_
: String();
} }
String ListedElement::ValidationSubMessage() const { String ListedElement::ValidationSubMessage() const {
......
This is a testharness.js-based test.
FAIL [input] The validity.customError must be true if the custom validity error message is not empty assert_true: The validity.customError attribute should be true, when control is disabled. expected true got false
PASS [input] The validity.customError must be false if the custom validity error message is empty
FAIL [button] The validity.customError must be true if the custom validity error message is not empty assert_true: The validity.customError attribute should be true, when control is disabled. expected true got false
PASS [button] The validity.customError must be false if the custom validity error message is empty
FAIL [select] The validity.customError must be true if the custom validity error message is not empty assert_true: The validity.customError attribute should be true, when control is disabled. expected true got false
PASS [select] The validity.customError must be false i the custom validity error message is empty
FAIL [textarea] The validity.customError must be true if the custom validity error message is not empty assert_true: The validity.customError attribute should be true, when control is disabled. expected true got false
PASS [textarea] The validity.customError must be false if the custom validity error message is empty
Harness: the test ran to completion.
...@@ -31,7 +31,7 @@ var testElements = [ ...@@ -31,7 +31,7 @@ var testElements = [
types: [], types: [],
testData: [ testData: [
{conditions: {message: "My custom error"}, expected: true, name: "[target] The validity.customError must be true if the custom validity error message is not empty"}, {conditions: {message: "My custom error"}, expected: true, name: "[target] The validity.customError must be true if the custom validity error message is not empty"},
{conditions: {message: ""}, expected: false, name: "[target] The validity.customError must be false i the custom validity error message is empty"} {conditions: {message: ""}, expected: false, name: "[target] The validity.customError must be false if the custom validity error message is empty"}
] ]
}, },
{ {
......
This is a testharness.js-based test.
FAIL fieldset setCustomValidity is correct assert_true: expected true got false
Harness: the test ran to completion.
This is a testharness.js-based test.
FAIL output setCustomValidity is correct assert_true: expected true got false
Harness: the test ran to completion.
...@@ -3,10 +3,10 @@ This test checks validity.customError. ...@@ -3,10 +3,10 @@ This test checks validity.customError.
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE". On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
Set some value for customError. Set some value for customError.
PASS customErrorFor("fieldset-set") is false PASS customErrorFor("fieldset-set") is true
PASS customErrorFor("button-set") is true PASS customErrorFor("button-set") is true
PASS customErrorFor("button-button-set") is false PASS customErrorFor("button-button-set") is true
PASS customErrorFor("button-reset-set") is false PASS customErrorFor("button-reset-set") is true
PASS customErrorFor("select-set") is true PASS customErrorFor("select-set") is true
PASS customErrorFor("textarea-set") is true PASS customErrorFor("textarea-set") is true
PASS customErrorFor("input-set") is true PASS customErrorFor("input-set") is true
...@@ -45,37 +45,37 @@ PASS setCustomValidity() threw Failed to execute 'setCustomValidity' on 'HTMLSel ...@@ -45,37 +45,37 @@ PASS setCustomValidity() threw Failed to execute 'setCustomValidity' on 'HTMLSel
PASS setCustomValidity() threw Failed to execute 'setCustomValidity' on 'HTMLTextAreaElement': 1 argument required, but only 0 present. PASS setCustomValidity() threw Failed to execute 'setCustomValidity' on 'HTMLTextAreaElement': 1 argument required, but only 0 present.
PASS setCustomValidity() threw Failed to execute 'setCustomValidity' on 'HTMLInputElement': 1 argument required, but only 0 present. PASS setCustomValidity() threw Failed to execute 'setCustomValidity' on 'HTMLInputElement': 1 argument required, but only 0 present.
PASS setCustomValidity() threw Failed to execute 'setCustomValidity' on 'HTMLInputElement': 1 argument required, but only 0 present. PASS setCustomValidity() threw Failed to execute 'setCustomValidity' on 'HTMLInputElement': 1 argument required, but only 0 present.
PASS customErrorFor("fieldset-many-changes") is false PASS customErrorFor("fieldset-many-changes") is true
PASS customErrorFor("button-many-changes") is true PASS customErrorFor("button-many-changes") is true
PASS customErrorFor("button-button-many-changes") is false PASS customErrorFor("button-button-many-changes") is true
PASS customErrorFor("button-reset-many-changes") is false PASS customErrorFor("button-reset-many-changes") is true
PASS customErrorFor("select-many-changes") is true PASS customErrorFor("select-many-changes") is true
PASS customErrorFor("textarea-many-changes") is true PASS customErrorFor("textarea-many-changes") is true
PASS customErrorFor("input-many-changes") is true PASS customErrorFor("input-many-changes") is true
PASS customErrorFor("input-submit-many-changes") is true PASS customErrorFor("input-submit-many-changes") is true
Set with three arguments. Set with three arguments.
PASS customErrorFor("fieldset-many-changes") is false PASS customErrorFor("fieldset-many-changes") is true
PASS customErrorFor("button-many-changes") is true PASS customErrorFor("button-many-changes") is true
PASS customErrorFor("button-button-many-changes") is false PASS customErrorFor("button-button-many-changes") is true
PASS customErrorFor("button-reset-many-changes") is false PASS customErrorFor("button-reset-many-changes") is true
PASS customErrorFor("select-many-changes") is true PASS customErrorFor("select-many-changes") is true
PASS customErrorFor("textarea-many-changes") is true PASS customErrorFor("textarea-many-changes") is true
PASS customErrorFor("input-many-changes") is true PASS customErrorFor("input-many-changes") is true
PASS customErrorFor("input-submit-many-changes") is true PASS customErrorFor("input-submit-many-changes") is true
Set null. Set null.
PASS customErrorFor("fieldset-many-changes") is false PASS customErrorFor("fieldset-many-changes") is true
PASS customErrorFor("button-many-changes") is true PASS customErrorFor("button-many-changes") is true
PASS customErrorFor("button-button-many-changes") is false PASS customErrorFor("button-button-many-changes") is true
PASS customErrorFor("button-reset-many-changes") is false PASS customErrorFor("button-reset-many-changes") is true
PASS customErrorFor("select-many-changes") is true PASS customErrorFor("select-many-changes") is true
PASS customErrorFor("textarea-many-changes") is true PASS customErrorFor("textarea-many-changes") is true
PASS customErrorFor("input-many-changes") is true PASS customErrorFor("input-many-changes") is true
PASS customErrorFor("input-submit-many-changes") is true PASS customErrorFor("input-submit-many-changes") is true
Set some value, and set undefined. Set some value, and set undefined.
PASS customErrorFor("fieldset-many-changes") is false PASS customErrorFor("fieldset-many-changes") is true
PASS customErrorFor("button-many-changes") is true PASS customErrorFor("button-many-changes") is true
PASS customErrorFor("button-button-many-changes") is false PASS customErrorFor("button-button-many-changes") is true
PASS customErrorFor("button-reset-many-changes") is false PASS customErrorFor("button-reset-many-changes") is true
PASS customErrorFor("select-many-changes") is true PASS customErrorFor("select-many-changes") is true
PASS customErrorFor("textarea-many-changes") is true PASS customErrorFor("textarea-many-changes") is true
PASS customErrorFor("input-many-changes") is true PASS customErrorFor("input-many-changes") is true
......
...@@ -54,10 +54,10 @@ debug('Set some value for customError.'); ...@@ -54,10 +54,10 @@ debug('Set some value for customError.');
v = document.getElementsByName("set"); v = document.getElementsByName("set");
for (i = 0; i < v.length; i++) for (i = 0; i < v.length; i++)
v[i].setCustomValidity("Custom validation message"); v[i].setCustomValidity("Custom validation message");
shouldBeFalse('customErrorFor("fieldset-set")'); shouldBeTrue('customErrorFor("fieldset-set")');
shouldBeTrue('customErrorFor("button-set")'); shouldBeTrue('customErrorFor("button-set")');
shouldBeFalse('customErrorFor("button-button-set")'); shouldBeTrue('customErrorFor("button-button-set")');
shouldBeFalse('customErrorFor("button-reset-set")'); shouldBeTrue('customErrorFor("button-reset-set")');
shouldBeTrue('customErrorFor("select-set")'); shouldBeTrue('customErrorFor("select-set")');
shouldBeTrue('customErrorFor("textarea-set")'); shouldBeTrue('customErrorFor("textarea-set")');
shouldBeTrue('customErrorFor("input-set")'); shouldBeTrue('customErrorFor("input-set")');
...@@ -104,10 +104,10 @@ for (i = 0; i < v.length; i++) { ...@@ -104,10 +104,10 @@ for (i = 0; i < v.length; i++) {
} }
v[i].setCustomValidity(undefined); v[i].setCustomValidity(undefined);
} }
shouldBeFalse('customErrorFor("fieldset-many-changes")'); shouldBeTrue('customErrorFor("fieldset-many-changes")');
shouldBeTrue('customErrorFor("button-many-changes")'); shouldBeTrue('customErrorFor("button-many-changes")');
shouldBeFalse('customErrorFor("button-button-many-changes")'); shouldBeTrue('customErrorFor("button-button-many-changes")');
shouldBeFalse('customErrorFor("button-reset-many-changes")'); shouldBeTrue('customErrorFor("button-reset-many-changes")');
shouldBeTrue('customErrorFor("select-many-changes")'); shouldBeTrue('customErrorFor("select-many-changes")');
shouldBeTrue('customErrorFor("textarea-many-changes")'); shouldBeTrue('customErrorFor("textarea-many-changes")');
shouldBeTrue('customErrorFor("input-many-changes")'); shouldBeTrue('customErrorFor("input-many-changes")');
...@@ -116,10 +116,10 @@ shouldBeTrue('customErrorFor("input-submit-many-changes")'); ...@@ -116,10 +116,10 @@ shouldBeTrue('customErrorFor("input-submit-many-changes")');
debug('Set with three arguments.'); debug('Set with three arguments.');
for (i = 0; i < v.length; i++) for (i = 0; i < v.length; i++)
v[i].setCustomValidity("one", "two", "three"); v[i].setCustomValidity("one", "two", "three");
shouldBeFalse('customErrorFor("fieldset-many-changes")'); shouldBeTrue('customErrorFor("fieldset-many-changes")');
shouldBeTrue('customErrorFor("button-many-changes")'); shouldBeTrue('customErrorFor("button-many-changes")');
shouldBeFalse('customErrorFor("button-button-many-changes")'); shouldBeTrue('customErrorFor("button-button-many-changes")');
shouldBeFalse('customErrorFor("button-reset-many-changes")'); shouldBeTrue('customErrorFor("button-reset-many-changes")');
shouldBeTrue('customErrorFor("select-many-changes")'); shouldBeTrue('customErrorFor("select-many-changes")');
shouldBeTrue('customErrorFor("textarea-many-changes")'); shouldBeTrue('customErrorFor("textarea-many-changes")');
shouldBeTrue('customErrorFor("input-many-changes")'); shouldBeTrue('customErrorFor("input-many-changes")');
...@@ -128,10 +128,10 @@ shouldBeTrue('customErrorFor("input-submit-many-changes")'); ...@@ -128,10 +128,10 @@ shouldBeTrue('customErrorFor("input-submit-many-changes")');
debug('Set null.'); debug('Set null.');
for (i = 0; i < v.length; i++) for (i = 0; i < v.length; i++)
v[i].setCustomValidity(null); v[i].setCustomValidity(null);
shouldBeFalse('customErrorFor("fieldset-many-changes")'); shouldBeTrue('customErrorFor("fieldset-many-changes")');
shouldBeTrue('customErrorFor("button-many-changes")'); shouldBeTrue('customErrorFor("button-many-changes")');
shouldBeFalse('customErrorFor("button-button-many-changes")'); shouldBeTrue('customErrorFor("button-button-many-changes")');
shouldBeFalse('customErrorFor("button-reset-many-changes")'); shouldBeTrue('customErrorFor("button-reset-many-changes")');
shouldBeTrue('customErrorFor("select-many-changes")'); shouldBeTrue('customErrorFor("select-many-changes")');
shouldBeTrue('customErrorFor("textarea-many-changes")'); shouldBeTrue('customErrorFor("textarea-many-changes")');
shouldBeTrue('customErrorFor("input-many-changes")'); shouldBeTrue('customErrorFor("input-many-changes")');
...@@ -142,10 +142,10 @@ for (i = 0; i < v.length; i++) { ...@@ -142,10 +142,10 @@ for (i = 0; i < v.length; i++) {
v[i].setCustomValidity("Custom string"); v[i].setCustomValidity("Custom string");
v[i].setCustomValidity(undefined); v[i].setCustomValidity(undefined);
} }
shouldBeFalse('customErrorFor("fieldset-many-changes")'); shouldBeTrue('customErrorFor("fieldset-many-changes")');
shouldBeTrue('customErrorFor("button-many-changes")'); shouldBeTrue('customErrorFor("button-many-changes")');
shouldBeFalse('customErrorFor("button-button-many-changes")'); shouldBeTrue('customErrorFor("button-button-many-changes")');
shouldBeFalse('customErrorFor("button-reset-many-changes")'); shouldBeTrue('customErrorFor("button-reset-many-changes")');
shouldBeTrue('customErrorFor("select-many-changes")'); shouldBeTrue('customErrorFor("select-many-changes")');
shouldBeTrue('customErrorFor("textarea-many-changes")'); shouldBeTrue('customErrorFor("textarea-many-changes")');
shouldBeTrue('customErrorFor("input-many-changes")'); shouldBeTrue('customErrorFor("input-many-changes")');
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment