Fix some edge cases for textarea.rows and textarea.cols
Both setting rows/cols IDL attribute directly as well as
indirectly setting using setAttribute were not treating
values bigger than 2147483647 correctly, so fix both code
paths.
Bug: 651762
Change-Id: Ibee9df2bea4e6b75df711499b3ea2a2f3821674a
Reviewed-on: https://chromium-review.googlesource.com/775078
Commit-Queue: Rob Buis <rob.buis@samsung.com>
Reviewed-by: Philip Jägenstedt <foolip@chromium.org>
Cr-Commit-Position: refs/heads/master@{#519205}
diff --git a/third_party/WebKit/LayoutTests/external/wpt/html/dom/reflection-forms-expected.txt b/third_party/WebKit/LayoutTests/external/wpt/html/dom/reflection-forms-expected.txt
index 6e84d4e..c1cecdd 100644
--- a/third_party/WebKit/LayoutTests/external/wpt/html/dom/reflection-forms-expected.txt
+++ b/third_party/WebKit/LayoutTests/external/wpt/html/dom/reflection-forms-expected.txt
@@ -1,5 +1,5 @@
This is a testharness.js-based test.
-Found 7041 tests; 6721 PASS, 320 FAIL, 0 TIMEOUT, 0 NOTRUN.
+Found 7041 tests; 6729 PASS, 312 FAIL, 0 TIMEOUT, 0 NOTRUN.
PASS form.title: 32 tests
PASS form.lang: 32 tests
PASS form.dir: 62 tests
@@ -338,12 +338,7 @@
NOTRUN test
NOTRUN test
PASS textarea.autofocus: 33 tests
-PASS textarea.cols: 9 tests
-NOTRUN test
-NOTRUN test
-PASS textarea.cols: 46 tests
-NOTRUN test
-NOTRUN test
+PASS textarea.cols: 59 tests
PASS textarea.dirName: 32 tests
PASS textarea.disabled: 33 tests
PASS textarea.inputMode: 3 tests
@@ -508,12 +503,7 @@
PASS textarea.placeholder: 32 tests
PASS textarea.readOnly: 33 tests
PASS textarea.required: 33 tests
-PASS textarea.rows: 9 tests
-NOTRUN test
-NOTRUN test
-PASS textarea.rows: 46 tests
-NOTRUN test
-NOTRUN test
+PASS textarea.rows: 59 tests
PASS textarea.wrap: 32 tests
PASS output.title: 32 tests
PASS output.lang: 32 tests
diff --git a/third_party/WebKit/LayoutTests/fast/forms/textarea/cols-attribute-expected.txt b/third_party/WebKit/LayoutTests/fast/forms/textarea/cols-attribute-expected.txt
index 4a5ae32..534400e 100644
--- a/third_party/WebKit/LayoutTests/fast/forms/textarea/cols-attribute-expected.txt
+++ b/third_party/WebKit/LayoutTests/fast/forms/textarea/cols-attribute-expected.txt
@@ -21,10 +21,13 @@
PASS colsAttributeEffect(" 7") is 7
PASS colsAttributeEffect(arabicIndicDigitOne) is 20
PASS colsAttributeEffect("2" + arabicIndicDigitOne) is 2
+PASS colsAttributeEffect("2147483646") is 2147483646
PASS colsAttributeEffect("2147483647") is 2147483647
-PASS colsAttributeEffect("2147483648") is 2147483648
-PASS colsAttributeEffect("4294967295") is 4294967295
+PASS colsAttributeEffect("2147483648") is 20
+PASS colsAttributeEffect("2147483649") is 20
+PASS colsAttributeEffect("4294967295") is 20
PASS colsAttributeEffect("4294967296") is 20
+PASS colsAttributeEffect("4294967297") is 20
PASS successfullyParsed is true
TEST COMPLETE
diff --git a/third_party/WebKit/LayoutTests/fast/forms/textarea/cols-attribute.html b/third_party/WebKit/LayoutTests/fast/forms/textarea/cols-attribute.html
index 6978fa1b..bfdb504 100644
--- a/third_party/WebKit/LayoutTests/fast/forms/textarea/cols-attribute.html
+++ b/third_party/WebKit/LayoutTests/fast/forms/textarea/cols-attribute.html
@@ -41,10 +41,15 @@
shouldBe('colsAttributeEffect(arabicIndicDigitOne)', '20');
shouldBe('colsAttributeEffect("2" + arabicIndicDigitOne)', '2');
+// Verify that values >= 2^31 result in the default value.
+shouldBe('colsAttributeEffect("2147483646")', '2147483646');
shouldBe('colsAttributeEffect("2147483647")', '2147483647');
-shouldBe('colsAttributeEffect("2147483648")', '2147483648');
-shouldBe('colsAttributeEffect("4294967295")', '4294967295');
+shouldBe('colsAttributeEffect("2147483648")', '20');
+shouldBe('colsAttributeEffect("2147483649")', '20');
+// Verify that 2^32 is no special boundary at all.
+shouldBe('colsAttributeEffect("4294967295")', '20');
shouldBe('colsAttributeEffect("4294967296")', '20');
+shouldBe('colsAttributeEffect("4294967297")', '20');
</script>
</body>
</html>
diff --git a/third_party/WebKit/LayoutTests/fast/forms/textarea/rows-attribute-expected.txt b/third_party/WebKit/LayoutTests/fast/forms/textarea/rows-attribute-expected.txt
index 1df61b4b..5d6638f 100644
--- a/third_party/WebKit/LayoutTests/fast/forms/textarea/rows-attribute-expected.txt
+++ b/third_party/WebKit/LayoutTests/fast/forms/textarea/rows-attribute-expected.txt
@@ -21,10 +21,13 @@
PASS rowsAttributeEffect(" 7") is 7
PASS rowsAttributeEffect(arabicIndicDigitOne) is 2
PASS rowsAttributeEffect("2" + arabicIndicDigitOne) is 2
+PASS rowsAttributeEffect("2147483646") is 2147483646
PASS rowsAttributeEffect("2147483647") is 2147483647
-PASS rowsAttributeEffect("2147483648") is 2147483648
-PASS rowsAttributeEffect("4294967295") is 4294967295
+PASS rowsAttributeEffect("2147483648") is 2
+PASS rowsAttributeEffect("2147483649") is 2
+PASS rowsAttributeEffect("4294967295") is 2
PASS rowsAttributeEffect("4294967296") is 2
+PASS rowsAttributeEffect("4294967297") is 2
PASS successfullyParsed is true
TEST COMPLETE
diff --git a/third_party/WebKit/LayoutTests/fast/forms/textarea/rows-attribute.html b/third_party/WebKit/LayoutTests/fast/forms/textarea/rows-attribute.html
index 8341645..5416794 100644
--- a/third_party/WebKit/LayoutTests/fast/forms/textarea/rows-attribute.html
+++ b/third_party/WebKit/LayoutTests/fast/forms/textarea/rows-attribute.html
@@ -41,10 +41,15 @@
shouldBe('rowsAttributeEffect(arabicIndicDigitOne)', '2');
shouldBe('rowsAttributeEffect("2" + arabicIndicDigitOne)', '2');
+// Verify that values >= 2^31 result in the default value.
+shouldBe('rowsAttributeEffect("2147483646")', '2147483646');
shouldBe('rowsAttributeEffect("2147483647")', '2147483647');
-shouldBe('rowsAttributeEffect("2147483648")', '2147483648');
-shouldBe('rowsAttributeEffect("4294967295")', '4294967295');
+shouldBe('rowsAttributeEffect("2147483648")', '2');
+shouldBe('rowsAttributeEffect("2147483649")', '2');
+// Verify that 2^32 is no special boundary at all.
+shouldBe('rowsAttributeEffect("4294967295")', '2');
shouldBe('rowsAttributeEffect("4294967296")', '2');
+shouldBe('rowsAttributeEffect("4294967297")', '2');
</script>
</body>
</html>
diff --git a/third_party/WebKit/Source/core/html/forms/HTMLTextAreaElement.cpp b/third_party/WebKit/Source/core/html/forms/HTMLTextAreaElement.cpp
index 40f330aa..ac3b09a 100644
--- a/third_party/WebKit/Source/core/html/forms/HTMLTextAreaElement.cpp
+++ b/third_party/WebKit/Source/core/html/forms/HTMLTextAreaElement.cpp
@@ -152,7 +152,7 @@
if (name == rowsAttr) {
unsigned rows = 0;
if (value.IsEmpty() || !ParseHTMLNonNegativeInteger(value, rows) ||
- rows <= 0)
+ rows <= 0 || rows > 0x7fffffffu)
rows = kDefaultRows;
if (rows_ != rows) {
rows_ = rows;
@@ -165,7 +165,7 @@
} else if (name == colsAttr) {
unsigned cols = 0;
if (value.IsEmpty() || !ParseHTMLNonNegativeInteger(value, cols) ||
- cols <= 0)
+ cols <= 0 || cols > 0x7fffffffu)
cols = kDefaultCols;
if (cols_ != cols) {
cols_ = cols;
@@ -568,11 +568,13 @@
}
void HTMLTextAreaElement::setCols(unsigned cols) {
- SetUnsignedIntegralAttribute(colsAttr, cols ? cols : kDefaultCols);
+ SetUnsignedIntegralAttribute(colsAttr, cols ? cols : kDefaultCols,
+ kDefaultCols);
}
void HTMLTextAreaElement::setRows(unsigned rows) {
- SetUnsignedIntegralAttribute(rowsAttr, rows ? rows : kDefaultRows);
+ SetUnsignedIntegralAttribute(rowsAttr, rows ? rows : kDefaultRows,
+ kDefaultRows);
}
bool HTMLTextAreaElement::MatchesReadOnlyPseudoClass() const {