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

Unified Diff: content/renderer/render_view_browsertest.cc

Issue 1889053003: Fix InputConnection.deleteSurroundingText() (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Use a different method to handle "\n" node Created 4 years, 5 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
Index: content/renderer/render_view_browsertest.cc
diff --git a/content/renderer/render_view_browsertest.cc b/content/renderer/render_view_browsertest.cc
index 572fedd2dd21ba5db4e9533a548f1060c908c264..177172c5c5d8158f1078bcc4ac6d40976d7fc69e 100644
--- a/content/renderer/render_view_browsertest.cc
+++ b/content/renderer/render_view_browsertest.cc
@@ -1678,7 +1678,6 @@ TEST_F(RenderViewImplTest, SetEditableSelectionAndComposition) {
EXPECT_EQ(0, info.selectionEnd);
}
-
TEST_F(RenderViewImplTest, OnExtendSelectionAndDelete) {
// Load an HTML page consisting of an input field.
LoadHTML("<html>"
@@ -1703,6 +1702,53 @@ TEST_F(RenderViewImplTest, OnExtendSelectionAndDelete) {
EXPECT_EQ(2, info.selectionEnd);
}
+TEST_F(RenderViewImplTest, OnDeleteSurroundingText) {
+ // Load an HTML page consisting of an input field.
+ LoadHTML(
+ "<html>"
+ "<head>"
+ "</head>"
+ "<body>"
+ "<input id=\"test1\" value=\"abcdefghijklmnopqrstuvwxyz\"></input>"
+ "</body>"
+ "</html>");
+ ExecuteJavaScriptForTests("document.getElementById('test1').focus();");
+
+ frame()->SetEditableSelectionOffsets(10, 10);
+ frame()->DeleteSurroundingText(3, 4);
+ blink::WebTextInputInfo info = view()->webview()->textInputInfo();
+ EXPECT_EQ("abcdefgopqrstuvwxyz", info.value);
+ EXPECT_EQ(7, info.selectionStart);
+ EXPECT_EQ(7, info.selectionEnd);
+
+ frame()->SetEditableSelectionOffsets(4, 8);
+ frame()->DeleteSurroundingText(2, 5);
+ info = view()->webview()->textInputInfo();
+ EXPECT_EQ("abefgouvwxyz", info.value);
+ EXPECT_EQ(2, info.selectionStart);
+ EXPECT_EQ(6, info.selectionEnd);
+
+ frame()->SetEditableSelectionOffsets(5, 5);
+ frame()->DeleteSurroundingText(10, 0);
+ info = view()->webview()->textInputInfo();
+ EXPECT_EQ("ouvwxyz", info.value);
+ EXPECT_EQ(0, info.selectionStart);
+ EXPECT_EQ(0, info.selectionEnd);
+
+ frame()->DeleteSurroundingText(0, 10);
+ info = view()->webview()->textInputInfo();
+ EXPECT_EQ("", info.value);
+ EXPECT_EQ(0, info.selectionStart);
+ EXPECT_EQ(0, info.selectionEnd);
+
+ frame()->DeleteSurroundingText(10, 10);
+ info = view()->webview()->textInputInfo();
+ EXPECT_EQ("", info.value);
+
+ EXPECT_EQ(0, info.selectionStart);
+ EXPECT_EQ(0, info.selectionEnd);
+}
+
// Test that the navigating specific frames works correctly.
TEST_F(RenderViewImplTest, NavigateSubframe) {
// Load page A.

Powered by Google App Engine
This is Rietveld 408576698