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

Side by Side Diff: content/renderer/render_view_browsertest.cc

Issue 1206753003: Add a TestRenderFrame to use in RenderViewTests (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed Nasko's comments Created 5 years, 6 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.h ('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 "base/basictypes.h" 5 #include "base/basictypes.h"
6 #include "base/bind.h" 6 #include "base/bind.h"
7 #include "base/callback.h" 7 #include "base/callback.h"
8 #include "base/location.h" 8 #include "base/location.h"
9 #include "base/memory/shared_memory.h" 9 #include "base/memory/shared_memory.h"
10 #include "base/single_thread_task_runner.h" 10 #include "base/single_thread_task_runner.h"
(...skipping 25 matching lines...) Expand all
36 #include "content/renderer/accessibility/renderer_accessibility.h" 36 #include "content/renderer/accessibility/renderer_accessibility.h"
37 #include "content/renderer/devtools/devtools_agent.h" 37 #include "content/renderer/devtools/devtools_agent.h"
38 #include "content/renderer/history_controller.h" 38 #include "content/renderer/history_controller.h"
39 #include "content/renderer/history_serialization.h" 39 #include "content/renderer/history_serialization.h"
40 #include "content/renderer/navigation_state_impl.h" 40 #include "content/renderer/navigation_state_impl.h"
41 #include "content/renderer/render_process.h" 41 #include "content/renderer/render_process.h"
42 #include "content/renderer/render_view_impl.h" 42 #include "content/renderer/render_view_impl.h"
43 #include "content/shell/browser/shell.h" 43 #include "content/shell/browser/shell.h"
44 #include "content/shell/browser/shell_browser_context.h" 44 #include "content/shell/browser/shell_browser_context.h"
45 #include "content/test/mock_keyboard.h" 45 #include "content/test/mock_keyboard.h"
46 #include "content/test/test_render_frame.h"
46 #include "net/base/net_errors.h" 47 #include "net/base/net_errors.h"
47 #include "net/cert/cert_status_flags.h" 48 #include "net/cert/cert_status_flags.h"
48 #include "testing/gtest/include/gtest/gtest.h" 49 #include "testing/gtest/include/gtest/gtest.h"
49 #include "third_party/WebKit/public/platform/WebData.h" 50 #include "third_party/WebKit/public/platform/WebData.h"
50 #include "third_party/WebKit/public/platform/WebHTTPBody.h" 51 #include "third_party/WebKit/public/platform/WebHTTPBody.h"
51 #include "third_party/WebKit/public/platform/WebString.h" 52 #include "third_party/WebKit/public/platform/WebString.h"
52 #include "third_party/WebKit/public/platform/WebURLResponse.h" 53 #include "third_party/WebKit/public/platform/WebURLResponse.h"
53 #include "third_party/WebKit/public/web/WebDataSource.h" 54 #include "third_party/WebKit/public/web/WebDataSource.h"
54 #include "third_party/WebKit/public/web/WebDeviceEmulationParams.h" 55 #include "third_party/WebKit/public/web/WebDeviceEmulationParams.h"
55 #include "third_party/WebKit/public/web/WebHistoryCommitType.h" 56 #include "third_party/WebKit/public/web/WebHistoryCommitType.h"
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
156 } 157 }
157 158
158 RenderViewImpl* view() { 159 RenderViewImpl* view() {
159 return static_cast<RenderViewImpl*>(view_); 160 return static_cast<RenderViewImpl*>(view_);
160 } 161 }
161 162
162 int view_page_id() { 163 int view_page_id() {
163 return view()->page_id_; 164 return view()->page_id_;
164 } 165 }
165 166
166 RenderFrameImpl* frame() { 167 TestRenderFrame* frame() {
167 return static_cast<RenderFrameImpl*>(view()->GetMainRenderFrame()); 168 return static_cast<TestRenderFrame*>(view()->GetMainRenderFrame());
168 } 169 }
169 170
170 // Sends IPC messages that emulates a key-press event. 171 // Sends IPC messages that emulates a key-press event.
171 int SendKeyEvent(MockKeyboard::Layout layout, 172 int SendKeyEvent(MockKeyboard::Layout layout,
172 int key_code, 173 int key_code,
173 MockKeyboard::Modifiers modifiers, 174 MockKeyboard::Modifiers modifiers,
174 base::string16* output) { 175 base::string16* output) {
175 #if defined(OS_WIN) 176 #if defined(OS_WIN)
176 // Retrieve the Unicode character for the given tuple (keyboard-layout, 177 // Retrieve the Unicode character for the given tuple (keyboard-layout,
177 // key-code, and modifiers). 178 // key-code, and modifiers).
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
282 283
283 const gfx::Size& GetPreferredSize() { 284 const gfx::Size& GetPreferredSize() {
284 view()->CheckPreferredSize(); 285 view()->CheckPreferredSize();
285 return view()->preferred_size_; 286 return view()->preferred_size_;
286 } 287 }
287 288
288 void SetZoomLevel(double level) { 289 void SetZoomLevel(double level) {
289 view()->OnSetZoomLevelForView(false, level); 290 view()->OnSetZoomLevelForView(false, level);
290 } 291 }
291 292
292 void NavigateMainFrame(const CommonNavigationParams& common_params,
293 const StartNavigationParams& start_params,
294 const RequestNavigationParams& request_params) {
295 NavigateFrame(frame(), common_params, start_params, request_params);
296 }
297
298 void NavigateFrame(RenderFrameImpl* frame,
299 const CommonNavigationParams& common_params,
300 const StartNavigationParams& start_params,
301 const RequestNavigationParams& request_params) {
302 // PlzNavigate
303 if (base::CommandLine::ForCurrentProcess()->HasSwitch(
304 switches::kEnableBrowserSideNavigation)) {
305 frame->OnCommitNavigation(ResourceResponseHead(), common_params.url,
306 common_params, request_params);
307 return;
308 }
309 frame->OnNavigate(common_params, start_params, request_params);
310 }
311
312 void SwapOut(RenderFrameImpl* frame,
313 int proxy_routing_id,
314 bool is_loading,
315 const FrameReplicationState& replicated_frame_state) {
316 frame->OnSwapOut(proxy_routing_id, is_loading, replicated_frame_state);
317 }
318
319 void SetEditableSelectionOffsets(int start, int end) {
320 frame()->OnSetEditableSelectionOffsets(start, end);
321 }
322
323 void ExtendSelectionAndDelete(int before, int after) {
324 frame()->OnExtendSelectionAndDelete(before, after);
325 }
326
327 void Unselect() { frame()->OnUnselect(); }
328
329 void SetAccessibilityMode(AccessibilityMode new_mode) {
330 frame()->OnSetAccessibilityMode(new_mode);
331 }
332
333 void SetCompositionFromExistingText(
334 int start,
335 int end,
336 const std::vector<blink::WebCompositionUnderline>& underlines) {
337 frame()->OnSetCompositionFromExistingText(start, end, underlines);
338 }
339
340 private: 293 private:
341 scoped_ptr<MockKeyboard> mock_keyboard_; 294 scoped_ptr<MockKeyboard> mock_keyboard_;
342 }; 295 };
343 296
344 class DevToolsAgentTest : public RenderViewImplTest { 297 class DevToolsAgentTest : public RenderViewImplTest {
345 public: 298 public:
346 void Attach() { 299 void Attach() {
347 std::string host_id = "host_id"; 300 std::string host_id = "host_id";
348 agent()->OnAttach(host_id); 301 agent()->OnAttach(host_id);
349 } 302 }
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
491 request_params.page_id = -1; 444 request_params.page_id = -1;
492 445
493 // Set up post data. 446 // Set up post data.
494 const unsigned char* raw_data = reinterpret_cast<const unsigned char*>( 447 const unsigned char* raw_data = reinterpret_cast<const unsigned char*>(
495 "post \0\ndata"); 448 "post \0\ndata");
496 const unsigned int length = 11; 449 const unsigned int length = 11;
497 const std::vector<unsigned char> post_data(raw_data, raw_data + length); 450 const std::vector<unsigned char> post_data(raw_data, raw_data + length);
498 start_params.is_post = true; 451 start_params.is_post = true;
499 start_params.browser_initiated_post_data = post_data; 452 start_params.browser_initiated_post_data = post_data;
500 453
501 NavigateMainFrame(common_params, start_params, request_params); 454 frame()->Navigate(common_params, start_params, request_params);
502 ProcessPendingMessages(); 455 ProcessPendingMessages();
503 456
504 const IPC::Message* frame_navigate_msg = 457 const IPC::Message* frame_navigate_msg =
505 render_thread_->sink().GetUniqueMessageMatching( 458 render_thread_->sink().GetUniqueMessageMatching(
506 FrameHostMsg_DidCommitProvisionalLoad::ID); 459 FrameHostMsg_DidCommitProvisionalLoad::ID);
507 EXPECT_TRUE(frame_navigate_msg); 460 EXPECT_TRUE(frame_navigate_msg);
508 461
509 FrameHostMsg_DidCommitProvisionalLoad::Param host_nav_params; 462 FrameHostMsg_DidCommitProvisionalLoad::Param host_nav_params;
510 FrameHostMsg_DidCommitProvisionalLoad::Read(frame_navigate_msg, 463 FrameHostMsg_DidCommitProvisionalLoad::Read(frame_navigate_msg,
511 &host_nav_params); 464 &host_nav_params);
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after
679 if (RenderFrameProxy::IsSwappedOutStateForbidden()) { 632 if (RenderFrameProxy::IsSwappedOutStateForbidden()) {
680 return; 633 return;
681 } 634 }
682 LoadHTML("<div>Page A</div>"); 635 LoadHTML("<div>Page A</div>");
683 int initial_page_id = view_page_id(); 636 int initial_page_id = view_page_id();
684 637
685 // Increment the ref count so that we don't exit when swapping out. 638 // Increment the ref count so that we don't exit when swapping out.
686 RenderProcess::current()->AddRefProcess(); 639 RenderProcess::current()->AddRefProcess();
687 640
688 // Respond to a swap out request. 641 // Respond to a swap out request.
689 SwapOut(frame(), kProxyRoutingId, true, content::FrameReplicationState()); 642 frame()->SwapOut(kProxyRoutingId, true, content::FrameReplicationState());
690 643
691 // Ensure the swap out commits synchronously. 644 // Ensure the swap out commits synchronously.
692 EXPECT_NE(initial_page_id, view_page_id()); 645 EXPECT_NE(initial_page_id, view_page_id());
693 646
694 // Check for a valid OnSwapOutACK. 647 // Check for a valid OnSwapOutACK.
695 const IPC::Message* msg = render_thread_->sink().GetUniqueMessageMatching( 648 const IPC::Message* msg = render_thread_->sink().GetUniqueMessageMatching(
696 FrameHostMsg_SwapOut_ACK::ID); 649 FrameHostMsg_SwapOut_ACK::ID);
697 ASSERT_TRUE(msg); 650 ASSERT_TRUE(msg);
698 651
699 // It is possible to get another swap out request. Ensure that we send 652 // It is possible to get another swap out request. Ensure that we send
700 // an ACK, even if we don't have to do anything else. 653 // an ACK, even if we don't have to do anything else.
701 render_thread_->sink().ClearMessages(); 654 render_thread_->sink().ClearMessages();
702 SwapOut(frame(), kProxyRoutingId, false, content::FrameReplicationState()); 655 frame()->SwapOut(kProxyRoutingId, false, content::FrameReplicationState());
703 const IPC::Message* msg2 = render_thread_->sink().GetUniqueMessageMatching( 656 const IPC::Message* msg2 = render_thread_->sink().GetUniqueMessageMatching(
704 FrameHostMsg_SwapOut_ACK::ID); 657 FrameHostMsg_SwapOut_ACK::ID);
705 ASSERT_TRUE(msg2); 658 ASSERT_TRUE(msg2);
706 659
707 // If we navigate back to this RenderView, ensure we don't send a state 660 // If we navigate back to this RenderView, ensure we don't send a state
708 // update for the swapped out URL. (http://crbug.com/72235) 661 // update for the swapped out URL. (http://crbug.com/72235)
709 CommonNavigationParams common_params; 662 CommonNavigationParams common_params;
710 RequestNavigationParams request_params; 663 RequestNavigationParams request_params;
711 common_params.url = GURL("data:text/html,<div>Page B</div>"); 664 common_params.url = GURL("data:text/html,<div>Page B</div>");
712 common_params.navigation_type = FrameMsg_Navigate_Type::NORMAL; 665 common_params.navigation_type = FrameMsg_Navigate_Type::NORMAL;
713 common_params.transition = ui::PAGE_TRANSITION_TYPED; 666 common_params.transition = ui::PAGE_TRANSITION_TYPED;
714 request_params.current_history_list_length = 1; 667 request_params.current_history_list_length = 1;
715 request_params.current_history_list_offset = 0; 668 request_params.current_history_list_offset = 0;
716 request_params.pending_history_list_offset = 1; 669 request_params.pending_history_list_offset = 1;
717 request_params.page_id = -1; 670 request_params.page_id = -1;
718 NavigateMainFrame(common_params, StartNavigationParams(), request_params); 671 frame()->Navigate(common_params, StartNavigationParams(), request_params);
719 ProcessPendingMessages(); 672 ProcessPendingMessages();
720 const IPC::Message* msg3 = render_thread_->sink().GetUniqueMessageMatching( 673 const IPC::Message* msg3 = render_thread_->sink().GetUniqueMessageMatching(
721 ViewHostMsg_UpdateState::ID); 674 ViewHostMsg_UpdateState::ID);
722 EXPECT_FALSE(msg3); 675 EXPECT_FALSE(msg3);
723 } 676 }
724 677
725 // Ensure the RenderViewImpl reloads the previous page if a reload request 678 // Ensure the RenderViewImpl reloads the previous page if a reload request
726 // arrives while it is showing swappedout://. http://crbug.com/143155. 679 // arrives while it is showing swappedout://. http://crbug.com/143155.
727 TEST_F(RenderViewImplTest, ReloadWhileSwappedOut) { 680 TEST_F(RenderViewImplTest, ReloadWhileSwappedOut) {
728 // This test is invalid in --site-per-process mode, as swapped-out is no 681 // This test is invalid in --site-per-process mode, as swapped-out is no
(...skipping 24 matching lines...) Expand all
753 CommonNavigationParams common_params_A; 706 CommonNavigationParams common_params_A;
754 RequestNavigationParams request_params_A; 707 RequestNavigationParams request_params_A;
755 common_params_A.navigation_type = FrameMsg_Navigate_Type::NORMAL; 708 common_params_A.navigation_type = FrameMsg_Navigate_Type::NORMAL;
756 common_params_A.transition = ui::PAGE_TRANSITION_FORWARD_BACK; 709 common_params_A.transition = ui::PAGE_TRANSITION_FORWARD_BACK;
757 request_params_A.current_history_list_length = 2; 710 request_params_A.current_history_list_length = 2;
758 request_params_A.current_history_list_offset = 1; 711 request_params_A.current_history_list_offset = 1;
759 request_params_A.pending_history_list_offset = 0; 712 request_params_A.pending_history_list_offset = 0;
760 request_params_A.page_id = 1; 713 request_params_A.page_id = 1;
761 request_params_A.nav_entry_id = 1; 714 request_params_A.nav_entry_id = 1;
762 request_params_A.page_state = state_A; 715 request_params_A.page_state = state_A;
763 NavigateMainFrame(common_params_A, StartNavigationParams(), request_params_A); 716 frame()->Navigate(common_params_A, StartNavigationParams(), request_params_A);
764 EXPECT_EQ(1, view()->historyBackListCount()); 717 EXPECT_EQ(1, view()->historyBackListCount());
765 EXPECT_EQ(2, view()->historyBackListCount() + 718 EXPECT_EQ(2, view()->historyBackListCount() +
766 view()->historyForwardListCount() + 1); 719 view()->historyForwardListCount() + 1);
767 ProcessPendingMessages(); 720 ProcessPendingMessages();
768 721
769 // Respond to a swap out request. 722 // Respond to a swap out request.
770 SwapOut(frame(), kProxyRoutingId, true, content::FrameReplicationState()); 723 frame()->SwapOut(kProxyRoutingId, true, content::FrameReplicationState());
771 724
772 // Check for a OnSwapOutACK. 725 // Check for a OnSwapOutACK.
773 const IPC::Message* msg = render_thread_->sink().GetUniqueMessageMatching( 726 const IPC::Message* msg = render_thread_->sink().GetUniqueMessageMatching(
774 FrameHostMsg_SwapOut_ACK::ID); 727 FrameHostMsg_SwapOut_ACK::ID);
775 ASSERT_TRUE(msg); 728 ASSERT_TRUE(msg);
776 render_thread_->sink().ClearMessages(); 729 render_thread_->sink().ClearMessages();
777 730
778 // It is possible to get a reload request at this point, containing the 731 // It is possible to get a reload request at this point, containing the
779 // params.page_state of the initial page (e.g., if the new page fails the 732 // params.page_state of the initial page (e.g., if the new page fails the
780 // provisional load in the renderer process, after we unload the old page). 733 // provisional load in the renderer process, after we unload the old page).
781 // Ensure the old page gets reloaded, not swappedout://. 734 // Ensure the old page gets reloaded, not swappedout://.
782 CommonNavigationParams common_params; 735 CommonNavigationParams common_params;
783 RequestNavigationParams request_params; 736 RequestNavigationParams request_params;
784 common_params.url = GURL("data:text/html,<div>Page A</div>"); 737 common_params.url = GURL("data:text/html,<div>Page A</div>");
785 common_params.navigation_type = FrameMsg_Navigate_Type::RELOAD; 738 common_params.navigation_type = FrameMsg_Navigate_Type::RELOAD;
786 common_params.transition = ui::PAGE_TRANSITION_RELOAD; 739 common_params.transition = ui::PAGE_TRANSITION_RELOAD;
787 request_params.current_history_list_length = 2; 740 request_params.current_history_list_length = 2;
788 request_params.current_history_list_offset = 0; 741 request_params.current_history_list_offset = 0;
789 request_params.pending_history_list_offset = 0; 742 request_params.pending_history_list_offset = 0;
790 request_params.page_id = 1; 743 request_params.page_id = 1;
791 request_params.nav_entry_id = 1; 744 request_params.nav_entry_id = 1;
792 request_params.page_state = state_A; 745 request_params.page_state = state_A;
793 NavigateMainFrame(common_params, StartNavigationParams(), request_params); 746 frame()->Navigate(common_params, StartNavigationParams(), request_params);
794 ProcessPendingMessages(); 747 ProcessPendingMessages();
795 748
796 // Verify page A committed, not swappedout://. 749 // Verify page A committed, not swappedout://.
797 const IPC::Message* frame_navigate_msg = 750 const IPC::Message* frame_navigate_msg =
798 render_thread_->sink().GetUniqueMessageMatching( 751 render_thread_->sink().GetUniqueMessageMatching(
799 FrameHostMsg_DidCommitProvisionalLoad::ID); 752 FrameHostMsg_DidCommitProvisionalLoad::ID);
800 EXPECT_TRUE(frame_navigate_msg); 753 EXPECT_TRUE(frame_navigate_msg);
801 754
802 // Read URL out of the parent trait of the params object. 755 // Read URL out of the parent trait of the params object.
803 FrameHostMsg_DidCommitProvisionalLoad::Param commit_load_params; 756 FrameHostMsg_DidCommitProvisionalLoad::Param commit_load_params;
804 FrameHostMsg_DidCommitProvisionalLoad::Read(frame_navigate_msg, 757 FrameHostMsg_DidCommitProvisionalLoad::Read(frame_navigate_msg,
805 &commit_load_params); 758 &commit_load_params);
806 EXPECT_NE(GURL("swappedout://"), base::get<0>(commit_load_params).url); 759 EXPECT_NE(GURL("swappedout://"), base::get<0>(commit_load_params).url);
807 } 760 }
808 761
809 // Verify that security origins are replicated properly to RenderFrameProxies 762 // Verify that security origins are replicated properly to RenderFrameProxies
810 // when swapping out. 763 // when swapping out.
811 TEST_F(RenderViewImplTest, OriginReplicationForSwapOut) { 764 TEST_F(RenderViewImplTest, OriginReplicationForSwapOut) {
812 // This test should only run with --site-per-process, since origin 765 // This test should only run with --site-per-process, since origin
813 // replication only happens in that mode. 766 // replication only happens in that mode.
814 if (!base::CommandLine::ForCurrentProcess()->HasSwitch( 767 if (!base::CommandLine::ForCurrentProcess()->HasSwitch(
815 switches::kSitePerProcess)) 768 switches::kSitePerProcess))
816 return; 769 return;
817 770
818 LoadHTML( 771 LoadHTML(
819 "Hello <iframe src='data:text/html,frame 1'></iframe>" 772 "Hello <iframe src='data:text/html,frame 1'></iframe>"
820 "<iframe src='data:text/html,frame 2'></iframe>"); 773 "<iframe src='data:text/html,frame 2'></iframe>");
821 WebFrame* web_frame = frame()->GetWebFrame(); 774 WebFrame* web_frame = frame()->GetWebFrame();
822 RenderFrameImpl* child_frame = static_cast<RenderFrameImpl*>( 775 TestRenderFrame* child_frame = static_cast<TestRenderFrame*>(
823 RenderFrame::FromWebFrame(web_frame->firstChild())); 776 RenderFrame::FromWebFrame(web_frame->firstChild()));
824 777
825 // Swap the child frame out and pass a serialized origin to be set for 778 // Swap the child frame out and pass a serialized origin to be set for
826 // WebRemoteFrame. 779 // WebRemoteFrame.
827 content::FrameReplicationState replication_state; 780 content::FrameReplicationState replication_state;
828 replication_state.origin = url::Origin("http://foo.com"); 781 replication_state.origin = url::Origin("http://foo.com");
829 SwapOut(child_frame, kProxyRoutingId, true, replication_state); 782 child_frame->SwapOut(kProxyRoutingId, true, replication_state);
830 783
831 // The child frame should now be a WebRemoteFrame. 784 // The child frame should now be a WebRemoteFrame.
832 EXPECT_TRUE(web_frame->firstChild()->isWebRemoteFrame()); 785 EXPECT_TRUE(web_frame->firstChild()->isWebRemoteFrame());
833 786
834 // Expect the origin to be updated properly. 787 // Expect the origin to be updated properly.
835 blink::WebSecurityOrigin origin = web_frame->firstChild()->securityOrigin(); 788 blink::WebSecurityOrigin origin = web_frame->firstChild()->securityOrigin();
836 EXPECT_EQ(origin.toString(), 789 EXPECT_EQ(origin.toString(),
837 WebString::fromUTF8(replication_state.origin.string())); 790 WebString::fromUTF8(replication_state.origin.string()));
838 791
839 // Now, swap out the second frame using a unique origin and verify that it is 792 // Now, swap out the second frame using a unique origin and verify that it is
840 // replicated correctly. 793 // replicated correctly.
841 replication_state.origin = url::Origin(); 794 replication_state.origin = url::Origin();
842 RenderFrameImpl* child_frame2 = static_cast<RenderFrameImpl*>( 795 TestRenderFrame* child_frame2 = static_cast<TestRenderFrame*>(
843 RenderFrame::FromWebFrame(web_frame->lastChild())); 796 RenderFrame::FromWebFrame(web_frame->lastChild()));
844 SwapOut(child_frame2, kProxyRoutingId + 1, true, replication_state); 797 child_frame2->SwapOut(kProxyRoutingId + 1, true, replication_state);
845 EXPECT_TRUE(web_frame->lastChild()->isWebRemoteFrame()); 798 EXPECT_TRUE(web_frame->lastChild()->isWebRemoteFrame());
846 EXPECT_TRUE(web_frame->lastChild()->securityOrigin().isUnique()); 799 EXPECT_TRUE(web_frame->lastChild()->securityOrigin().isUnique());
847 } 800 }
848 801
849 // Test that we get the correct UpdateState message when we go back twice 802 // Test that we get the correct UpdateState message when we go back twice
850 // quickly without committing. Regression test for http://crbug.com/58082. 803 // quickly without committing. Regression test for http://crbug.com/58082.
851 // Disabled: http://crbug.com/157357 . 804 // Disabled: http://crbug.com/157357 .
852 TEST_F(RenderViewImplTest, DISABLED_LastCommittedUpdateState) { 805 TEST_F(RenderViewImplTest, DISABLED_LastCommittedUpdateState) {
853 // Load page A. 806 // Load page A.
854 LoadHTML("<div>Page A</div>"); 807 LoadHTML("<div>Page A</div>");
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
901 // Go back to C and commit, preparing for our real test. 854 // Go back to C and commit, preparing for our real test.
902 CommonNavigationParams common_params_C; 855 CommonNavigationParams common_params_C;
903 RequestNavigationParams request_params_C; 856 RequestNavigationParams request_params_C;
904 common_params_C.navigation_type = FrameMsg_Navigate_Type::NORMAL; 857 common_params_C.navigation_type = FrameMsg_Navigate_Type::NORMAL;
905 common_params_C.transition = ui::PAGE_TRANSITION_FORWARD_BACK; 858 common_params_C.transition = ui::PAGE_TRANSITION_FORWARD_BACK;
906 request_params_C.current_history_list_length = 4; 859 request_params_C.current_history_list_length = 4;
907 request_params_C.current_history_list_offset = 3; 860 request_params_C.current_history_list_offset = 3;
908 request_params_C.pending_history_list_offset = 2; 861 request_params_C.pending_history_list_offset = 2;
909 request_params_C.page_id = 3; 862 request_params_C.page_id = 3;
910 request_params_C.page_state = state_C; 863 request_params_C.page_state = state_C;
911 NavigateMainFrame(common_params_C, StartNavigationParams(), request_params_C); 864 frame()->Navigate(common_params_C, StartNavigationParams(), request_params_C);
912 ProcessPendingMessages(); 865 ProcessPendingMessages();
913 render_thread_->sink().ClearMessages(); 866 render_thread_->sink().ClearMessages();
914 867
915 // Go back twice quickly, such that page B does not have a chance to commit. 868 // Go back twice quickly, such that page B does not have a chance to commit.
916 // This leads to two changes to the back/forward list but only one change to 869 // This leads to two changes to the back/forward list but only one change to
917 // the RenderView's page ID. 870 // the RenderView's page ID.
918 871
919 // Back to page B (page_id 2), without committing. 872 // Back to page B (page_id 2), without committing.
920 CommonNavigationParams common_params_B; 873 CommonNavigationParams common_params_B;
921 RequestNavigationParams request_params_B; 874 RequestNavigationParams request_params_B;
922 common_params_B.navigation_type = FrameMsg_Navigate_Type::NORMAL; 875 common_params_B.navigation_type = FrameMsg_Navigate_Type::NORMAL;
923 common_params_B.transition = ui::PAGE_TRANSITION_FORWARD_BACK; 876 common_params_B.transition = ui::PAGE_TRANSITION_FORWARD_BACK;
924 request_params_B.current_history_list_length = 4; 877 request_params_B.current_history_list_length = 4;
925 request_params_B.current_history_list_offset = 2; 878 request_params_B.current_history_list_offset = 2;
926 request_params_B.pending_history_list_offset = 1; 879 request_params_B.pending_history_list_offset = 1;
927 request_params_B.page_id = 2; 880 request_params_B.page_id = 2;
928 request_params_B.page_state = state_B; 881 request_params_B.page_state = state_B;
929 NavigateMainFrame(common_params_B, StartNavigationParams(), request_params_B); 882 frame()->Navigate(common_params_B, StartNavigationParams(), request_params_B);
930 883
931 // Back to page A (page_id 1) and commit. 884 // Back to page A (page_id 1) and commit.
932 CommonNavigationParams common_params; 885 CommonNavigationParams common_params;
933 RequestNavigationParams request_params; 886 RequestNavigationParams request_params;
934 common_params.navigation_type = FrameMsg_Navigate_Type::NORMAL; 887 common_params.navigation_type = FrameMsg_Navigate_Type::NORMAL;
935 common_params.transition = ui::PAGE_TRANSITION_FORWARD_BACK; 888 common_params.transition = ui::PAGE_TRANSITION_FORWARD_BACK;
936 request_params.current_history_list_length = 4; 889 request_params.current_history_list_length = 4;
937 request_params.current_history_list_offset = 2; 890 request_params.current_history_list_offset = 2;
938 request_params.pending_history_list_offset = 0; 891 request_params.pending_history_list_offset = 0;
939 request_params.page_id = 1; 892 request_params.page_id = 1;
940 request_params.page_state = state_A; 893 request_params.page_state = state_A;
941 NavigateMainFrame(common_params, StartNavigationParams(), request_params); 894 frame()->Navigate(common_params, StartNavigationParams(), request_params);
942 ProcessPendingMessages(); 895 ProcessPendingMessages();
943 896
944 // Now ensure that the UpdateState message we receive is consistent 897 // Now ensure that the UpdateState message we receive is consistent
945 // and represents page C in both page_id and state. 898 // and represents page C in both page_id and state.
946 const IPC::Message* msg = render_thread_->sink().GetUniqueMessageMatching( 899 const IPC::Message* msg = render_thread_->sink().GetUniqueMessageMatching(
947 ViewHostMsg_UpdateState::ID); 900 ViewHostMsg_UpdateState::ID);
948 ASSERT_TRUE(msg); 901 ASSERT_TRUE(msg);
949 ViewHostMsg_UpdateState::Read(msg, &param); 902 ViewHostMsg_UpdateState::Read(msg, &param);
950 int page_id = base::get<0>(param); 903 int page_id = base::get<0>(param);
951 PageState state = base::get<1>(param); 904 PageState state = base::get<1>(param);
(...skipping 689 matching lines...) Expand 10 before | Expand all | Expand 10 after
1641 error.domain = WebString::fromUTF8(net::kErrorDomain); 1594 error.domain = WebString::fromUTF8(net::kErrorDomain);
1642 error.reason = net::ERR_FILE_NOT_FOUND; 1595 error.reason = net::ERR_FILE_NOT_FOUND;
1643 error.unreachableURL = GURL("http://foo"); 1596 error.unreachableURL = GURL("http://foo");
1644 WebLocalFrame* web_frame = GetMainFrame(); 1597 WebLocalFrame* web_frame = GetMainFrame();
1645 1598
1646 // Start a load that will reach provisional state synchronously, 1599 // Start a load that will reach provisional state synchronously,
1647 // but won't complete synchronously. 1600 // but won't complete synchronously.
1648 CommonNavigationParams common_params; 1601 CommonNavigationParams common_params;
1649 common_params.navigation_type = FrameMsg_Navigate_Type::NORMAL; 1602 common_params.navigation_type = FrameMsg_Navigate_Type::NORMAL;
1650 common_params.url = GURL("data:text/html,test data"); 1603 common_params.url = GURL("data:text/html,test data");
1651 NavigateMainFrame(common_params, StartNavigationParams(), 1604 frame()->Navigate(common_params, StartNavigationParams(),
1652 RequestNavigationParams()); 1605 RequestNavigationParams());
1653 1606
1654 // An error occurred. 1607 // An error occurred.
1655 view()->GetMainRenderFrame()->didFailProvisionalLoad( 1608 view()->GetMainRenderFrame()->didFailProvisionalLoad(
1656 web_frame, error, blink::WebStandardCommit); 1609 web_frame, error, blink::WebStandardCommit);
1657 // Frame should exit view-source mode. 1610 // Frame should exit view-source mode.
1658 EXPECT_FALSE(web_frame->isViewSourceModeEnabled()); 1611 EXPECT_FALSE(web_frame->isViewSourceModeEnabled());
1659 } 1612 }
1660 1613
1661 TEST_F(RenderViewImplTest, DidFailProvisionalLoadWithErrorForCancellation) { 1614 TEST_F(RenderViewImplTest, DidFailProvisionalLoadWithErrorForCancellation) {
1662 GetMainFrame()->enableViewSourceMode(true); 1615 GetMainFrame()->enableViewSourceMode(true);
1663 WebURLError error; 1616 WebURLError error;
1664 error.domain = WebString::fromUTF8(net::kErrorDomain); 1617 error.domain = WebString::fromUTF8(net::kErrorDomain);
1665 error.reason = net::ERR_ABORTED; 1618 error.reason = net::ERR_ABORTED;
1666 error.unreachableURL = GURL("http://foo"); 1619 error.unreachableURL = GURL("http://foo");
1667 WebLocalFrame* web_frame = GetMainFrame(); 1620 WebLocalFrame* web_frame = GetMainFrame();
1668 1621
1669 // Start a load that will reach provisional state synchronously, 1622 // Start a load that will reach provisional state synchronously,
1670 // but won't complete synchronously. 1623 // but won't complete synchronously.
1671 CommonNavigationParams common_params; 1624 CommonNavigationParams common_params;
1672 common_params.navigation_type = FrameMsg_Navigate_Type::NORMAL; 1625 common_params.navigation_type = FrameMsg_Navigate_Type::NORMAL;
1673 common_params.url = GURL("data:text/html,test data"); 1626 common_params.url = GURL("data:text/html,test data");
1674 NavigateMainFrame(common_params, StartNavigationParams(), 1627 frame()->Navigate(common_params, StartNavigationParams(),
1675 RequestNavigationParams()); 1628 RequestNavigationParams());
1676 1629
1677 // A cancellation occurred. 1630 // A cancellation occurred.
1678 view()->GetMainRenderFrame()->didFailProvisionalLoad( 1631 view()->GetMainRenderFrame()->didFailProvisionalLoad(
1679 web_frame, error, blink::WebStandardCommit); 1632 web_frame, error, blink::WebStandardCommit);
1680 // Frame should stay in view-source mode. 1633 // Frame should stay in view-source mode.
1681 EXPECT_TRUE(web_frame->isViewSourceModeEnabled()); 1634 EXPECT_TRUE(web_frame->isViewSourceModeEnabled());
1682 } 1635 }
1683 1636
1684 // Regression test for http://crbug.com/41562 1637 // Regression test for http://crbug.com/41562
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after
1862 TEST_F(RenderViewImplTest, ZoomLimit) { 1815 TEST_F(RenderViewImplTest, ZoomLimit) {
1863 const double kMinZoomLevel = ZoomFactorToZoomLevel(kMinimumZoomFactor); 1816 const double kMinZoomLevel = ZoomFactorToZoomLevel(kMinimumZoomFactor);
1864 const double kMaxZoomLevel = ZoomFactorToZoomLevel(kMaximumZoomFactor); 1817 const double kMaxZoomLevel = ZoomFactorToZoomLevel(kMaximumZoomFactor);
1865 1818
1866 // Verifies navigation to a URL with preset zoom level indeed sets the level. 1819 // Verifies navigation to a URL with preset zoom level indeed sets the level.
1867 // Regression test for http://crbug.com/139559, where the level was not 1820 // Regression test for http://crbug.com/139559, where the level was not
1868 // properly set when it is out of the default zoom limits of WebView. 1821 // properly set when it is out of the default zoom limits of WebView.
1869 CommonNavigationParams common_params; 1822 CommonNavigationParams common_params;
1870 common_params.url = GURL("data:text/html,min_zoomlimit_test"); 1823 common_params.url = GURL("data:text/html,min_zoomlimit_test");
1871 view()->OnSetZoomLevelForLoadingURL(common_params.url, kMinZoomLevel); 1824 view()->OnSetZoomLevelForLoadingURL(common_params.url, kMinZoomLevel);
1872 NavigateMainFrame(common_params, StartNavigationParams(), 1825 frame()->Navigate(common_params, StartNavigationParams(),
1873 RequestNavigationParams()); 1826 RequestNavigationParams());
1874 ProcessPendingMessages(); 1827 ProcessPendingMessages();
1875 EXPECT_DOUBLE_EQ(kMinZoomLevel, view()->GetWebView()->zoomLevel()); 1828 EXPECT_DOUBLE_EQ(kMinZoomLevel, view()->GetWebView()->zoomLevel());
1876 1829
1877 // It should work even when the zoom limit is temporarily changed in the page. 1830 // It should work even when the zoom limit is temporarily changed in the page.
1878 view()->GetWebView()->zoomLimitsChanged(ZoomFactorToZoomLevel(1.0), 1831 view()->GetWebView()->zoomLimitsChanged(ZoomFactorToZoomLevel(1.0),
1879 ZoomFactorToZoomLevel(1.0)); 1832 ZoomFactorToZoomLevel(1.0));
1880 common_params.url = GURL("data:text/html,max_zoomlimit_test"); 1833 common_params.url = GURL("data:text/html,max_zoomlimit_test");
1881 view()->OnSetZoomLevelForLoadingURL(common_params.url, kMaxZoomLevel); 1834 view()->OnSetZoomLevelForLoadingURL(common_params.url, kMaxZoomLevel);
1882 NavigateMainFrame(common_params, StartNavigationParams(), 1835 frame()->Navigate(common_params, StartNavigationParams(),
1883 RequestNavigationParams()); 1836 RequestNavigationParams());
1884 ProcessPendingMessages(); 1837 ProcessPendingMessages();
1885 EXPECT_DOUBLE_EQ(kMaxZoomLevel, view()->GetWebView()->zoomLevel()); 1838 EXPECT_DOUBLE_EQ(kMaxZoomLevel, view()->GetWebView()->zoomLevel());
1886 } 1839 }
1887 1840
1888 TEST_F(RenderViewImplTest, SetEditableSelectionAndComposition) { 1841 TEST_F(RenderViewImplTest, SetEditableSelectionAndComposition) {
1889 // Load an HTML page consisting of an input field. 1842 // Load an HTML page consisting of an input field.
1890 LoadHTML("<html>" 1843 LoadHTML("<html>"
1891 "<head>" 1844 "<head>"
1892 "</head>" 1845 "</head>"
1893 "<body>" 1846 "<body>"
1894 "<input id=\"test1\" value=\"some test text hello\"></input>" 1847 "<input id=\"test1\" value=\"some test text hello\"></input>"
1895 "</body>" 1848 "</body>"
1896 "</html>"); 1849 "</html>");
1897 ExecuteJavaScript("document.getElementById('test1').focus();"); 1850 ExecuteJavaScript("document.getElementById('test1').focus();");
1898 SetEditableSelectionOffsets(4, 8); 1851 frame()->SetEditableSelectionOffsets(4, 8);
1899 const std::vector<blink::WebCompositionUnderline> empty_underline; 1852 const std::vector<blink::WebCompositionUnderline> empty_underline;
1900 SetCompositionFromExistingText(7, 10, empty_underline); 1853 frame()->SetCompositionFromExistingText(7, 10, empty_underline);
1901 blink::WebTextInputInfo info = view()->webview()->textInputInfo(); 1854 blink::WebTextInputInfo info = view()->webview()->textInputInfo();
1902 EXPECT_EQ(4, info.selectionStart); 1855 EXPECT_EQ(4, info.selectionStart);
1903 EXPECT_EQ(8, info.selectionEnd); 1856 EXPECT_EQ(8, info.selectionEnd);
1904 EXPECT_EQ(7, info.compositionStart); 1857 EXPECT_EQ(7, info.compositionStart);
1905 EXPECT_EQ(10, info.compositionEnd); 1858 EXPECT_EQ(10, info.compositionEnd);
1906 Unselect(); 1859 frame()->Unselect();
1907 info = view()->webview()->textInputInfo(); 1860 info = view()->webview()->textInputInfo();
1908 EXPECT_EQ(0, info.selectionStart); 1861 EXPECT_EQ(0, info.selectionStart);
1909 EXPECT_EQ(0, info.selectionEnd); 1862 EXPECT_EQ(0, info.selectionEnd);
1910 } 1863 }
1911 1864
1912 1865
1913 TEST_F(RenderViewImplTest, OnExtendSelectionAndDelete) { 1866 TEST_F(RenderViewImplTest, OnExtendSelectionAndDelete) {
1914 // Load an HTML page consisting of an input field. 1867 // Load an HTML page consisting of an input field.
1915 LoadHTML("<html>" 1868 LoadHTML("<html>"
1916 "<head>" 1869 "<head>"
1917 "</head>" 1870 "</head>"
1918 "<body>" 1871 "<body>"
1919 "<input id=\"test1\" value=\"abcdefghijklmnopqrstuvwxyz\"></input>" 1872 "<input id=\"test1\" value=\"abcdefghijklmnopqrstuvwxyz\"></input>"
1920 "</body>" 1873 "</body>"
1921 "</html>"); 1874 "</html>");
1922 ExecuteJavaScript("document.getElementById('test1').focus();"); 1875 ExecuteJavaScript("document.getElementById('test1').focus();");
1923 SetEditableSelectionOffsets(10, 10); 1876 frame()->SetEditableSelectionOffsets(10, 10);
1924 ExtendSelectionAndDelete(3, 4); 1877 frame()->ExtendSelectionAndDelete(3, 4);
1925 blink::WebTextInputInfo info = view()->webview()->textInputInfo(); 1878 blink::WebTextInputInfo info = view()->webview()->textInputInfo();
1926 EXPECT_EQ("abcdefgopqrstuvwxyz", info.value); 1879 EXPECT_EQ("abcdefgopqrstuvwxyz", info.value);
1927 EXPECT_EQ(7, info.selectionStart); 1880 EXPECT_EQ(7, info.selectionStart);
1928 EXPECT_EQ(7, info.selectionEnd); 1881 EXPECT_EQ(7, info.selectionEnd);
1929 SetEditableSelectionOffsets(4, 8); 1882 frame()->SetEditableSelectionOffsets(4, 8);
1930 ExtendSelectionAndDelete(2, 5); 1883 frame()->ExtendSelectionAndDelete(2, 5);
1931 info = view()->webview()->textInputInfo(); 1884 info = view()->webview()->textInputInfo();
1932 EXPECT_EQ("abuvwxyz", info.value); 1885 EXPECT_EQ("abuvwxyz", info.value);
1933 EXPECT_EQ(2, info.selectionStart); 1886 EXPECT_EQ(2, info.selectionStart);
1934 EXPECT_EQ(2, info.selectionEnd); 1887 EXPECT_EQ(2, info.selectionEnd);
1935 } 1888 }
1936 1889
1937 // Test that the navigating specific frames works correctly. 1890 // Test that the navigating specific frames works correctly.
1938 TEST_F(RenderViewImplTest, NavigateSubframe) { 1891 TEST_F(RenderViewImplTest, NavigateSubframe) {
1939 // Load page A. 1892 // Load page A.
1940 LoadHTML("hello <iframe srcdoc='fail' name='frame'></iframe>"); 1893 LoadHTML("hello <iframe srcdoc='fail' name='frame'></iframe>");
1941 1894
1942 // Navigate the frame only. 1895 // Navigate the frame only.
1943 CommonNavigationParams common_params; 1896 CommonNavigationParams common_params;
1944 RequestNavigationParams request_params; 1897 RequestNavigationParams request_params;
1945 common_params.url = GURL("data:text/html,world"); 1898 common_params.url = GURL("data:text/html,world");
1946 common_params.navigation_type = FrameMsg_Navigate_Type::NORMAL; 1899 common_params.navigation_type = FrameMsg_Navigate_Type::NORMAL;
1947 common_params.transition = ui::PAGE_TRANSITION_TYPED; 1900 common_params.transition = ui::PAGE_TRANSITION_TYPED;
1948 request_params.current_history_list_length = 1; 1901 request_params.current_history_list_length = 1;
1949 request_params.current_history_list_offset = 0; 1902 request_params.current_history_list_offset = 0;
1950 request_params.pending_history_list_offset = 1; 1903 request_params.pending_history_list_offset = 1;
1951 request_params.page_id = -1; 1904 request_params.page_id = -1;
1952 request_params.browser_navigation_start = 1905 request_params.browser_navigation_start =
1953 base::TimeTicks::FromInternalValue(1); 1906 base::TimeTicks::FromInternalValue(1);
1954 1907
1955 RenderFrameImpl* subframe = RenderFrameImpl::FromWebFrame( 1908 TestRenderFrame* subframe =
1956 view()->webview()->findFrameByName("frame")); 1909 static_cast<TestRenderFrame*>(RenderFrameImpl::FromWebFrame(
1957 NavigateFrame(subframe, common_params, StartNavigationParams(), 1910 view()->webview()->findFrameByName("frame")));
1958 request_params); 1911 subframe->Navigate(common_params, StartNavigationParams(), request_params);
1959 FrameLoadWaiter(subframe).Wait(); 1912 FrameLoadWaiter(subframe).Wait();
1960 1913
1961 // Copy the document content to std::wstring and compare with the 1914 // Copy the document content to std::wstring and compare with the
1962 // expected result. 1915 // expected result.
1963 const int kMaxOutputCharacters = 256; 1916 const int kMaxOutputCharacters = 256;
1964 std::string output = base::UTF16ToUTF8( 1917 std::string output = base::UTF16ToUTF8(
1965 GetMainFrame()->contentAsText(kMaxOutputCharacters)); 1918 GetMainFrame()->contentAsText(kMaxOutputCharacters));
1966 EXPECT_EQ(output, "hello \n\nworld"); 1919 EXPECT_EQ(output, "hello \n\nworld");
1967 } 1920 }
1968 1921
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
2064 error.domain = WebString::fromUTF8(net::kErrorDomain); 2017 error.domain = WebString::fromUTF8(net::kErrorDomain);
2065 error.reason = net::ERR_FILE_NOT_FOUND; 2018 error.reason = net::ERR_FILE_NOT_FOUND;
2066 error.unreachableURL = GURL("http://example.com/suppress"); 2019 error.unreachableURL = GURL("http://example.com/suppress");
2067 WebLocalFrame* web_frame = GetMainFrame(); 2020 WebLocalFrame* web_frame = GetMainFrame();
2068 2021
2069 // Start a load that will reach provisional state synchronously, 2022 // Start a load that will reach provisional state synchronously,
2070 // but won't complete synchronously. 2023 // but won't complete synchronously.
2071 CommonNavigationParams common_params; 2024 CommonNavigationParams common_params;
2072 common_params.navigation_type = FrameMsg_Navigate_Type::NORMAL; 2025 common_params.navigation_type = FrameMsg_Navigate_Type::NORMAL;
2073 common_params.url = GURL("data:text/html,test data"); 2026 common_params.url = GURL("data:text/html,test data");
2074 NavigateMainFrame(common_params, StartNavigationParams(), 2027 TestRenderFrame* main_frame = static_cast<TestRenderFrame*>(frame());
2075 RequestNavigationParams()); 2028 main_frame->Navigate(common_params, StartNavigationParams(),
2029 RequestNavigationParams());
2076 2030
2077 // An error occurred. 2031 // An error occurred.
2078 view()->GetMainRenderFrame()->didFailProvisionalLoad( 2032 main_frame->didFailProvisionalLoad(web_frame, error,
2079 web_frame, error, blink::WebStandardCommit); 2033 blink::WebStandardCommit);
2080 const int kMaxOutputCharacters = 22; 2034 const int kMaxOutputCharacters = 22;
2081 EXPECT_EQ("", 2035 EXPECT_EQ("",
2082 base::UTF16ToASCII(web_frame->contentAsText(kMaxOutputCharacters))); 2036 base::UTF16ToASCII(web_frame->contentAsText(kMaxOutputCharacters)));
2083 } 2037 }
2084 2038
2085 #if defined(OS_ANDROID) 2039 #if defined(OS_ANDROID)
2086 // Crashing on Android: http://crbug.com/311341 2040 // Crashing on Android: http://crbug.com/311341
2087 #define MAYBE_DoesNotSuppress DISABLED_DoesNotSuppress 2041 #define MAYBE_DoesNotSuppress DISABLED_DoesNotSuppress
2088 #else 2042 #else
2089 #define MAYBE_DoesNotSuppress DoesNotSuppress 2043 #define MAYBE_DoesNotSuppress DoesNotSuppress
2090 #endif 2044 #endif
2091 2045
2092 TEST_F(SuppressErrorPageTest, MAYBE_DoesNotSuppress) { 2046 TEST_F(SuppressErrorPageTest, MAYBE_DoesNotSuppress) {
2093 WebURLError error; 2047 WebURLError error;
2094 error.domain = WebString::fromUTF8(net::kErrorDomain); 2048 error.domain = WebString::fromUTF8(net::kErrorDomain);
2095 error.reason = net::ERR_FILE_NOT_FOUND; 2049 error.reason = net::ERR_FILE_NOT_FOUND;
2096 error.unreachableURL = GURL("http://example.com/dont-suppress"); 2050 error.unreachableURL = GURL("http://example.com/dont-suppress");
2097 WebLocalFrame* web_frame = GetMainFrame(); 2051 WebLocalFrame* web_frame = GetMainFrame();
2098 2052
2099 // Start a load that will reach provisional state synchronously, 2053 // Start a load that will reach provisional state synchronously,
2100 // but won't complete synchronously. 2054 // but won't complete synchronously.
2101 CommonNavigationParams common_params; 2055 CommonNavigationParams common_params;
2102 common_params.navigation_type = FrameMsg_Navigate_Type::NORMAL; 2056 common_params.navigation_type = FrameMsg_Navigate_Type::NORMAL;
2103 common_params.url = GURL("data:text/html,test data"); 2057 common_params.url = GURL("data:text/html,test data");
2104 NavigateMainFrame(common_params, StartNavigationParams(), 2058 TestRenderFrame* main_frame = static_cast<TestRenderFrame*>(frame());
2105 RequestNavigationParams()); 2059 main_frame->Navigate(common_params, StartNavigationParams(),
2060 RequestNavigationParams());
2106 2061
2107 // An error occurred. 2062 // An error occurred.
2108 view()->GetMainRenderFrame()->didFailProvisionalLoad( 2063 main_frame->didFailProvisionalLoad(web_frame, error,
2109 web_frame, error, blink::WebStandardCommit); 2064 blink::WebStandardCommit);
2065
2110 // The error page itself is loaded asynchronously. 2066 // The error page itself is loaded asynchronously.
2111 FrameLoadWaiter(frame()).Wait(); 2067 FrameLoadWaiter(main_frame).Wait();
2112 const int kMaxOutputCharacters = 22; 2068 const int kMaxOutputCharacters = 22;
2113 EXPECT_EQ("A suffusion of yellow.", 2069 EXPECT_EQ("A suffusion of yellow.",
2114 base::UTF16ToASCII(web_frame->contentAsText(kMaxOutputCharacters))); 2070 base::UTF16ToASCII(web_frame->contentAsText(kMaxOutputCharacters)));
2115 } 2071 }
2116 2072
2117 // Ensure the render view sends favicon url update events correctly. 2073 // Ensure the render view sends favicon url update events correctly.
2118 TEST_F(RenderViewImplTest, SendFaviconURLUpdateEvent) { 2074 TEST_F(RenderViewImplTest, SendFaviconURLUpdateEvent) {
2119 // An event should be sent when a favicon url exists. 2075 // An event should be sent when a favicon url exists.
2120 LoadHTML("<html>" 2076 LoadHTML("<html>"
2121 "<head>" 2077 "<head>"
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
2206 extra_data = static_cast<RequestExtraData*>(request.extraData()); 2162 extra_data = static_cast<RequestExtraData*>(request.extraData());
2207 ASSERT_TRUE(extra_data); 2163 ASSERT_TRUE(extra_data);
2208 EXPECT_EQ(extra_data->service_worker_provider_id(), 2164 EXPECT_EQ(extra_data->service_worker_provider_id(),
2209 provider->provider_id()); 2165 provider->provider_id());
2210 } 2166 }
2211 2167
2212 TEST_F(RenderViewImplTest, OnSetAccessibilityMode) { 2168 TEST_F(RenderViewImplTest, OnSetAccessibilityMode) {
2213 ASSERT_EQ(AccessibilityModeOff, frame()->accessibility_mode()); 2169 ASSERT_EQ(AccessibilityModeOff, frame()->accessibility_mode());
2214 ASSERT_EQ((RendererAccessibility*) NULL, frame()->renderer_accessibility()); 2170 ASSERT_EQ((RendererAccessibility*) NULL, frame()->renderer_accessibility());
2215 2171
2216 SetAccessibilityMode(AccessibilityModeTreeOnly); 2172 frame()->SetAccessibilityMode(AccessibilityModeTreeOnly);
2217 ASSERT_EQ(AccessibilityModeTreeOnly, frame()->accessibility_mode()); 2173 ASSERT_EQ(AccessibilityModeTreeOnly, frame()->accessibility_mode());
2218 ASSERT_NE((RendererAccessibility*) NULL, frame()->renderer_accessibility()); 2174 ASSERT_NE((RendererAccessibility*) NULL, frame()->renderer_accessibility());
2219 2175
2220 SetAccessibilityMode(AccessibilityModeOff); 2176 frame()->SetAccessibilityMode(AccessibilityModeOff);
2221 ASSERT_EQ(AccessibilityModeOff, frame()->accessibility_mode()); 2177 ASSERT_EQ(AccessibilityModeOff, frame()->accessibility_mode());
2222 ASSERT_EQ((RendererAccessibility*) NULL, frame()->renderer_accessibility()); 2178 ASSERT_EQ((RendererAccessibility*) NULL, frame()->renderer_accessibility());
2223 2179
2224 SetAccessibilityMode(AccessibilityModeComplete); 2180 frame()->SetAccessibilityMode(AccessibilityModeComplete);
2225 ASSERT_EQ(AccessibilityModeComplete, frame()->accessibility_mode()); 2181 ASSERT_EQ(AccessibilityModeComplete, frame()->accessibility_mode());
2226 ASSERT_NE((RendererAccessibility*) NULL, frame()->renderer_accessibility()); 2182 ASSERT_NE((RendererAccessibility*) NULL, frame()->renderer_accessibility());
2227 } 2183 }
2228 2184
2229 TEST_F(RenderViewImplTest, ScreenMetricsEmulation) { 2185 TEST_F(RenderViewImplTest, ScreenMetricsEmulation) {
2230 LoadHTML("<body style='min-height:1000px;'></body>"); 2186 LoadHTML("<body style='min-height:1000px;'></body>");
2231 2187
2232 blink::WebDeviceEmulationParams params; 2188 blink::WebDeviceEmulationParams params;
2233 base::string16 get_width = base::ASCIIToUTF16("Number(window.innerWidth)"); 2189 base::string16 get_width = base::ASCIIToUTF16("Number(window.innerWidth)");
2234 base::string16 get_height = base::ASCIIToUTF16("Number(window.innerHeight)"); 2190 base::string16 get_height = base::ASCIIToUTF16("Number(window.innerHeight)");
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
2267 CommonNavigationParams early_common_params; 2223 CommonNavigationParams early_common_params;
2268 StartNavigationParams early_start_params; 2224 StartNavigationParams early_start_params;
2269 RequestNavigationParams early_request_params; 2225 RequestNavigationParams early_request_params;
2270 early_common_params.url = GURL("data:text/html,<div>Page</div>"); 2226 early_common_params.url = GURL("data:text/html,<div>Page</div>");
2271 early_common_params.navigation_type = FrameMsg_Navigate_Type::NORMAL; 2227 early_common_params.navigation_type = FrameMsg_Navigate_Type::NORMAL;
2272 early_common_params.transition = ui::PAGE_TRANSITION_TYPED; 2228 early_common_params.transition = ui::PAGE_TRANSITION_TYPED;
2273 early_start_params.is_post = true; 2229 early_start_params.is_post = true;
2274 early_request_params.browser_navigation_start = 2230 early_request_params.browser_navigation_start =
2275 base::TimeTicks::FromInternalValue(1); 2231 base::TimeTicks::FromInternalValue(1);
2276 2232
2277 NavigateMainFrame(early_common_params, early_start_params, 2233 frame()->Navigate(early_common_params, early_start_params,
2278 early_request_params); 2234 early_request_params);
2279 ProcessPendingMessages(); 2235 ProcessPendingMessages();
2280 2236
2281 base::Time early_nav_reported_start = 2237 base::Time early_nav_reported_start =
2282 base::Time::FromDoubleT(GetMainFrame()->performance().navigationStart()); 2238 base::Time::FromDoubleT(GetMainFrame()->performance().navigationStart());
2283 EXPECT_LT(early_nav_reported_start, before_navigation); 2239 EXPECT_LT(early_nav_reported_start, before_navigation);
2284 2240
2285 // Verify that a navigation that claims to have started in the future - 42 2241 // Verify that a navigation that claims to have started in the future - 42
2286 // days from now is *not* reported as one that starts in the future; as we 2242 // days from now is *not* reported as one that starts in the future; as we
2287 // sanitize the override allowing a maximum of ::Now(). 2243 // sanitize the override allowing a maximum of ::Now().
2288 CommonNavigationParams late_common_params; 2244 CommonNavigationParams late_common_params;
2289 RequestNavigationParams late_request_params; 2245 RequestNavigationParams late_request_params;
2290 StartNavigationParams late_start_params; 2246 StartNavigationParams late_start_params;
2291 late_common_params.url = GURL("data:text/html,<div>Another page</div>"); 2247 late_common_params.url = GURL("data:text/html,<div>Another page</div>");
2292 late_common_params.navigation_type = FrameMsg_Navigate_Type::NORMAL; 2248 late_common_params.navigation_type = FrameMsg_Navigate_Type::NORMAL;
2293 late_common_params.transition = ui::PAGE_TRANSITION_TYPED; 2249 late_common_params.transition = ui::PAGE_TRANSITION_TYPED;
2294 late_start_params.is_post = true; 2250 late_start_params.is_post = true;
2295 late_request_params.browser_navigation_start = 2251 late_request_params.browser_navigation_start =
2296 base::TimeTicks::Now() + base::TimeDelta::FromDays(42); 2252 base::TimeTicks::Now() + base::TimeDelta::FromDays(42);
2297 2253
2298 NavigateMainFrame(late_common_params, late_start_params, late_request_params); 2254 frame()->Navigate(late_common_params, late_start_params, late_request_params);
2299 ProcessPendingMessages(); 2255 ProcessPendingMessages();
2300 base::Time after_navigation = 2256 base::Time after_navigation =
2301 base::Time::Now() + base::TimeDelta::FromDays(1); 2257 base::Time::Now() + base::TimeDelta::FromDays(1);
2302 2258
2303 base::Time late_nav_reported_start = 2259 base::Time late_nav_reported_start =
2304 base::Time::FromDoubleT(GetMainFrame()->performance().navigationStart()); 2260 base::Time::FromDoubleT(GetMainFrame()->performance().navigationStart());
2305 EXPECT_LE(late_nav_reported_start, after_navigation); 2261 EXPECT_LE(late_nav_reported_start, after_navigation);
2306 } 2262 }
2307 2263
2308 TEST_F(RenderViewImplTest, PreferredSizeZoomed) { 2264 TEST_F(RenderViewImplTest, PreferredSizeZoomed) {
(...skipping 16 matching lines...) Expand all
2325 EXPECT_EQ(0, view()->historyBackListCount()); 2281 EXPECT_EQ(0, view()->historyBackListCount());
2326 EXPECT_EQ(0, view()->historyBackListCount() + 2282 EXPECT_EQ(0, view()->historyBackListCount() +
2327 view()->historyForwardListCount() + 1); 2283 view()->historyForwardListCount() + 1);
2328 2284
2329 // Receive a Navigate message with history parameters. 2285 // Receive a Navigate message with history parameters.
2330 RequestNavigationParams request_params; 2286 RequestNavigationParams request_params;
2331 request_params.current_history_list_length = 2; 2287 request_params.current_history_list_length = 2;
2332 request_params.current_history_list_offset = 1; 2288 request_params.current_history_list_offset = 1;
2333 request_params.pending_history_list_offset = 2; 2289 request_params.pending_history_list_offset = 2;
2334 request_params.page_id = -1; 2290 request_params.page_id = -1;
2335 NavigateMainFrame(CommonNavigationParams(), StartNavigationParams(), 2291 frame()->Navigate(CommonNavigationParams(), StartNavigationParams(),
2336 request_params); 2292 request_params);
2337 2293
2338 // The history list in RenderView should have been updated. 2294 // The history list in RenderView should have been updated.
2339 EXPECT_EQ(1, view()->historyBackListCount()); 2295 EXPECT_EQ(1, view()->historyBackListCount());
2340 EXPECT_EQ(2, view()->historyBackListCount() + 2296 EXPECT_EQ(2, view()->historyBackListCount() +
2341 view()->historyForwardListCount() + 1); 2297 view()->historyForwardListCount() + 1);
2342 } 2298 }
2343 2299
2344 TEST_F(RenderViewImplBlinkSettingsTest, Default) { 2300 TEST_F(RenderViewImplBlinkSettingsTest, Default) {
2345 DoSetUp(); 2301 DoSetUp();
(...skipping 20 matching lines...) Expand all
2366 FROM_HERE, 2322 FROM_HERE,
2367 base::Bind(&DevToolsAgentTest::CloseWhilePaused, base::Unretained(this))); 2323 base::Bind(&DevToolsAgentTest::CloseWhilePaused, base::Unretained(this)));
2368 ExecuteJavaScript("debugger;"); 2324 ExecuteJavaScript("debugger;");
2369 2325
2370 // CloseWhilePaused should resume execution and continue here. 2326 // CloseWhilePaused should resume execution and continue here.
2371 EXPECT_FALSE(IsPaused()); 2327 EXPECT_FALSE(IsPaused());
2372 Detach(); 2328 Detach();
2373 } 2329 }
2374 2330
2375 } // namespace content 2331 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/render_frame_impl.h ('k') | content/test/test_render_frame.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698