Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(190)

Unified Diff: third_party/WebKit/Source/core/html/HTMLTextAreaElementTest.cpp

Issue 1846913005: Newline characters in pasted text are not counted correctly for textarea[maxlength]. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/WebKit/Source/core/html/HTMLTextAreaElement.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/core/html/HTMLTextAreaElementTest.cpp
diff --git a/third_party/WebKit/Source/core/html/HTMLTextAreaElementTest.cpp b/third_party/WebKit/Source/core/html/HTMLTextAreaElementTest.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..c475bb9444e2c298c0b431f19e9c1d403e2fe389
--- /dev/null
+++ b/third_party/WebKit/Source/core/html/HTMLTextAreaElementTest.cpp
@@ -0,0 +1,32 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "core/html/HTMLTextAreaElement.h"
+
+#include "testing/gtest/include/gtest/gtest.h"
+
+namespace blink {
+
+TEST(HTMLTextAreaElementTest, SanitizeUserInputValue)
+{
+ UChar kLeadSurrogate = 0xD800;
+ EXPECT_EQ("", HTMLTextAreaElement::sanitizeUserInputValue("", 0));
+ EXPECT_EQ("", HTMLTextAreaElement::sanitizeUserInputValue("a", 0));
+ EXPECT_EQ("", HTMLTextAreaElement::sanitizeUserInputValue("\n", 0));
+ StringBuilder builder;
+ builder.append(kLeadSurrogate);
+ String leadSurrogate = builder.toString();
+ EXPECT_EQ("", HTMLTextAreaElement::sanitizeUserInputValue(leadSurrogate, 0));
+
+ EXPECT_EQ("", HTMLTextAreaElement::sanitizeUserInputValue("", 1));
+ EXPECT_EQ("", HTMLTextAreaElement::sanitizeUserInputValue(leadSurrogate, 1));
+ EXPECT_EQ("a", HTMLTextAreaElement::sanitizeUserInputValue("a", 1));
+ EXPECT_EQ("", HTMLTextAreaElement::sanitizeUserInputValue("\n", 1));
+ EXPECT_EQ("\n", HTMLTextAreaElement::sanitizeUserInputValue("\n", 2));
+
+ EXPECT_EQ("abc", HTMLTextAreaElement::sanitizeUserInputValue(String("abc") + leadSurrogate, 4));
+ EXPECT_EQ("a\nc", HTMLTextAreaElement::sanitizeUserInputValue("a\ncdef", 4));
+}
+
+} // namespace blink
« no previous file with comments | « third_party/WebKit/Source/core/html/HTMLTextAreaElement.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698