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

Side by Side 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: deleteContents doesn’t work well for multiple nodes. Created 4 years, 7 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include <stddef.h> 5 #include <stddef.h>
6 #include <stdint.h> 6 #include <stdint.h>
7 7
8 #include "base/bind.h" 8 #include "base/bind.h"
9 #include "base/callback.h" 9 #include "base/callback.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 1656 matching lines...) Expand 10 before | Expand all | Expand 10 after
1667 EXPECT_EQ(4, info.selectionStart); 1667 EXPECT_EQ(4, info.selectionStart);
1668 EXPECT_EQ(8, info.selectionEnd); 1668 EXPECT_EQ(8, info.selectionEnd);
1669 EXPECT_EQ(7, info.compositionStart); 1669 EXPECT_EQ(7, info.compositionStart);
1670 EXPECT_EQ(10, info.compositionEnd); 1670 EXPECT_EQ(10, info.compositionEnd);
1671 frame()->Unselect(); 1671 frame()->Unselect();
1672 info = view()->webview()->textInputInfo(); 1672 info = view()->webview()->textInputInfo();
1673 EXPECT_EQ(0, info.selectionStart); 1673 EXPECT_EQ(0, info.selectionStart);
1674 EXPECT_EQ(0, info.selectionEnd); 1674 EXPECT_EQ(0, info.selectionEnd);
1675 } 1675 }
1676 1676
1677
1678 TEST_F(RenderViewImplTest, OnExtendSelectionAndDelete) { 1677 TEST_F(RenderViewImplTest, OnExtendSelectionAndDelete) {
1679 // Load an HTML page consisting of an input field. 1678 // Load an HTML page consisting of an input field.
1680 LoadHTML("<html>" 1679 LoadHTML("<html>"
1681 "<head>" 1680 "<head>"
1682 "</head>" 1681 "</head>"
1683 "<body>" 1682 "<body>"
1684 "<input id=\"test1\" value=\"abcdefghijklmnopqrstuvwxyz\"></input>" 1683 "<input id=\"test1\" value=\"abcdefghijklmnopqrstuvwxyz\"></input>"
1685 "</body>" 1684 "</body>"
1686 "</html>"); 1685 "</html>");
1687 ExecuteJavaScriptForTests("document.getElementById('test1').focus();"); 1686 ExecuteJavaScriptForTests("document.getElementById('test1').focus();");
1688 frame()->SetEditableSelectionOffsets(10, 10); 1687 frame()->SetEditableSelectionOffsets(10, 10);
1689 frame()->ExtendSelectionAndDelete(3, 4); 1688 frame()->ExtendSelectionAndDelete(3, 4);
1690 blink::WebTextInputInfo info = view()->webview()->textInputInfo(); 1689 blink::WebTextInputInfo info = view()->webview()->textInputInfo();
1691 EXPECT_EQ("abcdefgopqrstuvwxyz", info.value); 1690 EXPECT_EQ("abcdefgopqrstuvwxyz", info.value);
1692 EXPECT_EQ(7, info.selectionStart); 1691 EXPECT_EQ(7, info.selectionStart);
1693 EXPECT_EQ(7, info.selectionEnd); 1692 EXPECT_EQ(7, info.selectionEnd);
1694 frame()->SetEditableSelectionOffsets(4, 8); 1693 frame()->SetEditableSelectionOffsets(4, 8);
1695 frame()->ExtendSelectionAndDelete(2, 5); 1694 frame()->ExtendSelectionAndDelete(2, 5);
1696 info = view()->webview()->textInputInfo(); 1695 info = view()->webview()->textInputInfo();
1697 EXPECT_EQ("abuvwxyz", info.value); 1696 EXPECT_EQ("abuvwxyz", info.value);
1698 EXPECT_EQ(2, info.selectionStart); 1697 EXPECT_EQ(2, info.selectionStart);
1699 EXPECT_EQ(2, info.selectionEnd); 1698 EXPECT_EQ(2, info.selectionEnd);
1700 } 1699 }
1701 1700
1701 TEST_F(RenderViewImplTest, OnDeleteSurroundingText) {
1702 // Load an HTML page consisting of an input field.
1703 LoadHTML(
1704 "<html>"
1705 "<head>"
1706 "</head>"
1707 "<body>"
1708 "<input id=\"test1\" value=\"abcdefghijklmnopqrstuvwxyz\"></input>"
1709 "</body>"
1710 "</html>");
1711 ExecuteJavaScriptForTests("document.getElementById('test1').focus();");
1712
1713 frame()->SetEditableSelectionOffsets(10, 10);
1714 frame()->DeleteSurroundingText(3, 4);
1715 blink::WebTextInputInfo info = view()->webview()->textInputInfo();
1716 EXPECT_EQ("abcdefgopqrstuvwxyz", info.value);
1717 EXPECT_EQ(7, info.selectionStart);
1718 EXPECT_EQ(7, info.selectionEnd);
1719
1720 frame()->SetEditableSelectionOffsets(4, 8);
1721 frame()->DeleteSurroundingText(2, 5);
1722 info = view()->webview()->textInputInfo();
1723 EXPECT_EQ("abefgouvwxyz", info.value);
1724 EXPECT_EQ(2, info.selectionStart);
1725 EXPECT_EQ(6, info.selectionEnd);
1726
1727 frame()->SetEditableSelectionOffsets(5, 5);
1728 frame()->DeleteSurroundingText(10, 0);
1729 info = view()->webview()->textInputInfo();
1730 EXPECT_EQ("ouvwxyz", info.value);
1731 EXPECT_EQ(0, info.selectionStart);
1732 EXPECT_EQ(0, info.selectionEnd);
1733
1734 frame()->DeleteSurroundingText(0, 10);
1735 info = view()->webview()->textInputInfo();
1736 EXPECT_EQ("", info.value);
1737 EXPECT_EQ(0, info.selectionStart);
1738 EXPECT_EQ(0, info.selectionEnd);
1739
1740 frame()->DeleteSurroundingText(10, 10);
1741 info = view()->webview()->textInputInfo();
1742 EXPECT_EQ("", info.value);
1743
1744 EXPECT_EQ(0, info.selectionStart);
1745 EXPECT_EQ(0, info.selectionEnd);
1746 }
1747
1702 // Test that the navigating specific frames works correctly. 1748 // Test that the navigating specific frames works correctly.
1703 TEST_F(RenderViewImplTest, NavigateSubframe) { 1749 TEST_F(RenderViewImplTest, NavigateSubframe) {
1704 // Load page A. 1750 // Load page A.
1705 LoadHTML("hello <iframe srcdoc='fail' name='frame'></iframe>"); 1751 LoadHTML("hello <iframe srcdoc='fail' name='frame'></iframe>");
1706 1752
1707 // Navigate the frame only. 1753 // Navigate the frame only.
1708 CommonNavigationParams common_params; 1754 CommonNavigationParams common_params;
1709 RequestNavigationParams request_params; 1755 RequestNavigationParams request_params;
1710 common_params.url = GURL("data:text/html,world"); 1756 common_params.url = GURL("data:text/html,world");
1711 common_params.navigation_type = FrameMsg_Navigate_Type::NORMAL; 1757 common_params.navigation_type = FrameMsg_Navigate_Type::NORMAL;
(...skipping 763 matching lines...) Expand 10 before | Expand all | Expand 10 after
2475 "," 2521 ","
2476 "\"functionDeclaration\":\"function foo(){ " 2522 "\"functionDeclaration\":\"function foo(){ "
2477 "Promise.resolve().then(() => " 2523 "Promise.resolve().then(() => "
2478 "console.log(239))}\"" 2524 "console.log(239))}\""
2479 "}" 2525 "}"
2480 "}"); 2526 "}");
2481 EXPECT_EQ(1, CountNotifications("Console.messageAdded")); 2527 EXPECT_EQ(1, CountNotifications("Console.messageAdded"));
2482 } 2528 }
2483 2529
2484 } // namespace content 2530 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698