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

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: change back to patch set #25 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 unified diff | Download patch
« no previous file with comments | « content/renderer/render_frame_impl.cc ('k') | content/test/test_render_frame.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 #include <tuple> 7 #include <tuple>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/callback.h" 10 #include "base/callback.h"
(...skipping 1682 matching lines...) Expand 10 before | Expand all | Expand 10 after
1693 EXPECT_EQ(4, info.selectionStart); 1693 EXPECT_EQ(4, info.selectionStart);
1694 EXPECT_EQ(8, info.selectionEnd); 1694 EXPECT_EQ(8, info.selectionEnd);
1695 EXPECT_EQ(7, info.compositionStart); 1695 EXPECT_EQ(7, info.compositionStart);
1696 EXPECT_EQ(10, info.compositionEnd); 1696 EXPECT_EQ(10, info.compositionEnd);
1697 frame()->Unselect(); 1697 frame()->Unselect();
1698 info = view()->webview()->textInputInfo(); 1698 info = view()->webview()->textInputInfo();
1699 EXPECT_EQ(0, info.selectionStart); 1699 EXPECT_EQ(0, info.selectionStart);
1700 EXPECT_EQ(0, info.selectionEnd); 1700 EXPECT_EQ(0, info.selectionEnd);
1701 } 1701 }
1702 1702
1703
1704 TEST_F(RenderViewImplTest, OnExtendSelectionAndDelete) { 1703 TEST_F(RenderViewImplTest, OnExtendSelectionAndDelete) {
1705 // Load an HTML page consisting of an input field. 1704 // Load an HTML page consisting of an input field.
1706 LoadHTML("<html>" 1705 LoadHTML("<html>"
1707 "<head>" 1706 "<head>"
1708 "</head>" 1707 "</head>"
1709 "<body>" 1708 "<body>"
1710 "<input id=\"test1\" value=\"abcdefghijklmnopqrstuvwxyz\"></input>" 1709 "<input id=\"test1\" value=\"abcdefghijklmnopqrstuvwxyz\"></input>"
1711 "</body>" 1710 "</body>"
1712 "</html>"); 1711 "</html>");
1713 ExecuteJavaScriptForTests("document.getElementById('test1').focus();"); 1712 ExecuteJavaScriptForTests("document.getElementById('test1').focus();");
1714 frame()->SetEditableSelectionOffsets(10, 10); 1713 frame()->SetEditableSelectionOffsets(10, 10);
1715 frame()->ExtendSelectionAndDelete(3, 4); 1714 frame()->ExtendSelectionAndDelete(3, 4);
1716 blink::WebTextInputInfo info = view()->webview()->textInputInfo(); 1715 blink::WebTextInputInfo info = view()->webview()->textInputInfo();
1717 EXPECT_EQ("abcdefgopqrstuvwxyz", info.value); 1716 EXPECT_EQ("abcdefgopqrstuvwxyz", info.value);
1718 EXPECT_EQ(7, info.selectionStart); 1717 EXPECT_EQ(7, info.selectionStart);
1719 EXPECT_EQ(7, info.selectionEnd); 1718 EXPECT_EQ(7, info.selectionEnd);
1720 frame()->SetEditableSelectionOffsets(4, 8); 1719 frame()->SetEditableSelectionOffsets(4, 8);
1721 frame()->ExtendSelectionAndDelete(2, 5); 1720 frame()->ExtendSelectionAndDelete(2, 5);
1722 info = view()->webview()->textInputInfo(); 1721 info = view()->webview()->textInputInfo();
1723 EXPECT_EQ("abuvwxyz", info.value); 1722 EXPECT_EQ("abuvwxyz", info.value);
1724 EXPECT_EQ(2, info.selectionStart); 1723 EXPECT_EQ(2, info.selectionStart);
1725 EXPECT_EQ(2, info.selectionEnd); 1724 EXPECT_EQ(2, info.selectionEnd);
1726 } 1725 }
1727 1726
1727 TEST_F(RenderViewImplTest, OnDeleteSurroundingText) {
1728 // Load an HTML page consisting of an input field.
1729 LoadHTML(
1730 "<html>"
1731 "<head>"
1732 "</head>"
1733 "<body>"
1734 "<input id=\"test1\" value=\"abcdefghijklmnopqrstuvwxyz\"></input>"
1735 "</body>"
1736 "</html>");
1737 ExecuteJavaScriptForTests("document.getElementById('test1').focus();");
1738
1739 frame()->SetEditableSelectionOffsets(10, 10);
1740 frame()->DeleteSurroundingText(3, 4);
1741 blink::WebTextInputInfo info = view()->webview()->textInputInfo();
1742 EXPECT_EQ("abcdefgopqrstuvwxyz", info.value);
1743 EXPECT_EQ(7, info.selectionStart);
1744 EXPECT_EQ(7, info.selectionEnd);
1745
1746 frame()->SetEditableSelectionOffsets(4, 8);
1747 frame()->DeleteSurroundingText(2, 5);
1748 info = view()->webview()->textInputInfo();
1749 EXPECT_EQ("abefgouvwxyz", info.value);
1750 EXPECT_EQ(2, info.selectionStart);
1751 EXPECT_EQ(6, info.selectionEnd);
1752
1753 frame()->SetEditableSelectionOffsets(5, 5);
1754 frame()->DeleteSurroundingText(10, 0);
1755 info = view()->webview()->textInputInfo();
1756 EXPECT_EQ("ouvwxyz", info.value);
1757 EXPECT_EQ(0, info.selectionStart);
1758 EXPECT_EQ(0, info.selectionEnd);
1759
1760 frame()->DeleteSurroundingText(0, 10);
1761 info = view()->webview()->textInputInfo();
1762 EXPECT_EQ("", info.value);
1763 EXPECT_EQ(0, info.selectionStart);
1764 EXPECT_EQ(0, info.selectionEnd);
1765
1766 frame()->DeleteSurroundingText(10, 10);
1767 info = view()->webview()->textInputInfo();
1768 EXPECT_EQ("", info.value);
1769
1770 EXPECT_EQ(0, info.selectionStart);
1771 EXPECT_EQ(0, info.selectionEnd);
1772 }
1773
1728 // Test that the navigating specific frames works correctly. 1774 // Test that the navigating specific frames works correctly.
1729 TEST_F(RenderViewImplTest, NavigateSubframe) { 1775 TEST_F(RenderViewImplTest, NavigateSubframe) {
1730 // Load page A. 1776 // Load page A.
1731 LoadHTML("hello <iframe srcdoc='fail' name='frame'></iframe>"); 1777 LoadHTML("hello <iframe srcdoc='fail' name='frame'></iframe>");
1732 1778
1733 // Navigate the frame only. 1779 // Navigate the frame only.
1734 CommonNavigationParams common_params; 1780 CommonNavigationParams common_params;
1735 RequestNavigationParams request_params; 1781 RequestNavigationParams request_params;
1736 common_params.url = GURL("data:text/html,world"); 1782 common_params.url = GURL("data:text/html,world");
1737 common_params.navigation_type = FrameMsg_Navigate_Type::NORMAL; 1783 common_params.navigation_type = FrameMsg_Navigate_Type::NORMAL;
(...skipping 819 matching lines...) Expand 10 before | Expand all | Expand 10 after
2557 ExpectPauseAndResume(3); 2603 ExpectPauseAndResume(3);
2558 blink::WebScriptSource source2( 2604 blink::WebScriptSource source2(
2559 WebString::fromUTF8("function func2() { func1(); }; func2();")); 2605 WebString::fromUTF8("function func2() { func1(); }; func2();"));
2560 frame()->GetWebFrame()->executeScriptInIsolatedWorld(17, &source2, 1, 1); 2606 frame()->GetWebFrame()->executeScriptInIsolatedWorld(17, &source2, 1, 1);
2561 2607
2562 EXPECT_FALSE(IsPaused()); 2608 EXPECT_FALSE(IsPaused());
2563 Detach(); 2609 Detach();
2564 } 2610 }
2565 2611
2566 } // namespace content 2612 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/render_frame_impl.cc ('k') | content/test/test_render_frame.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698