Double number step=.5 should be considered valid in <input type="number" step=".5">
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 25 Oct 2011 14:04:45 +0000 (14:04 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 25 Oct 2011 14:04:45 +0000 (14:04 +0000)
https://bugs.webkit.org/show_bug.cgi?id=70320

Patch by Sachin Puranik <sachin.puranik@motorola.com> on 2011-10-25
Reviewed by Kent Tamura.

Source/WebCore:

Test: fast/forms/input-step-as-double.html

* html/parser/HTMLParserIdioms.cpp:
(WebCore::parseToDoubleForNumberType): Changed the function to consider
step as valid even if it starts with "."

LayoutTests:

* fast/forms/ValidityState-typeMismatch-number-expected.txt: Change in result of layout test.
* fast/forms/input-step-as-double-expected.txt: Added, expected output for new test case.
* fast/forms/input-step-as-double.html: Added, testcase to make sure that all ports
consider .5 as a valid double value for step attribute of input element.
* fast/forms/input-valueasnumber-number-expected.txt: Change in result of layout test.
* fast/forms/range/input-valueasnumber-range-expected.txt: Change in result of layout test.
* fast/forms/range/input-valueasnumber-range.html: Consider .2 as valid real number now.
* fast/forms/script-tests/ValidityState-typeMismatch-number.js: Consider
.2 as valid real number now.
* fast/forms/script-tests/input-valueasnumber-number.js: Consider .2 as valid real number now.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@98342 268f45cc-cd09-0410-ab3c-d52691b4dbfc

LayoutTests/ChangeLog
LayoutTests/fast/forms/ValidityState-typeMismatch-number-expected.txt
LayoutTests/fast/forms/input-step-as-double-expected.txt [new file with mode: 0644]
LayoutTests/fast/forms/input-step-as-double.html [new file with mode: 0644]
LayoutTests/fast/forms/input-valueasnumber-number-expected.txt
LayoutTests/fast/forms/range/input-valueasnumber-range-expected.txt
LayoutTests/fast/forms/range/input-valueasnumber-range.html
LayoutTests/fast/forms/script-tests/ValidityState-typeMismatch-number.js
LayoutTests/fast/forms/script-tests/input-valueasnumber-number.js
Source/WebCore/ChangeLog
Source/WebCore/html/parser/HTMLParserIdioms.cpp

index 2f7e314..9513377 100644 (file)
@@ -1,3 +1,21 @@
+2011-10-25  Sachin Puranik  <sachin.puranik@motorola.com>
+
+        Double number step=.5 should be considered valid in <input type="number" step=".5">
+        https://bugs.webkit.org/show_bug.cgi?id=70320
+
+        Reviewed by Kent Tamura.
+
+        * fast/forms/ValidityState-typeMismatch-number-expected.txt: Change in result of layout test.
+        * fast/forms/input-step-as-double-expected.txt: Added, expected output for new test case.
+        * fast/forms/input-step-as-double.html: Added, testcase to make sure that all ports 
+        consider .5 as a valid double value for step attribute of input element.
+        * fast/forms/input-valueasnumber-number-expected.txt: Change in result of layout test.
+        * fast/forms/range/input-valueasnumber-range-expected.txt: Change in result of layout test.
+        * fast/forms/range/input-valueasnumber-range.html: Consider .2 as valid real number now.
+        * fast/forms/script-tests/ValidityState-typeMismatch-number.js: Consider
+        .2 as valid real number now.
+        * fast/forms/script-tests/input-valueasnumber-number.js: Consider .2 as valid real number now.
+
 2011-10-25  Vsevolod Vlasov  <vsevik@chromium.org>
 
         Web Inspector: Resources panel: display the current search match index in the toolbar.
index f56183a..0df52d1 100644 (file)
@@ -6,6 +6,8 @@ On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE
 PASS "0" is a valid number.
 PASS "10" is a valid number.
 PASS "01" is a valid number.
+PASS "0.2" is a valid number.
+PASS ".2" is a valid number.
 PASS "-0" is a valid number.
 PASS "-1.2" is a valid number.
 PASS "1.2E10" is a valid number.
@@ -19,7 +21,6 @@ PASS "+1" was sanitized to "".
 PASS " 10" was sanitized to "".
 PASS "10 " was sanitized to "".
 PASS "1,2" was sanitized to "".
-PASS ".2" was sanitized to "".
 PASS "1E" was sanitized to "".
 PASS "NaN" was sanitized to "".
 PASS "nan" was sanitized to "".
diff --git a/LayoutTests/fast/forms/input-step-as-double-expected.txt b/LayoutTests/fast/forms/input-step-as-double-expected.txt
new file mode 100644 (file)
index 0000000..10d116b
--- /dev/null
@@ -0,0 +1,10 @@
+Test for a capturing spec change to consider .2 as valid real number for step
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS numberInput.value is "0.5"
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/fast/forms/input-step-as-double.html b/LayoutTests/fast/forms/input-step-as-double.html
new file mode 100644 (file)
index 0000000..70e8d14
--- /dev/null
@@ -0,0 +1,32 @@
+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
+<html>
+<head>
+<script src="../../fast/js/resources/js-test-pre.js"></script>
+</head>
+<body>
+<script>
+description('Test for a capturing spec change to consider .2 as valid real number for step');
+
+var parent = document.createElement('div');
+document.body.appendChild(parent);
+parent.innerHTML = '<input type=number id=number value=0 step=".5">';
+var numberInput = document.getElementById('number');
+
+if (window.eventSender) {
+    // Move the cursor on the upper button of the input field.
+    eventSender.mouseMoveTo(numberInput.offsetLeft + numberInput.offsetWidth - 10, numberInput.offsetTop + numberInput.offsetHeight / 4);
+
+    eventSender.mouseDown();
+    eventSender.mouseUp();
+    shouldBe('numberInput.value', '"0.5"');
+
+    parent.innerHTML = '';
+} else {
+    document.getElementById('console').innerHTML = '<p>No eventSender. <p>Manual test instruction: Click the upper button of the input field.  Confirm that the input field value is 0.5';
+}
+
+var successfullyParsed = true;
+</script>
+<script src="../../fast/js/resources/js-test-post.js"></script>
+</body>
+</html>
index 71147fd..b72f890 100644 (file)
@@ -4,6 +4,8 @@ On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE
 
 
 PASS valueAsNumberFor("0") is 0
+PASS valueAsNumberFor("0.2") is 0.2
+PASS valueAsNumberFor(".2") is 0.2
 PASS valueAsNumberFor("10") is 10
 PASS valueAsNumberFor("01") is 1
 PASS valueAsNumberFor("-0") is 0
@@ -20,7 +22,7 @@ PASS isNaN(valueAsNumberFor("0xff")) is true
 PASS isNaN(valueAsNumberFor("+1")) is true
 PASS isNaN(valueAsNumberFor(" 10")) is true
 PASS isNaN(valueAsNumberFor("10 ")) is true
-PASS isNaN(valueAsNumberFor(".2")) is true
+PASS isNaN(valueAsNumberFor(".")) is true
 PASS isNaN(valueAsNumberFor("1E")) is true
 PASS isNaN(valueAsNumberFor("NaN")) is true
 PASS isNaN(valueAsNumberFor("nan")) is true
index 3be7794..e7513da 100644 (file)
@@ -8,6 +8,8 @@ PASS valueAsNumberFor("10") is 10
 PASS valueAsNumberFor("01") is 1
 PASS valueAsNumberFor("-0") is 0
 PASS valueAsNumberFor("-1.2") is 0
+PASS valueAsNumberFor("0.2") is 0
+PASS valueAsNumberFor(".2") is 0
 PASS valueAsNumberFor("1.2E10") is 100
 PASS valueAsNumberFor("1.2E-10") is 0
 PASS valueAsNumberFor("1.2E+10") is 100
@@ -20,7 +22,6 @@ PASS valueAsNumberFor("0xff") is 50
 PASS valueAsNumberFor("+1") is 50
 PASS valueAsNumberFor(" 10") is 50
 PASS valueAsNumberFor("10 ") is 50
-PASS valueAsNumberFor(".2") is 50
 PASS valueAsNumberFor("1E") is 50
 PASS valueAsNumberFor("NaN") is 50
 PASS valueAsNumberFor("nan") is 50
index 36d431d..cbec644 100644 (file)
@@ -32,6 +32,8 @@ shouldBe('valueAsNumberFor("10")', '10');
 shouldBe('valueAsNumberFor("01")', '1');
 shouldBe('valueAsNumberFor("-0")', '0');
 shouldBe('valueAsNumberFor("-1.2")', '0');
+shouldBe('valueAsNumberFor("0.2")', '0');
+shouldBe('valueAsNumberFor(".2")', '0');
 shouldBe('valueAsNumberFor("1.2E10")', '100');
 shouldBe('valueAsNumberFor("1.2E-10")', '0');
 shouldBe('valueAsNumberFor("1.2E+10")', '100');
@@ -45,7 +47,6 @@ shouldBe('valueAsNumberFor("0xff")', '50');
 shouldBe('valueAsNumberFor("+1")', '50');
 shouldBe('valueAsNumberFor(" 10")', '50');
 shouldBe('valueAsNumberFor("10 ")', '50');
-shouldBe('valueAsNumberFor(".2")', '50');
 shouldBe('valueAsNumberFor("1E")', '50');
 shouldBe('valueAsNumberFor("NaN")', '50');
 shouldBe('valueAsNumberFor("nan")', '50');
index 682e37e..736c446 100644 (file)
@@ -31,6 +31,8 @@ function checkSanitization(value, expectedValue)
 check('0');
 check('10');
 check('01');
+check('0.2');
+check('.2');
 check('-0');
 check('-1.2');
 check('1.2E10');
@@ -47,7 +49,6 @@ checkSanitization('+1', '');
 checkSanitization(' 10', '');
 checkSanitization('10 ', '');
 checkSanitization('1,2', '');
-checkSanitization('.2', '');
 checkSanitization('1E', '');
 checkSanitization('NaN', '');
 checkSanitization('nan', '');
index 2797591..b83b215 100644 (file)
@@ -14,6 +14,8 @@ function setValueAsNumberAndGetValue(num) {
 }
 
 shouldBe('valueAsNumberFor("0")', '0');
+shouldBe('valueAsNumberFor("0.2")', '0.2');
+shouldBe('valueAsNumberFor(".2")', '0.2');
 shouldBe('valueAsNumberFor("10")', '10');
 shouldBe('valueAsNumberFor("01")', '1');
 shouldBe('valueAsNumberFor("-0")', '0'); // "-0" is 0 in HTML5.
@@ -31,7 +33,7 @@ shouldBeTrue('isNaN(valueAsNumberFor("0xff"))');
 shouldBeTrue('isNaN(valueAsNumberFor("+1"))');
 shouldBeTrue('isNaN(valueAsNumberFor(" 10"))');
 shouldBeTrue('isNaN(valueAsNumberFor("10 "))');
-shouldBeTrue('isNaN(valueAsNumberFor(".2"))');
+shouldBeTrue('isNaN(valueAsNumberFor("."))');
 shouldBeTrue('isNaN(valueAsNumberFor("1E"))');
 shouldBeTrue('isNaN(valueAsNumberFor("NaN"))');
 shouldBeTrue('isNaN(valueAsNumberFor("nan"))');
index d1b6090..6b85edd 100644 (file)
@@ -1,3 +1,16 @@
+2011-10-25  Sachin Puranik  <sachin.puranik@motorola.com>
+
+        Double number step=.5 should be considered valid in <input type="number" step=".5">
+        https://bugs.webkit.org/show_bug.cgi?id=70320
+
+        Reviewed by Kent Tamura.
+
+        Test: fast/forms/input-step-as-double.html
+
+        * html/parser/HTMLParserIdioms.cpp:
+        (WebCore::parseToDoubleForNumberType): Changed the function to consider
+        step as valid even if it starts with "."
+
 2011-10-25  Alexander Pavlov  <apavlov@chromium.org>
 
         Web Inspector: [Chromium] Audits panel context menu for links not working properly
index 02f0177..b860202 100644 (file)
@@ -68,11 +68,11 @@ String serializeForNumberType(double number)
 
 bool parseToDoubleForNumberType(const String& string, double* result)
 {
-    // See HTML5 2.4.4.3 `Real numbers.'
+    // See HTML5 2.5.4.3 `Real numbers.'
 
     // String::toDouble() accepts leading + and whitespace characters, which are not valid here.
     UChar firstCharacter = string[0];
-    if (firstCharacter != '-' && !isASCIIDigit(firstCharacter))
+    if (firstCharacter != '-' && firstCharacter != '.' && !isASCIIDigit(firstCharacter))
         return false;
 
     bool valid = false;
@@ -85,7 +85,7 @@ bool parseToDoubleForNumberType(const String& string, double* result)
         return false;
 
     // Numbers are considered finite IEEE 754 single-precision floating point values.
-    // See HTML5 2.4.4.3 `Real numbers.'
+    // See HTML5 2.5.4.3 `Real numbers.'
     if (-std::numeric_limits<float>::max() > value || value > std::numeric_limits<float>::max())
         return false;