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

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: handle multi-code text with BackspaceStateMachine::previousPositionOf Created 4 years, 8 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 1629 matching lines...) Expand 10 before | Expand all | Expand 10 after
1640 EXPECT_EQ(4, info.selectionStart); 1640 EXPECT_EQ(4, info.selectionStart);
1641 EXPECT_EQ(8, info.selectionEnd); 1641 EXPECT_EQ(8, info.selectionEnd);
1642 EXPECT_EQ(7, info.compositionStart); 1642 EXPECT_EQ(7, info.compositionStart);
1643 EXPECT_EQ(10, info.compositionEnd); 1643 EXPECT_EQ(10, info.compositionEnd);
1644 frame()->Unselect(); 1644 frame()->Unselect();
1645 info = view()->webview()->textInputInfo(); 1645 info = view()->webview()->textInputInfo();
1646 EXPECT_EQ(0, info.selectionStart); 1646 EXPECT_EQ(0, info.selectionStart);
1647 EXPECT_EQ(0, info.selectionEnd); 1647 EXPECT_EQ(0, info.selectionEnd);
1648 } 1648 }
1649 1649
1650
1651 TEST_F(RenderViewImplTest, OnExtendSelectionAndDelete) { 1650 TEST_F(RenderViewImplTest, OnExtendSelectionAndDelete) {
1652 // Load an HTML page consisting of an input field. 1651 // Load an HTML page consisting of an input field.
1653 LoadHTML("<html>" 1652 LoadHTML("<html>"
1654 "<head>" 1653 "<head>"
1655 "</head>" 1654 "</head>"
1656 "<body>" 1655 "<body>"
1657 "<input id=\"test1\" value=\"abcdefghijklmnopqrstuvwxyz\"></input>" 1656 "<input id=\"test1\" value=\"abcdefghijklmnopqrstuvwxyz\"></input>"
1658 "</body>" 1657 "</body>"
1659 "</html>"); 1658 "</html>");
1660 ExecuteJavaScriptForTests("document.getElementById('test1').focus();"); 1659 ExecuteJavaScriptForTests("document.getElementById('test1').focus();");
1661 frame()->SetEditableSelectionOffsets(10, 10); 1660 frame()->SetEditableSelectionOffsets(10, 10);
1662 frame()->ExtendSelectionAndDelete(3, 4); 1661 frame()->ExtendSelectionAndDelete(3, 4);
1663 blink::WebTextInputInfo info = view()->webview()->textInputInfo(); 1662 blink::WebTextInputInfo info = view()->webview()->textInputInfo();
1664 EXPECT_EQ("abcdefgopqrstuvwxyz", info.value); 1663 EXPECT_EQ("abcdefgopqrstuvwxyz", info.value);
1665 EXPECT_EQ(7, info.selectionStart); 1664 EXPECT_EQ(7, info.selectionStart);
1666 EXPECT_EQ(7, info.selectionEnd); 1665 EXPECT_EQ(7, info.selectionEnd);
1667 frame()->SetEditableSelectionOffsets(4, 8); 1666 frame()->SetEditableSelectionOffsets(4, 8);
1668 frame()->ExtendSelectionAndDelete(2, 5); 1667 frame()->ExtendSelectionAndDelete(2, 5);
1669 info = view()->webview()->textInputInfo(); 1668 info = view()->webview()->textInputInfo();
1670 EXPECT_EQ("abuvwxyz", info.value); 1669 EXPECT_EQ("abuvwxyz", info.value);
1671 EXPECT_EQ(2, info.selectionStart); 1670 EXPECT_EQ(2, info.selectionStart);
1672 EXPECT_EQ(2, info.selectionEnd); 1671 EXPECT_EQ(2, info.selectionEnd);
1673 } 1672 }
1674 1673
1674 TEST_F(RenderViewImplTest, OnDeleteSurroundingText) {
1675 // Load an HTML page consisting of an input field.
1676 LoadHTML(
1677 "<html>"
1678 "<head>"
1679 "</head>"
1680 "<body>"
1681 "<input id=\"test1\" value=\"abcdefghijklmnopqrstuvwxyz\"></input>"
1682 "</body>"
1683 "</html>");
1684 ExecuteJavaScriptForTests("document.getElementById('test1').focus();");
1685
1686 frame()->SetEditableSelectionOffsets(10, 10);
1687 frame()->DeleteSurroundingText(3, 4);
1688 blink::WebTextInputInfo info = view()->webview()->textInputInfo();
1689 EXPECT_EQ("abcdefgopqrstuvwxyz", info.value);
1690 EXPECT_EQ(7, info.selectionStart);
1691 EXPECT_EQ(7, info.selectionEnd);
1692
1693 frame()->SetEditableSelectionOffsets(4, 8);
1694 frame()->DeleteSurroundingText(2, 5);
1695 info = view()->webview()->textInputInfo();
1696 EXPECT_EQ("abefgouvwxyz", info.value);
1697 EXPECT_EQ(2, info.selectionStart);
1698 EXPECT_EQ(6, info.selectionEnd);
1699
1700 frame()->SetEditableSelectionOffsets(5, 5);
1701 frame()->DeleteSurroundingText(10, 0);
1702 info = view()->webview()->textInputInfo();
1703 EXPECT_EQ("ouvwxyz", info.value);
1704 EXPECT_EQ(0, info.selectionStart);
1705 EXPECT_EQ(0, info.selectionEnd);
1706
1707 frame()->DeleteSurroundingText(0, 10);
1708 info = view()->webview()->textInputInfo();
1709 EXPECT_EQ("", info.value);
1710 EXPECT_EQ(0, info.selectionStart);
1711 EXPECT_EQ(0, info.selectionEnd);
1712
1713 frame()->DeleteSurroundingText(10, 10);
1714 info = view()->webview()->textInputInfo();
1715 EXPECT_EQ("", info.value);
1716
1717 EXPECT_EQ(0, info.selectionStart);
1718 EXPECT_EQ(0, info.selectionEnd);
1719 }
1720
1675 // Test that the navigating specific frames works correctly. 1721 // Test that the navigating specific frames works correctly.
1676 TEST_F(RenderViewImplTest, NavigateSubframe) { 1722 TEST_F(RenderViewImplTest, NavigateSubframe) {
1677 // Load page A. 1723 // Load page A.
1678 LoadHTML("hello <iframe srcdoc='fail' name='frame'></iframe>"); 1724 LoadHTML("hello <iframe srcdoc='fail' name='frame'></iframe>");
1679 1725
1680 // Navigate the frame only. 1726 // Navigate the frame only.
1681 CommonNavigationParams common_params; 1727 CommonNavigationParams common_params;
1682 RequestNavigationParams request_params; 1728 RequestNavigationParams request_params;
1683 common_params.url = GURL("data:text/html,world"); 1729 common_params.url = GURL("data:text/html,world");
1684 common_params.navigation_type = FrameMsg_Navigate_Type::NORMAL; 1730 common_params.navigation_type = FrameMsg_Navigate_Type::NORMAL;
(...skipping 708 matching lines...) Expand 10 before | Expand all | Expand 10 after
2393 2439
2394 TEST_F(DevToolsAgentTest, RuntimeEnableForcesContextsAfterNavigation) { 2440 TEST_F(DevToolsAgentTest, RuntimeEnableForcesContextsAfterNavigation) {
2395 Attach(); 2441 Attach();
2396 DispatchDevToolsMessage("{\"id\":1,\"method\":\"Runtime.enable\"}"); 2442 DispatchDevToolsMessage("{\"id\":1,\"method\":\"Runtime.enable\"}");
2397 EXPECT_EQ(0, CountNotifications("Runtime.executionContextCreated")); 2443 EXPECT_EQ(0, CountNotifications("Runtime.executionContextCreated"));
2398 LoadHTML("<body>page<iframe></iframe></body>"); 2444 LoadHTML("<body>page<iframe></iframe></body>");
2399 EXPECT_EQ(2, CountNotifications("Runtime.executionContextCreated")); 2445 EXPECT_EQ(2, CountNotifications("Runtime.executionContextCreated"));
2400 } 2446 }
2401 2447
2402 } // namespace content 2448 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698