Commit af2085d1 authored by tkent@chromium.org's avatar tkent@chromium.org
Browse files

2011-05-11 Kent Tamura <tkent@chromium.org>

        Reviewed by Dimitri Glazkov.

        <input pattern="1|10" value="10"> doesn't work correctly.
        https://bugs.webkit.org/show_bug.cgi?id=60619

        Add test cases and update the result.

        * fast/forms/ValidityState-patternMismatch-expected.txt:
        * fast/forms/ValidityState-patternMismatch.html:
2011-05-11  Kent Tamura  <tkent@chromium.org>

        Reviewed by Dimitri Glazkov.

        <input pattern="1|10" value="10"> doesn't work correctly.
        https://bugs.webkit.org/show_bug.cgi?id=60619

        Fixes a bug that patternMismatch returns a wrong result if
         - a whole value matches to a pattern,
         - a sub-string of the value also matches to the pattern, and
         - the sub-string matching has priority.

        * html/BaseTextInputType.cpp:
        (WebCore::BaseTextInputType::patternMismatch):
          Enclose the specified pattern with ^( and )$.

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@86292 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 6e126984
2011-05-11 Kent Tamura <tkent@chromium.org>
Reviewed by Dimitri Glazkov.
<input pattern="1|10" value="10"> doesn't work correctly.
https://bugs.webkit.org/show_bug.cgi?id=60619
Add test cases and update the result.
* fast/forms/ValidityState-patternMismatch-expected.txt:
* fast/forms/ValidityState-patternMismatch.html:
2011-05-11 Abhishek Arya <inferno@chromium.org>
 
Unreviewed.
......@@ -25,6 +25,8 @@ PASS patternMismatchFor("match-14") is false
PASS patternMismatchFor("match-15") is false
PASS patternMismatchFor("match-16") is false
PASS patternMismatchFor("match-17") is false
PASS patternMismatchFor("match-18") is false
PASS patternMismatchFor("match-19") is false
PASS patternMismatchFor("wrong-gray-or-grey") is true
PASS patternMismatchFor("gray") is false
PASS patternMismatchFor("grey") is false
......
......@@ -7,6 +7,7 @@
<body>
<p id="description"></p>
<div id="console"></div>
<div id=container>
<input id="simple" pattern="[0-9][A-Z]{3}" value="0AAA"
/><input id="no-pattern-and-no-value"
/><input id="ip-address" type="text" pattern="\b(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\b" value="127.0.0.1"
......@@ -28,8 +29,10 @@
/><input id="match-14" type="text" pattern="...\)\(..." value="aaa)(bbb"
/><input id="match-15" type="text" pattern="^" value=""
/><input id="match-16" type="text" pattern="$" value=""
/><input id="match-17" type="text" pattern="foobar" value=""
/><input id="wrong-gray-or-grey" type="text" pattern="gr[ae]y" value="Wrong!"
/><input id="match-17" type="text" pattern="foobar" value="" />
<input id="match-18" type="text" pattern="[0-9]|10|11|12" value="10" />
<input id="match-19" type="text" pattern="10|11|12|[0-9]" value="12" />
<input id="wrong-gray-or-grey" type="text" pattern="gr[ae]y" value="Wrong!"
/><input id="gray" type="text" pattern="gr[ae]y" value="gray"
/><input id="grey" type="text" pattern="gr[ae]y" value="grey"
/><input id="empty-gray-or-grey" type="text" pattern="gr[ae]y" value=""
......@@ -54,7 +57,7 @@
/><input id="mismatch-19" type="text" pattern="^" value="wrong"
/><input id="mismatch-20" type="text" pattern="$" value="wrong"
/><input id="empty-pattern" type="text" pattern="" value="Lorem Ipsum"
/><input id="disabled" pattern="[0-9][A-Z]{3}" value="00AA" disabled />
/><input id="disabled" pattern="[0-9][A-Z]{3}" value="00AA" disabled /></div>
<script language="JavaScript" type="text/javascript">
function patternMismatchFor(id) {
return document.getElementById(id).validity.patternMismatch;
......@@ -85,6 +88,8 @@ shouldBeFalse('patternMismatchFor("match-14")');
shouldBeFalse('patternMismatchFor("match-15")');
shouldBeFalse('patternMismatchFor("match-16")');
shouldBeFalse('patternMismatchFor("match-17")');
shouldBeFalse('patternMismatchFor("match-18")');
shouldBeFalse('patternMismatchFor("match-19")');
shouldBeTrue('patternMismatchFor("wrong-gray-or-grey")');
shouldBeFalse('patternMismatchFor("gray")');
......@@ -116,6 +121,7 @@ shouldBeFalse('patternMismatchFor("empty-pattern")');
shouldBeFalse('patternMismatchFor("disabled")');
document.body.removeChild(document.getElementById('container'));
var successfullyParsed = true;
</script>
<script src="../../fast/js/resources/js-test-post.js"></script>
......
2011-05-11 Kent Tamura <tkent@chromium.org>
Reviewed by Dimitri Glazkov.
<input pattern="1|10" value="10"> doesn't work correctly.
https://bugs.webkit.org/show_bug.cgi?id=60619
Fixes a bug that patternMismatch returns a wrong result if
- a whole value matches to a pattern,
- a sub-string of the value also matches to the pattern, and
- the sub-string matching has priority.
* html/BaseTextInputType.cpp:
(WebCore::BaseTextInputType::patternMismatch):
Enclose the specified pattern with ^( and )$.
2011-05-11 Zelidrag Hornung <zelidrag@chromium.org>
 
Reviewed by David Levin.
......@@ -39,10 +39,11 @@ bool BaseTextInputType::isTextType() const
bool BaseTextInputType::patternMismatch(const String& value) const
{
const AtomicString& pattern = element()->fastGetAttribute(patternAttr);
const AtomicString& rawPattern = element()->fastGetAttribute(patternAttr);
// Empty values can't be mismatched
if (pattern.isEmpty() || value.isEmpty())
if (rawPattern.isEmpty() || value.isEmpty())
return false;
String pattern = "^(" + rawPattern + ")$";
int matchLength = 0;
int valueLength = value.length();
int matchOffset = RegularExpression(pattern, TextCaseSensitive).match(value, 0, &matchLength);
......
Supports Markdown
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