- Revision
- 286315
- Author
- [email protected]
- Date
- 2021-11-30 12:38:24 -0800 (Tue, 30 Nov 2021)
Log Message
html/semantics/forms/constraints/form-validation-validity-patternMismatch.html WPT test is failing
https://bugs.webkit.org/show_bug.cgi?id=233601
Reviewed by Darin Adler.
LayoutTests/imported/w3c:
Rebaseline WPT test now that it is passing.
* web-platform-tests/html/semantics/forms/constraints/form-validation-validity-patternMismatch-expected.txt:
Source/WebCore:
No new tests, rebaselined existing test.
* html/BaseTextInputType.cpp:
(WebCore::BaseTextInputType::patternMismatch const):
Per https://html.spec.whatwg.org/#attr-input-pattern, when the multiple attribute is present and it
applies to the control, then we should check if the pattern applies to each comma-separated value
in the input (rather than applying the pattern to the whole input).
* html/HTMLInputElement.cpp:
(WebCore::HTMLInputElement::patternMismatch const):
Per https://html.spec.whatwg.org/#dom-validitystate-patternmismatch, patternMismatch should be true
when a control has a value that doesn't satisfy the pattern attribute. We had a bug where we would
only return true if the control was eligible for validation (i.e. not disabled).
Modified Paths
Diff
Modified: trunk/LayoutTests/fast/forms/ValidityState-patternMismatch-expected.txt (286314 => 286315)
--- trunk/LayoutTests/fast/forms/ValidityState-patternMismatch-expected.txt 2021-11-30 20:10:32 UTC (rev 286314)
+++ trunk/LayoutTests/fast/forms/ValidityState-patternMismatch-expected.txt 2021-11-30 20:38:24 UTC (rev 286315)
@@ -66,7 +66,7 @@
PASS patternMismatchFor("invalid-06") is false
PASS patternMismatchFor("invalid-07") is false
PASS patternMismatchFor("invalid-08") is false
-PASS patternMismatchFor("disabled") is false
+PASS patternMismatchFor("disabled") is true
PASS successfullyParsed is true
TEST COMPLETE
Modified: trunk/LayoutTests/fast/forms/ValidityState-patternMismatch.html (286314 => 286315)
--- trunk/LayoutTests/fast/forms/ValidityState-patternMismatch.html 2021-11-30 20:10:32 UTC (rev 286314)
+++ trunk/LayoutTests/fast/forms/ValidityState-patternMismatch.html 2021-11-30 20:38:24 UTC (rev 286315)
@@ -149,7 +149,7 @@
shouldBeFalse('patternMismatchFor("invalid-07")');
shouldBeFalse('patternMismatchFor("invalid-08")');
-shouldBeFalse('patternMismatchFor("disabled")');
+shouldBeTrue('patternMismatchFor("disabled")');
document.body.removeChild(document.getElementById('container'));
</script>
Modified: trunk/LayoutTests/imported/w3c/ChangeLog (286314 => 286315)
--- trunk/LayoutTests/imported/w3c/ChangeLog 2021-11-30 20:10:32 UTC (rev 286314)
+++ trunk/LayoutTests/imported/w3c/ChangeLog 2021-11-30 20:38:24 UTC (rev 286315)
@@ -1,3 +1,14 @@
+2021-11-30 Chris Dumez <[email protected]>
+
+ html/semantics/forms/constraints/form-validation-validity-patternMismatch.html WPT test is failing
+ https://bugs.webkit.org/show_bug.cgi?id=233601
+
+ Reviewed by Darin Adler.
+
+ Rebaseline WPT test now that it is passing.
+
+ * web-platform-tests/html/semantics/forms/constraints/form-validation-validity-patternMismatch-expected.txt:
+
2021-11-30 Andreu Botella <[email protected]>
Constructing a FormData from a form can lead to entries with lone surrogates
Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/html/semantics/forms/constraints/form-validation-validity-patternMismatch-expected.txt (286314 => 286315)
--- trunk/LayoutTests/imported/w3c/web-platform-tests/html/semantics/forms/constraints/form-validation-validity-patternMismatch-expected.txt 2021-11-30 20:10:32 UTC (rev 286314)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/html/semantics/forms/constraints/form-validation-validity-patternMismatch-expected.txt 2021-11-30 20:38:24 UTC (rev 286315)
@@ -3,78 +3,78 @@
PASS [INPUT in TEXT status] The value attibute is empty string
PASS [INPUT in TEXT status] The value attribute matches the pattern attribute
PASS [INPUT in TEXT status] The value(ABC) in unicode attribute matches the pattern attribute
-FAIL [INPUT in TEXT status] The value attribute mismatches the pattern attribute assert_true: The validity.patternMismatch should be true, when control is disabled. expected true got false
-FAIL [INPUT in TEXT status] The value attribute mismatches the pattern attribute even when a subset matches assert_true: The validity.patternMismatch should be true, when control is disabled. expected true got false
+PASS [INPUT in TEXT status] The value attribute mismatches the pattern attribute
+PASS [INPUT in TEXT status] The value attribute mismatches the pattern attribute even when a subset matches
PASS [INPUT in TEXT status] Invalid regular _expression_ gets ignored
PASS [INPUT in TEXT status] The pattern attribute tries to escape a group
PASS [INPUT in TEXT status] The pattern attribute uses Unicode features
PASS [INPUT in TEXT status] The value attribute matches _javascript_-specific regular _expression_
-FAIL [INPUT in TEXT status] The value attribute mismatches _javascript_-specific regular _expression_ assert_true: The validity.patternMismatch should be true, when control is disabled. expected true got false
+PASS [INPUT in TEXT status] The value attribute mismatches _javascript_-specific regular _expression_
PASS [INPUT in SEARCH status] The pattern attribute is not set
PASS [INPUT in SEARCH status] The value attibute is empty string
PASS [INPUT in SEARCH status] The value attribute matches the pattern attribute
PASS [INPUT in SEARCH status] The value(ABC) in unicode attribute matches the pattern attribute
-FAIL [INPUT in SEARCH status] The value attribute mismatches the pattern attribute assert_true: The validity.patternMismatch should be true, when control is disabled. expected true got false
-FAIL [INPUT in SEARCH status] The value attribute mismatches the pattern attribute even when a subset matches assert_true: The validity.patternMismatch should be true, when control is disabled. expected true got false
+PASS [INPUT in SEARCH status] The value attribute mismatches the pattern attribute
+PASS [INPUT in SEARCH status] The value attribute mismatches the pattern attribute even when a subset matches
PASS [INPUT in SEARCH status] Invalid regular _expression_ gets ignored
PASS [INPUT in SEARCH status] The pattern attribute tries to escape a group
PASS [INPUT in SEARCH status] The pattern attribute uses Unicode features
PASS [INPUT in SEARCH status] The value attribute matches _javascript_-specific regular _expression_
-FAIL [INPUT in SEARCH status] The value attribute mismatches _javascript_-specific regular _expression_ assert_true: The validity.patternMismatch should be true, when control is disabled. expected true got false
+PASS [INPUT in SEARCH status] The value attribute mismatches _javascript_-specific regular _expression_
PASS [INPUT in TEL status] The pattern attribute is not set
PASS [INPUT in TEL status] The value attibute is empty string
PASS [INPUT in TEL status] The value attribute matches the pattern attribute
PASS [INPUT in TEL status] The value(ABC) in unicode attribute matches the pattern attribute
-FAIL [INPUT in TEL status] The value attribute mismatches the pattern attribute assert_true: The validity.patternMismatch should be true, when control is disabled. expected true got false
-FAIL [INPUT in TEL status] The value attribute mismatches the pattern attribute even when a subset matches assert_true: The validity.patternMismatch should be true, when control is disabled. expected true got false
+PASS [INPUT in TEL status] The value attribute mismatches the pattern attribute
+PASS [INPUT in TEL status] The value attribute mismatches the pattern attribute even when a subset matches
PASS [INPUT in TEL status] Invalid regular _expression_ gets ignored
PASS [INPUT in TEL status] The pattern attribute tries to escape a group
PASS [INPUT in TEL status] The pattern attribute uses Unicode features
PASS [INPUT in TEL status] The value attribute matches _javascript_-specific regular _expression_
-FAIL [INPUT in TEL status] The value attribute mismatches _javascript_-specific regular _expression_ assert_true: The validity.patternMismatch should be true, when control is disabled. expected true got false
+PASS [INPUT in TEL status] The value attribute mismatches _javascript_-specific regular _expression_
PASS [INPUT in URL status] The pattern attribute is not set
PASS [INPUT in URL status] The value attibute is empty string
PASS [INPUT in URL status] The value attribute matches the pattern attribute
PASS [INPUT in URL status] The value(ABC) in unicode attribute matches the pattern attribute
-FAIL [INPUT in URL status] The value attribute mismatches the pattern attribute assert_true: The validity.patternMismatch should be true, when control is disabled. expected true got false
-FAIL [INPUT in URL status] The value attribute mismatches the pattern attribute even when a subset matches assert_true: The validity.patternMismatch should be true, when control is disabled. expected true got false
+PASS [INPUT in URL status] The value attribute mismatches the pattern attribute
+PASS [INPUT in URL status] The value attribute mismatches the pattern attribute even when a subset matches
PASS [INPUT in URL status] Invalid regular _expression_ gets ignored
PASS [INPUT in URL status] The pattern attribute tries to escape a group
PASS [INPUT in URL status] The pattern attribute uses Unicode features
PASS [INPUT in URL status] The value attribute matches _javascript_-specific regular _expression_
-FAIL [INPUT in URL status] The value attribute mismatches _javascript_-specific regular _expression_ assert_true: The validity.patternMismatch should be true, when control is disabled. expected true got false
+PASS [INPUT in URL status] The value attribute mismatches _javascript_-specific regular _expression_
PASS [INPUT in EMAIL status] The pattern attribute is not set
PASS [INPUT in EMAIL status] The value attibute is empty string
PASS [INPUT in EMAIL status] The value attribute matches the pattern attribute
PASS [INPUT in EMAIL status] The value(ABC) in unicode attribute matches the pattern attribute
-FAIL [INPUT in EMAIL status] The value attribute mismatches the pattern attribute assert_true: The validity.patternMismatch should be true, when control is disabled. expected true got false
-FAIL [INPUT in EMAIL status] The value attribute mismatches the pattern attribute even when a subset matches assert_true: The validity.patternMismatch should be true, when control is disabled. expected true got false
+PASS [INPUT in EMAIL status] The value attribute mismatches the pattern attribute
+PASS [INPUT in EMAIL status] The value attribute mismatches the pattern attribute even when a subset matches
PASS [INPUT in EMAIL status] Invalid regular _expression_ gets ignored
PASS [INPUT in EMAIL status] The pattern attribute tries to escape a group
PASS [INPUT in EMAIL status] The pattern attribute uses Unicode features
PASS [INPUT in EMAIL status] The value attribute matches _javascript_-specific regular _expression_
-FAIL [INPUT in EMAIL status] The value attribute mismatches _javascript_-specific regular _expression_ assert_true: The validity.patternMismatch should be true, when control is disabled. expected true got false
+PASS [INPUT in EMAIL status] The value attribute mismatches _javascript_-specific regular _expression_
PASS [INPUT in PASSWORD status] The pattern attribute is not set
PASS [INPUT in PASSWORD status] The value attibute is empty string
PASS [INPUT in PASSWORD status] The value attribute matches the pattern attribute
PASS [INPUT in PASSWORD status] The value(ABC) in unicode attribute matches the pattern attribute
-FAIL [INPUT in PASSWORD status] The value attribute mismatches the pattern attribute assert_true: The validity.patternMismatch should be true, when control is disabled. expected true got false
-FAIL [INPUT in PASSWORD status] The value attribute mismatches the pattern attribute even when a subset matches assert_true: The validity.patternMismatch should be true, when control is disabled. expected true got false
+PASS [INPUT in PASSWORD status] The value attribute mismatches the pattern attribute
+PASS [INPUT in PASSWORD status] The value attribute mismatches the pattern attribute even when a subset matches
PASS [INPUT in PASSWORD status] Invalid regular _expression_ gets ignored
PASS [INPUT in PASSWORD status] The pattern attribute tries to escape a group
PASS [INPUT in PASSWORD status] The pattern attribute uses Unicode features
PASS [INPUT in PASSWORD status] The value attribute matches _javascript_-specific regular _expression_
-FAIL [INPUT in PASSWORD status] The value attribute mismatches _javascript_-specific regular _expression_ assert_true: The validity.patternMismatch should be true, when control is disabled. expected true got false
+PASS [INPUT in PASSWORD status] The value attribute mismatches _javascript_-specific regular _expression_
PASS [INPUT in EMAIL status] The pattern attribute is not set, if multiple is present
PASS [INPUT in EMAIL status] The value attibute is empty string, if multiple is present
-FAIL [INPUT in EMAIL status] The value attribute matches the pattern attribute, if multiple is present assert_false: The validity.patternMismatch should be false. expected false got true
-FAIL [INPUT in EMAIL status] The value(ABC) in unicode attribute matches the pattern attribute, if multiple is present assert_false: The validity.patternMismatch should be false. expected false got true
-FAIL [INPUT in EMAIL status] The value attribute mismatches the pattern attribute, if multiple is present assert_true: The validity.patternMismatch should be true, when control is disabled. expected true got false
-FAIL [INPUT in EMAIL status] The value attribute mismatches the pattern attribute even when a subset matches, if multiple is present assert_true: The validity.patternMismatch should be true, when control is disabled. expected true got false
+PASS [INPUT in EMAIL status] The value attribute matches the pattern attribute, if multiple is present
+PASS [INPUT in EMAIL status] The value(ABC) in unicode attribute matches the pattern attribute, if multiple is present
+PASS [INPUT in EMAIL status] The value attribute mismatches the pattern attribute, if multiple is present
+PASS [INPUT in EMAIL status] The value attribute mismatches the pattern attribute even when a subset matches, if multiple is present
PASS [INPUT in EMAIL status] Invalid regular _expression_ gets ignored, if multiple is present
PASS [INPUT in EMAIL status] The pattern attribute tries to escape a group, if multiple is present
-FAIL [INPUT in EMAIL status] The pattern attribute uses Unicode features, if multiple is present assert_false: The validity.patternMismatch should be false. expected false got true
-FAIL [INPUT in EMAIL status] The value attribute matches _javascript_-specific regular _expression_, if multiple is present assert_false: The validity.patternMismatch should be false. expected false got true
-FAIL [INPUT in EMAIL status] The value attribute mismatches _javascript_-specific regular _expression_, if multiple is present assert_true: The validity.patternMismatch should be true, when control is disabled. expected true got false
-FAIL [INPUT in EMAIL status] Commas should be stripped from regex input, if multiple is present assert_true: The validity.patternMismatch should be true. expected true got false
+PASS [INPUT in EMAIL status] The pattern attribute uses Unicode features, if multiple is present
+PASS [INPUT in EMAIL status] The value attribute matches _javascript_-specific regular _expression_, if multiple is present
+PASS [INPUT in EMAIL status] The value attribute mismatches _javascript_-specific regular _expression_, if multiple is present
+PASS [INPUT in EMAIL status] Commas should be stripped from regex input, if multiple is present
Modified: trunk/Source/WebCore/ChangeLog (286314 => 286315)
--- trunk/Source/WebCore/ChangeLog 2021-11-30 20:10:32 UTC (rev 286314)
+++ trunk/Source/WebCore/ChangeLog 2021-11-30 20:38:24 UTC (rev 286315)
@@ -1,3 +1,24 @@
+2021-11-30 Chris Dumez <[email protected]>
+
+ html/semantics/forms/constraints/form-validation-validity-patternMismatch.html WPT test is failing
+ https://bugs.webkit.org/show_bug.cgi?id=233601
+
+ Reviewed by Darin Adler.
+
+ No new tests, rebaselined existing test.
+
+ * html/BaseTextInputType.cpp:
+ (WebCore::BaseTextInputType::patternMismatch const):
+ Per https://html.spec.whatwg.org/#attr-input-pattern, when the multiple attribute is present and it
+ applies to the control, then we should check if the pattern applies to each comma-separated value
+ in the input (rather than applying the pattern to the whole input).
+
+ * html/HTMLInputElement.cpp:
+ (WebCore::HTMLInputElement::patternMismatch const):
+ Per https://html.spec.whatwg.org/#dom-validitystate-patternmismatch, patternMismatch should be true
+ when a control has a value that doesn't satisfy the pattern attribute. We had a bug where we would
+ only return true if the control was eligible for validation (i.e. not disabled).
+
2021-11-30 Andreu Botella <[email protected]>
Constructing a FormData from a form can lead to entries with lone surrogates
Modified: trunk/Source/WebCore/html/BaseTextInputType.cpp (286314 => 286315)
--- trunk/Source/WebCore/html/BaseTextInputType.cpp 2021-11-30 20:10:32 UTC (rev 286314)
+++ trunk/Source/WebCore/html/BaseTextInputType.cpp 2021-11-30 20:38:24 UTC (rev 286315)
@@ -42,11 +42,21 @@
const AtomString& rawPattern = element()->attributeWithoutSynchronization(patternAttr);
if (rawPattern.isNull() || value.isEmpty() || !JSC::Yarr::RegularExpression(rawPattern, JSC::Yarr::TextCaseSensitive, JSC::Yarr::MultilineDisabled, JSC::Yarr::UnicodeAwareMode).isValid())
return false;
- String pattern = "^(?:" + rawPattern + ")$";
- int matchLength = 0;
- int valueLength = value.length();
- int matchOffset = JSC::Yarr::RegularExpression(pattern, JSC::Yarr::TextCaseSensitive, JSC::Yarr::MultilineDisabled, JSC::Yarr::UnicodeAwareMode).match(value, 0, &matchLength);
- return matchOffset || matchLength != valueLength;
+
+ String pattern = makeString("^(?:", rawPattern, ")$");
+ JSC::Yarr::RegularExpression regex(pattern, JSC::Yarr::TextCaseSensitive, JSC::Yarr::MultilineDisabled, JSC::Yarr::UnicodeAwareMode);
+ auto valuePatternMismatch = [®ex](auto& value) {
+ int matchLength = 0;
+ int valueLength = value.length();
+ int matchOffset = regex.match(value, 0, &matchLength);
+ return matchOffset || matchLength != valueLength;
+ };
+
+ if (isEmailField() && element()->multiple()) {
+ auto values = value.split(',');
+ return values.findMatching(valuePatternMismatch) != notFound;
+ }
+ return valuePatternMismatch(value);
}
bool BaseTextInputType::supportsPlaceholder() const
Modified: trunk/Source/WebCore/html/HTMLInputElement.cpp (286314 => 286315)
--- trunk/Source/WebCore/html/HTMLInputElement.cpp 2021-11-30 20:10:32 UTC (rev 286314)
+++ trunk/Source/WebCore/html/HTMLInputElement.cpp 2021-11-30 20:38:24 UTC (rev 286315)
@@ -311,7 +311,7 @@
bool HTMLInputElement::patternMismatch() const
{
- return willValidate() && m_inputType->patternMismatch(value());
+ return m_inputType->patternMismatch(value());
}
bool HTMLInputElement::tooShort(StringView value, NeedsToCheckDirtyFlag check) const