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

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: change int to size_t Created 4 years, 2 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 4663a9123b09b4e44a1a6158bfd01160e9b125e8..61ade1115e4ed959c43288de63d49fa9b9fe4c98 100644
--- a/content/renderer/render_view_browsertest.cc
+++ b/content/renderer/render_view_browsertest.cc
@@ -1700,7 +1700,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>"
@@ -1725,6 +1724,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