| OLD | NEW |
| 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 236 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 247 request_params.pending_history_list_offset = pending_offset; | 247 request_params.pending_history_list_offset = pending_offset; |
| 248 request_params.current_history_list_offset = view()->history_list_offset_; | 248 request_params.current_history_list_offset = view()->history_list_offset_; |
| 249 request_params.current_history_list_length = view()->history_list_length_; | 249 request_params.current_history_list_length = view()->history_list_length_; |
| 250 frame()->Navigate(common_params, start_params, request_params); | 250 frame()->Navigate(common_params, start_params, request_params); |
| 251 | 251 |
| 252 // The load actually happens asynchronously, so we pump messages to process | 252 // The load actually happens asynchronously, so we pump messages to process |
| 253 // the pending continuation. | 253 // the pending continuation. |
| 254 FrameLoadWaiter(frame()).Wait(); | 254 FrameLoadWaiter(frame()).Wait(); |
| 255 } | 255 } |
| 256 | 256 |
| 257 void SetEditableSelectionOffsets(int start, int end) { |
| 258 frame()->GetRenderWidget()->OnImeSetEditableSelectionOffsets(start, end); |
| 259 } |
| 260 |
| 261 void SetCompositionFromExistingText( |
| 262 int start, |
| 263 int end, |
| 264 const std::vector<blink::WebCompositionUnderline>& underlines) { |
| 265 frame()->GetRenderWidget()->OnImeSetCompositionFromExistingText( |
| 266 start, end, underlines); |
| 267 } |
| 268 |
| 257 template<class T> | 269 template<class T> |
| 258 typename T::Param ProcessAndReadIPC() { | 270 typename T::Param ProcessAndReadIPC() { |
| 259 ProcessPendingMessages(); | 271 ProcessPendingMessages(); |
| 260 const IPC::Message* message = | 272 const IPC::Message* message = |
| 261 render_thread_->sink().GetUniqueMessageMatching(T::ID); | 273 render_thread_->sink().GetUniqueMessageMatching(T::ID); |
| 262 typename T::Param param; | 274 typename T::Param param; |
| 263 EXPECT_TRUE(message); | 275 EXPECT_TRUE(message); |
| 264 if (message) | 276 if (message) |
| 265 T::Read(message, ¶m); | 277 T::Read(message, ¶m); |
| 266 return param; | 278 return param; |
| (...skipping 1411 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1678 TEST_F(RenderViewImplTest, SetEditableSelectionAndComposition) { | 1690 TEST_F(RenderViewImplTest, SetEditableSelectionAndComposition) { |
| 1679 // Load an HTML page consisting of an input field. | 1691 // Load an HTML page consisting of an input field. |
| 1680 LoadHTML("<html>" | 1692 LoadHTML("<html>" |
| 1681 "<head>" | 1693 "<head>" |
| 1682 "</head>" | 1694 "</head>" |
| 1683 "<body>" | 1695 "<body>" |
| 1684 "<input id=\"test1\" value=\"some test text hello\"></input>" | 1696 "<input id=\"test1\" value=\"some test text hello\"></input>" |
| 1685 "</body>" | 1697 "</body>" |
| 1686 "</html>"); | 1698 "</html>"); |
| 1687 ExecuteJavaScriptForTests("document.getElementById('test1').focus();"); | 1699 ExecuteJavaScriptForTests("document.getElementById('test1').focus();"); |
| 1688 frame()->SetEditableSelectionOffsets(4, 8); | 1700 SetEditableSelectionOffsets(4, 8); |
| 1689 const std::vector<blink::WebCompositionUnderline> empty_underline; | 1701 const std::vector<blink::WebCompositionUnderline> empty_underline; |
| 1690 frame()->SetCompositionFromExistingText(7, 10, empty_underline); | 1702 SetCompositionFromExistingText(7, 10, empty_underline); |
| 1691 blink::WebTextInputInfo info = view()->webview()->textInputInfo(); | 1703 blink::WebTextInputInfo info = view()->webview()->textInputInfo(); |
| 1692 EXPECT_EQ(4, info.selectionStart); | 1704 EXPECT_EQ(4, info.selectionStart); |
| 1693 EXPECT_EQ(8, info.selectionEnd); | 1705 EXPECT_EQ(8, info.selectionEnd); |
| 1694 EXPECT_EQ(7, info.compositionStart); | 1706 EXPECT_EQ(7, info.compositionStart); |
| 1695 EXPECT_EQ(10, info.compositionEnd); | 1707 EXPECT_EQ(10, info.compositionEnd); |
| 1696 frame()->Unselect(); | 1708 frame()->Unselect(); |
| 1697 info = view()->webview()->textInputInfo(); | 1709 info = view()->webview()->textInputInfo(); |
| 1698 EXPECT_EQ(0, info.selectionStart); | 1710 EXPECT_EQ(0, info.selectionStart); |
| 1699 EXPECT_EQ(0, info.selectionEnd); | 1711 EXPECT_EQ(0, info.selectionEnd); |
| 1700 } | 1712 } |
| 1701 | 1713 |
| 1702 | |
| 1703 TEST_F(RenderViewImplTest, OnExtendSelectionAndDelete) { | |
| 1704 // Load an HTML page consisting of an input field. | |
| 1705 LoadHTML("<html>" | |
| 1706 "<head>" | |
| 1707 "</head>" | |
| 1708 "<body>" | |
| 1709 "<input id=\"test1\" value=\"abcdefghijklmnopqrstuvwxyz\"></input>" | |
| 1710 "</body>" | |
| 1711 "</html>"); | |
| 1712 ExecuteJavaScriptForTests("document.getElementById('test1').focus();"); | |
| 1713 frame()->SetEditableSelectionOffsets(10, 10); | |
| 1714 frame()->ExtendSelectionAndDelete(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 frame()->SetEditableSelectionOffsets(4, 8); | |
| 1720 frame()->ExtendSelectionAndDelete(2, 5); | |
| 1721 info = view()->webview()->textInputInfo(); | |
| 1722 EXPECT_EQ("abuvwxyz", info.value); | |
| 1723 EXPECT_EQ(2, info.selectionStart); | |
| 1724 EXPECT_EQ(2, info.selectionEnd); | |
| 1725 } | |
| 1726 | |
| 1727 // Test that the navigating specific frames works correctly. | 1714 // Test that the navigating specific frames works correctly. |
| 1728 TEST_F(RenderViewImplTest, NavigateSubframe) { | 1715 TEST_F(RenderViewImplTest, NavigateSubframe) { |
| 1729 // Load page A. | 1716 // Load page A. |
| 1730 LoadHTML("hello <iframe srcdoc='fail' name='frame'></iframe>"); | 1717 LoadHTML("hello <iframe srcdoc='fail' name='frame'></iframe>"); |
| 1731 | 1718 |
| 1732 // Navigate the frame only. | 1719 // Navigate the frame only. |
| 1733 CommonNavigationParams common_params; | 1720 CommonNavigationParams common_params; |
| 1734 RequestNavigationParams request_params; | 1721 RequestNavigationParams request_params; |
| 1735 common_params.url = GURL("data:text/html,world"); | 1722 common_params.url = GURL("data:text/html,world"); |
| 1736 common_params.navigation_type = FrameMsg_Navigate_Type::NORMAL; | 1723 common_params.navigation_type = FrameMsg_Navigate_Type::NORMAL; |
| (...skipping 819 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2556 ExpectPauseAndResume(3); | 2543 ExpectPauseAndResume(3); |
| 2557 blink::WebScriptSource source2( | 2544 blink::WebScriptSource source2( |
| 2558 WebString::fromUTF8("function func2() { func1(); }; func2();")); | 2545 WebString::fromUTF8("function func2() { func1(); }; func2();")); |
| 2559 frame()->GetWebFrame()->executeScriptInIsolatedWorld(17, &source2, 1, 1); | 2546 frame()->GetWebFrame()->executeScriptInIsolatedWorld(17, &source2, 1, 1); |
| 2560 | 2547 |
| 2561 EXPECT_FALSE(IsPaused()); | 2548 EXPECT_FALSE(IsPaused()); |
| 2562 Detach(); | 2549 Detach(); |
| 2563 } | 2550 } |
| 2564 | 2551 |
| 2565 } // namespace content | 2552 } // namespace content |
| OLD | NEW |