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

Side by Side Diff: content/browser/web_contents/web_contents_impl_unittest.cc

Issue 15682009: Eliminate SwapOut message parameters, keeping state in RVHM instead. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase to get Android build fix Created 7 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 | Annotate | Revision Log
« no previous file with comments | « content/browser/web_contents/web_contents_impl.cc ('k') | content/common/view_messages.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/logging.h" 5 #include "base/logging.h"
6 #include "base/strings/utf_string_conversions.h" 6 #include "base/strings/utf_string_conversions.h"
7 #include "content/browser/renderer_host/render_view_host_impl.h" 7 #include "content/browser/renderer_host/render_view_host_impl.h"
8 #include "content/browser/renderer_host/test_render_view_host.h" 8 #include "content/browser/renderer_host/test_render_view_host.h"
9 #include "content/browser/site_instance_impl.h" 9 #include "content/browser/site_instance_impl.h"
10 #include "content/browser/web_contents/frame_tree_node.h" 10 #include "content/browser/web_contents/frame_tree_node.h"
11 #include "content/browser/web_contents/interstitial_page_impl.h" 11 #include "content/browser/web_contents/interstitial_page_impl.h"
12 #include "content/browser/web_contents/navigation_entry_impl.h" 12 #include "content/browser/web_contents/navigation_entry_impl.h"
13 #include "content/browser/webui/web_ui_controller_factory_registry.h" 13 #include "content/browser/webui/web_ui_controller_factory_registry.h"
14 #include "content/common/view_messages.h" 14 #include "content/common/view_messages.h"
15 #include "content/public/browser/global_request_id.h"
15 #include "content/public/browser/interstitial_page_delegate.h" 16 #include "content/public/browser/interstitial_page_delegate.h"
16 #include "content/public/browser/navigation_details.h" 17 #include "content/public/browser/navigation_details.h"
17 #include "content/public/browser/notification_details.h" 18 #include "content/public/browser/notification_details.h"
18 #include "content/public/browser/notification_source.h" 19 #include "content/public/browser/notification_source.h"
19 #include "content/public/browser/notification_source.h" 20 #include "content/public/browser/notification_source.h"
20 #include "content/public/browser/render_widget_host_view.h" 21 #include "content/public/browser/render_widget_host_view.h"
21 #include "content/public/browser/web_contents_observer.h" 22 #include "content/public/browser/web_contents_observer.h"
22 #include "content/public/browser/web_ui_controller.h" 23 #include "content/public/browser/web_ui_controller.h"
23 #include "content/public/common/bindings_policy.h" 24 #include "content/public/common/bindings_policy.h"
24 #include "content/public/common/content_constants.h" 25 #include "content/public/common/content_constants.h"
(...skipping 665 matching lines...) Expand 10 before | Expand all | Expand 10 after
690 url2, Referrer(), PAGE_TRANSITION_TYPED, std::string()); 691 url2, Referrer(), PAGE_TRANSITION_TYPED, std::string());
691 EXPECT_TRUE(orig_rvh->is_waiting_for_beforeunload_ack()); 692 EXPECT_TRUE(orig_rvh->is_waiting_for_beforeunload_ack());
692 now = base::TimeTicks::Now(); 693 now = base::TimeTicks::Now();
693 orig_rvh->OnMessageReceived(ViewHostMsg_ShouldClose_ACK(0, true, now, now)); 694 orig_rvh->OnMessageReceived(ViewHostMsg_ShouldClose_ACK(0, true, now, now));
694 EXPECT_FALSE(orig_rvh->is_waiting_for_beforeunload_ack()); 695 EXPECT_FALSE(orig_rvh->is_waiting_for_beforeunload_ack());
695 EXPECT_TRUE(contents()->cross_navigation_pending()); 696 EXPECT_TRUE(contents()->cross_navigation_pending());
696 TestRenderViewHost* pending_rvh = static_cast<TestRenderViewHost*>( 697 TestRenderViewHost* pending_rvh = static_cast<TestRenderViewHost*>(
697 contents()->GetPendingRenderViewHost()); 698 contents()->GetPendingRenderViewHost());
698 699
699 // We won't hear DidNavigate until the onunload handler has finished running. 700 // We won't hear DidNavigate until the onunload handler has finished running.
700 // (No way to simulate that here, but it involves a call from RDH to
701 // WebContentsImpl::OnCrossSiteResponse.)
702 701
703 // DidNavigate from the pending page 702 // DidNavigate from the pending page.
704 contents()->TestDidNavigate( 703 contents()->TestDidNavigate(
705 pending_rvh, 1, url2, PAGE_TRANSITION_TYPED); 704 pending_rvh, 1, url2, PAGE_TRANSITION_TYPED);
706 SiteInstance* instance2 = contents()->GetSiteInstance(); 705 SiteInstance* instance2 = contents()->GetSiteInstance();
707 EXPECT_FALSE(contents()->cross_navigation_pending()); 706 EXPECT_FALSE(contents()->cross_navigation_pending());
708 EXPECT_EQ(pending_rvh, rvh()); 707 EXPECT_EQ(pending_rvh, rvh());
709 EXPECT_NE(instance1, instance2); 708 EXPECT_NE(instance1, instance2);
710 EXPECT_TRUE(contents()->GetPendingRenderViewHost() == NULL); 709 EXPECT_TRUE(contents()->GetPendingRenderViewHost() == NULL);
711 } 710 }
712 711
713 // Test that during a slow cross-site navigation, the original renderer can 712 // Test that during a slow cross-site navigation, the original renderer can
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after
939 controller().LoadURL( 938 controller().LoadURL(
940 url2, Referrer(), PAGE_TRANSITION_TYPED, std::string()); 939 url2, Referrer(), PAGE_TRANSITION_TYPED, std::string());
941 base::TimeTicks now = base::TimeTicks::Now(); 940 base::TimeTicks now = base::TimeTicks::Now();
942 orig_rvh->OnMessageReceived(ViewHostMsg_ShouldClose_ACK(0, true, now, now)); 941 orig_rvh->OnMessageReceived(ViewHostMsg_ShouldClose_ACK(0, true, now, now));
943 EXPECT_TRUE(contents()->cross_navigation_pending()); 942 EXPECT_TRUE(contents()->cross_navigation_pending());
944 TestRenderViewHost* pending_rvh = static_cast<TestRenderViewHost*>( 943 TestRenderViewHost* pending_rvh = static_cast<TestRenderViewHost*>(
945 contents()->GetPendingRenderViewHost()); 944 contents()->GetPendingRenderViewHost());
946 945
947 // Simulate the pending renderer's response, which leads to an unload request 946 // Simulate the pending renderer's response, which leads to an unload request
948 // being sent to orig_rvh. 947 // being sent to orig_rvh.
949 contents()->GetRenderManagerForTesting()->OnCrossSiteResponse(0, 0); 948 contents()->GetRenderManagerForTesting()->OnCrossSiteResponse(
949 pending_rvh, GlobalRequestID(0, 0));
950 950
951 // Suppose the original renderer navigates now, while the unload request is in 951 // Suppose the original renderer navigates now, while the unload request is in
952 // flight. We should ignore it, wait for the unload ack, and let the pending 952 // flight. We should ignore it, wait for the unload ack, and let the pending
953 // request continue. Otherwise, the contents may close spontaneously or stop 953 // request continue. Otherwise, the contents may close spontaneously or stop
954 // responding to navigation requests. (See bug 23942.) 954 // responding to navigation requests. (See bug 23942.)
955 ViewHostMsg_FrameNavigate_Params params1a; 955 ViewHostMsg_FrameNavigate_Params params1a;
956 InitNavigateParams(&params1a, 2, GURL("http://www.google.com/foo"), 956 InitNavigateParams(&params1a, 2, GURL("http://www.google.com/foo"),
957 PAGE_TRANSITION_TYPED); 957 PAGE_TRANSITION_TYPED);
958 orig_rvh->SendNavigate(2, GURL("http://www.google.com/foo")); 958 orig_rvh->SendNavigate(2, GURL("http://www.google.com/foo"));
959 959
(...skipping 1140 matching lines...) Expand 10 before | Expand all | Expand 10 after
2100 EXPECT_EQ(0UL, deep_tree->child_at(0)->child_at(0)->child_count()); 2100 EXPECT_EQ(0UL, deep_tree->child_at(0)->child_at(0)->child_count());
2101 2101
2102 contents()->OnFrameDetached(16, 265); 2102 contents()->OnFrameDetached(16, 265);
2103 EXPECT_EQ(4UL, root->child_at(2)->child_count()); 2103 EXPECT_EQ(4UL, root->child_at(2)->child_count());
2104 2104
2105 contents()->OnFrameDetached(5, 15); 2105 contents()->OnFrameDetached(5, 15);
2106 EXPECT_EQ(2UL, root->child_count()); 2106 EXPECT_EQ(2UL, root->child_count());
2107 } 2107 }
2108 2108
2109 } // namespace content 2109 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/web_contents/web_contents_impl.cc ('k') | content/common/view_messages.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698