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

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

Powered by Google App Engine
This is Rietveld 408576698