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

Side by Side Diff: content/browser/frame_host/render_frame_host_manager_unittest.cc

Issue 92153003: Rename RenderViewHostManager to RenderFrameHostManager. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase Created 7 years 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
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/strings/utf_string_conversions.h" 5 #include "base/strings/utf_string_conversions.h"
6 #include "content/browser/frame_host/navigation_controller_impl.h" 6 #include "content/browser/frame_host/navigation_controller_impl.h"
7 #include "content/browser/frame_host/navigation_entry_impl.h" 7 #include "content/browser/frame_host/navigation_entry_impl.h"
8 #include "content/browser/frame_host/render_view_host_manager.h" 8 #include "content/browser/frame_host/render_frame_host_manager.h"
9 #include "content/browser/renderer_host/test_render_view_host.h" 9 #include "content/browser/renderer_host/test_render_view_host.h"
10 #include "content/browser/site_instance_impl.h" 10 #include "content/browser/site_instance_impl.h"
11 #include "content/browser/webui/web_ui_controller_factory_registry.h" 11 #include "content/browser/webui/web_ui_controller_factory_registry.h"
12 #include "content/common/view_messages.h" 12 #include "content/common/view_messages.h"
13 #include "content/public/browser/notification_details.h" 13 #include "content/public/browser/notification_details.h"
14 #include "content/public/browser/notification_service.h" 14 #include "content/public/browser/notification_service.h"
15 #include "content/public/browser/notification_source.h" 15 #include "content/public/browser/notification_source.h"
16 #include "content/public/browser/notification_types.h" 16 #include "content/public/browser/notification_types.h"
17 #include "content/public/browser/render_process_host.h" 17 #include "content/public/browser/render_process_host.h"
18 #include "content/public/browser/render_widget_host_iterator.h" 18 #include "content/public/browser/render_widget_host_iterator.h"
19 #include "content/public/browser/web_contents_delegate.h" 19 #include "content/public/browser/web_contents_delegate.h"
20 #include "content/public/browser/web_contents_observer.h" 20 #include "content/public/browser/web_contents_observer.h"
21 #include "content/public/browser/web_ui_controller.h" 21 #include "content/public/browser/web_ui_controller.h"
22 #include "content/public/common/bindings_policy.h" 22 #include "content/public/common/bindings_policy.h"
23 #include "content/public/common/javascript_message_type.h" 23 #include "content/public/common/javascript_message_type.h"
24 #include "content/public/common/page_transition_types.h" 24 #include "content/public/common/page_transition_types.h"
25 #include "content/public/common/url_constants.h" 25 #include "content/public/common/url_constants.h"
26 #include "content/public/common/url_utils.h" 26 #include "content/public/common/url_utils.h"
27 #include "content/public/test/mock_render_process_host.h" 27 #include "content/public/test/mock_render_process_host.h"
28 #include "content/public/test/test_notification_tracker.h" 28 #include "content/public/test/test_notification_tracker.h"
29 #include "content/test/test_content_browser_client.h" 29 #include "content/test/test_content_browser_client.h"
30 #include "content/test/test_content_client.h" 30 #include "content/test/test_content_client.h"
31 #include "content/test/test_web_contents.h" 31 #include "content/test/test_web_contents.h"
32 #include "testing/gtest/include/gtest/gtest.h" 32 #include "testing/gtest/include/gtest/gtest.h"
33 33
34 namespace content { 34 namespace content {
35 namespace { 35 namespace {
36 36
37 class RenderViewHostManagerTestWebUIControllerFactory 37 class RenderFrameHostManagerTestWebUIControllerFactory
38 : public WebUIControllerFactory { 38 : public WebUIControllerFactory {
39 public: 39 public:
40 RenderViewHostManagerTestWebUIControllerFactory() 40 RenderFrameHostManagerTestWebUIControllerFactory()
41 : should_create_webui_(false) { 41 : should_create_webui_(false) {
42 } 42 }
43 virtual ~RenderViewHostManagerTestWebUIControllerFactory() {} 43 virtual ~RenderFrameHostManagerTestWebUIControllerFactory() {}
44 44
45 void set_should_create_webui(bool should_create_webui) { 45 void set_should_create_webui(bool should_create_webui) {
46 should_create_webui_ = should_create_webui; 46 should_create_webui_ = should_create_webui;
47 } 47 }
48 48
49 // WebUIFactory implementation. 49 // WebUIFactory implementation.
50 virtual WebUIController* CreateWebUIControllerForURL( 50 virtual WebUIController* CreateWebUIControllerForURL(
51 WebUI* web_ui, const GURL& url) const OVERRIDE { 51 WebUI* web_ui, const GURL& url) const OVERRIDE {
52 if (!(should_create_webui_ && HasWebUIScheme(url))) 52 if (!(should_create_webui_ && HasWebUIScheme(url)))
53 return NULL; 53 return NULL;
(...skipping 11 matching lines...) Expand all
65 } 65 }
66 66
67 virtual bool UseWebUIBindingsForURL(BrowserContext* browser_context, 67 virtual bool UseWebUIBindingsForURL(BrowserContext* browser_context,
68 const GURL& url) const OVERRIDE { 68 const GURL& url) const OVERRIDE {
69 return HasWebUIScheme(url); 69 return HasWebUIScheme(url);
70 } 70 }
71 71
72 private: 72 private:
73 bool should_create_webui_; 73 bool should_create_webui_;
74 74
75 DISALLOW_COPY_AND_ASSIGN(RenderViewHostManagerTestWebUIControllerFactory); 75 DISALLOW_COPY_AND_ASSIGN(RenderFrameHostManagerTestWebUIControllerFactory);
76 }; 76 };
77 77
78 class BeforeUnloadFiredWebContentsDelegate : public WebContentsDelegate { 78 class BeforeUnloadFiredWebContentsDelegate : public WebContentsDelegate {
79 public: 79 public:
80 BeforeUnloadFiredWebContentsDelegate() {} 80 BeforeUnloadFiredWebContentsDelegate() {}
81 virtual ~BeforeUnloadFiredWebContentsDelegate() {} 81 virtual ~BeforeUnloadFiredWebContentsDelegate() {}
82 82
83 virtual void BeforeUnloadFired(WebContents* web_contents, 83 virtual void BeforeUnloadFired(WebContents* web_contents,
84 bool proceed, 84 bool proceed,
85 bool* proceed_to_fire_unload) OVERRIDE { 85 bool* proceed_to_fire_unload) OVERRIDE {
86 *proceed_to_fire_unload = proceed; 86 *proceed_to_fire_unload = proceed;
87 } 87 }
88 88
89 private: 89 private:
90 DISALLOW_COPY_AND_ASSIGN(BeforeUnloadFiredWebContentsDelegate); 90 DISALLOW_COPY_AND_ASSIGN(BeforeUnloadFiredWebContentsDelegate);
91 }; 91 };
92 92
93 } // namespace 93 } // namespace
94 94
95 class RenderViewHostManagerTest 95 class RenderFrameHostManagerTest
96 : public RenderViewHostImplTestHarness { 96 : public RenderViewHostImplTestHarness {
97 public: 97 public:
98 virtual void SetUp() OVERRIDE { 98 virtual void SetUp() OVERRIDE {
99 RenderViewHostImplTestHarness::SetUp(); 99 RenderViewHostImplTestHarness::SetUp();
100 WebUIControllerFactory::RegisterFactory(&factory_); 100 WebUIControllerFactory::RegisterFactory(&factory_);
101 } 101 }
102 102
103 virtual void TearDown() OVERRIDE { 103 virtual void TearDown() OVERRIDE {
104 RenderViewHostImplTestHarness::TearDown(); 104 RenderViewHostImplTestHarness::TearDown();
105 WebUIControllerFactory::UnregisterFactoryForTesting(&factory_); 105 WebUIControllerFactory::UnregisterFactoryForTesting(&factory_);
(...skipping 20 matching lines...) Expand all
126 active_rvh()->GetSiteInstance()); 126 active_rvh()->GetSiteInstance());
127 127
128 // Simulate the SwapOut_ACK that fires if you commit a cross-site 128 // Simulate the SwapOut_ACK that fires if you commit a cross-site
129 // navigation. 129 // navigation.
130 if (old_rvh != active_rvh()) 130 if (old_rvh != active_rvh())
131 old_rvh->OnSwappedOut(false); 131 old_rvh->OnSwappedOut(false);
132 132
133 active_test_rvh()->SendNavigate(max_page_id + 1, url); 133 active_test_rvh()->SendNavigate(max_page_id + 1, url);
134 } 134 }
135 135
136 bool ShouldSwapProcesses(RenderViewHostManager* manager, 136 bool ShouldSwapProcesses(RenderFrameHostManager* manager,
137 const NavigationEntryImpl* current_entry, 137 const NavigationEntryImpl* current_entry,
138 const NavigationEntryImpl* new_entry) const { 138 const NavigationEntryImpl* new_entry) const {
139 return manager->ShouldSwapBrowsingInstancesForNavigation(current_entry, 139 return manager->ShouldSwapBrowsingInstancesForNavigation(current_entry,
140 new_entry); 140 new_entry);
141 } 141 }
142 142
143 // Creates a test RenderViewHost that's swapped out. 143 // Creates a test RenderViewHost that's swapped out.
144 TestRenderViewHost* CreateSwappedOutRenderViewHost() { 144 TestRenderViewHost* CreateSwappedOutRenderViewHost() {
145 const GURL kChromeURL("chrome://foo"); 145 const GURL kChromeURL("chrome://foo");
146 const GURL kDestUrl("http://www.google.com/"); 146 const GURL kDestUrl("http://www.google.com/");
(...skipping 23 matching lines...) Expand all
170 ntp_rvh->SendShouldCloseACK(true); 170 ntp_rvh->SendShouldCloseACK(true);
171 171
172 // Assume SwapOutACK times out, so the dest_rvh proceeds and commits. 172 // Assume SwapOutACK times out, so the dest_rvh proceeds and commits.
173 dest_rvh->SendNavigate(101, kDestUrl); 173 dest_rvh->SendNavigate(101, kDestUrl);
174 174
175 EXPECT_TRUE(ntp_rvh->is_swapped_out()); 175 EXPECT_TRUE(ntp_rvh->is_swapped_out());
176 return ntp_rvh; 176 return ntp_rvh;
177 } 177 }
178 178
179 private: 179 private:
180 RenderViewHostManagerTestWebUIControllerFactory factory_; 180 RenderFrameHostManagerTestWebUIControllerFactory factory_;
181 }; 181 };
182 182
183 // Tests that when you navigate from a chrome:// url to another page, and 183 // Tests that when you navigate from a chrome:// url to another page, and
184 // then do that same thing in another tab, that the two resulting pages have 184 // then do that same thing in another tab, that the two resulting pages have
185 // different SiteInstances, BrowsingInstances, and RenderProcessHosts. This is 185 // different SiteInstances, BrowsingInstances, and RenderProcessHosts. This is
186 // a regression test for bug 9364. 186 // a regression test for bug 9364.
187 TEST_F(RenderViewHostManagerTest, NewTabPageProcesses) { 187 TEST_F(RenderFrameHostManagerTest, NewTabPageProcesses) {
188 set_should_create_webui(true); 188 set_should_create_webui(true);
189 const GURL kChromeUrl("chrome://foo"); 189 const GURL kChromeUrl("chrome://foo");
190 const GURL kDestUrl("http://www.google.com/"); 190 const GURL kDestUrl("http://www.google.com/");
191 191
192 // Navigate our first tab to the chrome url and then to the destination, 192 // Navigate our first tab to the chrome url and then to the destination,
193 // ensuring we grant bindings to the chrome URL. 193 // ensuring we grant bindings to the chrome URL.
194 NavigateActiveAndCommit(kChromeUrl); 194 NavigateActiveAndCommit(kChromeUrl);
195 EXPECT_TRUE(active_rvh()->GetEnabledBindings() & BINDINGS_POLICY_WEB_UI); 195 EXPECT_TRUE(active_rvh()->GetEnabledBindings() & BINDINGS_POLICY_WEB_UI);
196 NavigateActiveAndCommit(kDestUrl); 196 NavigateActiveAndCommit(kDestUrl);
197 197
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
243 contents2->GetRenderViewHost()->GetSiteInstance()); 243 contents2->GetRenderViewHost()->GetSiteInstance());
244 EXPECT_EQ(active_rvh()->GetSiteInstance()->GetProcess(), 244 EXPECT_EQ(active_rvh()->GetSiteInstance()->GetProcess(),
245 contents2->GetRenderViewHost()->GetSiteInstance()->GetProcess()); 245 contents2->GetRenderViewHost()->GetSiteInstance()->GetProcess());
246 } 246 }
247 247
248 // Ensure that the browser ignores most IPC messages that arrive from a 248 // Ensure that the browser ignores most IPC messages that arrive from a
249 // RenderViewHost that has been swapped out. We do not want to take 249 // RenderViewHost that has been swapped out. We do not want to take
250 // action on requests from a non-active renderer. The main exception is 250 // action on requests from a non-active renderer. The main exception is
251 // for synchronous messages, which cannot be ignored without leaving the 251 // for synchronous messages, which cannot be ignored without leaving the
252 // renderer in a stuck state. See http://crbug.com/93427. 252 // renderer in a stuck state. See http://crbug.com/93427.
253 TEST_F(RenderViewHostManagerTest, FilterMessagesWhileSwappedOut) { 253 TEST_F(RenderFrameHostManagerTest, FilterMessagesWhileSwappedOut) {
254 const GURL kChromeURL("chrome://foo"); 254 const GURL kChromeURL("chrome://foo");
255 const GURL kDestUrl("http://www.google.com/"); 255 const GURL kDestUrl("http://www.google.com/");
256 256
257 // Navigate our first tab to a chrome url and then to the destination. 257 // Navigate our first tab to a chrome url and then to the destination.
258 NavigateActiveAndCommit(kChromeURL); 258 NavigateActiveAndCommit(kChromeURL);
259 TestRenderViewHost* ntp_rvh = static_cast<TestRenderViewHost*>( 259 TestRenderViewHost* ntp_rvh = static_cast<TestRenderViewHost*>(
260 contents()->GetRenderManagerForTesting()->current_host()); 260 contents()->GetRenderManagerForTesting()->current_host());
261 261
262 // Send an update title message and make sure it works. 262 // Send an update title message and make sure it works.
263 const string16 ntp_title = ASCIIToUTF16("NTP Title"); 263 const string16 ntp_title = ASCIIToUTF16("NTP Title");
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
321 // Also test RunJavaScriptMessage. 321 // Also test RunJavaScriptMessage.
322 ntp_process_host->sink().ClearMessages(); 322 ntp_process_host->sink().ClearMessages();
323 ViewHostMsg_RunJavaScriptMessage js_msg( 323 ViewHostMsg_RunJavaScriptMessage js_msg(
324 rvh()->GetRoutingID(), msg, msg, kChromeURL, 324 rvh()->GetRoutingID(), msg, msg, kChromeURL,
325 JAVASCRIPT_MESSAGE_TYPE_CONFIRM, &result, &unused); 325 JAVASCRIPT_MESSAGE_TYPE_CONFIRM, &result, &unused);
326 js_msg.EnableMessagePumping(); 326 js_msg.EnableMessagePumping();
327 EXPECT_TRUE(ntp_rvh->OnMessageReceived(js_msg)); 327 EXPECT_TRUE(ntp_rvh->OnMessageReceived(js_msg));
328 EXPECT_TRUE(ntp_process_host->sink().GetUniqueMessageMatching(IPC_REPLY_ID)); 328 EXPECT_TRUE(ntp_process_host->sink().GetUniqueMessageMatching(IPC_REPLY_ID));
329 } 329 }
330 330
331 TEST_F(RenderViewHostManagerTest, WhiteListSwapCompositorFrame) { 331 TEST_F(RenderFrameHostManagerTest, WhiteListSwapCompositorFrame) {
332 TestRenderViewHost* swapped_out_rvh = CreateSwappedOutRenderViewHost(); 332 TestRenderViewHost* swapped_out_rvh = CreateSwappedOutRenderViewHost();
333 TestRenderWidgetHostView* swapped_out_rwhv = 333 TestRenderWidgetHostView* swapped_out_rwhv =
334 static_cast<TestRenderWidgetHostView*>(swapped_out_rvh->GetView()); 334 static_cast<TestRenderWidgetHostView*>(swapped_out_rvh->GetView());
335 EXPECT_FALSE(swapped_out_rwhv->did_swap_compositor_frame()); 335 EXPECT_FALSE(swapped_out_rwhv->did_swap_compositor_frame());
336 336
337 MockRenderProcessHost* process_host = 337 MockRenderProcessHost* process_host =
338 static_cast<MockRenderProcessHost*>(swapped_out_rvh->GetProcess()); 338 static_cast<MockRenderProcessHost*>(swapped_out_rvh->GetProcess());
339 process_host->sink().ClearMessages(); 339 process_host->sink().ClearMessages();
340 340
341 cc::CompositorFrame frame; 341 cc::CompositorFrame frame;
342 ViewHostMsg_SwapCompositorFrame msg(rvh()->GetRoutingID(), 0, frame); 342 ViewHostMsg_SwapCompositorFrame msg(rvh()->GetRoutingID(), 0, frame);
343 343
344 EXPECT_TRUE(swapped_out_rvh->OnMessageReceived(msg)); 344 EXPECT_TRUE(swapped_out_rvh->OnMessageReceived(msg));
345 EXPECT_TRUE(swapped_out_rwhv->did_swap_compositor_frame()); 345 EXPECT_TRUE(swapped_out_rwhv->did_swap_compositor_frame());
346 } 346 }
347 347
348 TEST_F(RenderViewHostManagerTest, WhiteListDidActivateAcceleratedCompositing) { 348 TEST_F(RenderFrameHostManagerTest, WhiteListDidActivateAcceleratedCompositing) {
349 TestRenderViewHost* swapped_out_rvh = CreateSwappedOutRenderViewHost(); 349 TestRenderViewHost* swapped_out_rvh = CreateSwappedOutRenderViewHost();
350 350
351 MockRenderProcessHost* process_host = 351 MockRenderProcessHost* process_host =
352 static_cast<MockRenderProcessHost*>(swapped_out_rvh->GetProcess()); 352 static_cast<MockRenderProcessHost*>(swapped_out_rvh->GetProcess());
353 process_host->sink().ClearMessages(); 353 process_host->sink().ClearMessages();
354 ViewHostMsg_DidActivateAcceleratedCompositing msg( 354 ViewHostMsg_DidActivateAcceleratedCompositing msg(
355 rvh()->GetRoutingID(), true); 355 rvh()->GetRoutingID(), true);
356 EXPECT_TRUE(swapped_out_rvh->OnMessageReceived(msg)); 356 EXPECT_TRUE(swapped_out_rvh->OnMessageReceived(msg));
357 EXPECT_TRUE(swapped_out_rvh->is_accelerated_compositing_active()); 357 EXPECT_TRUE(swapped_out_rvh->is_accelerated_compositing_active());
358 } 358 }
359 359
360 // Test if RenderViewHost::GetRenderWidgetHosts() only returns active 360 // Test if RenderViewHost::GetRenderWidgetHosts() only returns active
361 // widgets. 361 // widgets.
362 TEST_F(RenderViewHostManagerTest, GetRenderWidgetHostsReturnsActiveViews) { 362 TEST_F(RenderFrameHostManagerTest, GetRenderWidgetHostsReturnsActiveViews) {
363 TestRenderViewHost* swapped_out_rvh = CreateSwappedOutRenderViewHost(); 363 TestRenderViewHost* swapped_out_rvh = CreateSwappedOutRenderViewHost();
364 EXPECT_TRUE(swapped_out_rvh->is_swapped_out()); 364 EXPECT_TRUE(swapped_out_rvh->is_swapped_out());
365 365
366 scoped_ptr<RenderWidgetHostIterator> widgets( 366 scoped_ptr<RenderWidgetHostIterator> widgets(
367 RenderWidgetHost::GetRenderWidgetHosts()); 367 RenderWidgetHost::GetRenderWidgetHosts());
368 // We know that there is the only one active widget. Another view is 368 // We know that there is the only one active widget. Another view is
369 // now swapped out, so the swapped out view is not included in the 369 // now swapped out, so the swapped out view is not included in the
370 // list. 370 // list.
371 RenderWidgetHost* widget = widgets->GetNextHost(); 371 RenderWidgetHost* widget = widgets->GetNextHost();
372 EXPECT_FALSE(widgets->GetNextHost()); 372 EXPECT_FALSE(widgets->GetNextHost());
373 RenderViewHost* rvh = RenderViewHost::From(widget); 373 RenderViewHost* rvh = RenderViewHost::From(widget);
374 EXPECT_FALSE(static_cast<RenderViewHostImpl*>(rvh)->is_swapped_out()); 374 EXPECT_FALSE(static_cast<RenderViewHostImpl*>(rvh)->is_swapped_out());
375 } 375 }
376 376
377 // Test if RenderViewHost::GetRenderWidgetHosts() returns a subset of 377 // Test if RenderViewHost::GetRenderWidgetHosts() returns a subset of
378 // RenderViewHostImpl::GetAllRenderWidgetHosts(). 378 // RenderViewHostImpl::GetAllRenderWidgetHosts().
379 // RenderViewHost::GetRenderWidgetHosts() returns only active widgets, but 379 // RenderViewHost::GetRenderWidgetHosts() returns only active widgets, but
380 // RenderViewHostImpl::GetAllRenderWidgetHosts() returns everything 380 // RenderViewHostImpl::GetAllRenderWidgetHosts() returns everything
381 // including swapped out ones. 381 // including swapped out ones.
382 TEST_F(RenderViewHostManagerTest, 382 TEST_F(RenderFrameHostManagerTest,
383 GetRenderWidgetHostsWithinGetAllRenderWidgetHosts) { 383 GetRenderWidgetHostsWithinGetAllRenderWidgetHosts) {
384 TestRenderViewHost* swapped_out_rvh = CreateSwappedOutRenderViewHost(); 384 TestRenderViewHost* swapped_out_rvh = CreateSwappedOutRenderViewHost();
385 EXPECT_TRUE(swapped_out_rvh->is_swapped_out()); 385 EXPECT_TRUE(swapped_out_rvh->is_swapped_out());
386 386
387 scoped_ptr<RenderWidgetHostIterator> widgets( 387 scoped_ptr<RenderWidgetHostIterator> widgets(
388 RenderWidgetHost::GetRenderWidgetHosts()); 388 RenderWidgetHost::GetRenderWidgetHosts());
389 389
390 while (RenderWidgetHost* w = widgets->GetNextHost()) { 390 while (RenderWidgetHost* w = widgets->GetNextHost()) {
391 bool found = false; 391 bool found = false;
392 scoped_ptr<RenderWidgetHostIterator> all_widgets( 392 scoped_ptr<RenderWidgetHostIterator> all_widgets(
393 RenderWidgetHostImpl::GetAllRenderWidgetHosts()); 393 RenderWidgetHostImpl::GetAllRenderWidgetHosts());
394 while (RenderWidgetHost* widget = all_widgets->GetNextHost()) { 394 while (RenderWidgetHost* widget = all_widgets->GetNextHost()) {
395 if (w == widget) { 395 if (w == widget) {
396 found = true; 396 found = true;
397 break; 397 break;
398 } 398 }
399 } 399 }
400 EXPECT_TRUE(found); 400 EXPECT_TRUE(found);
401 } 401 }
402 } 402 }
403 403
404 // Test if SiteInstanceImpl::active_view_count() is correctly updated 404 // Test if SiteInstanceImpl::active_view_count() is correctly updated
405 // as views in a SiteInstance get swapped out and in. 405 // as views in a SiteInstance get swapped out and in.
406 TEST_F(RenderViewHostManagerTest, ActiveViewCountWhileSwappingInandOut) { 406 TEST_F(RenderFrameHostManagerTest, ActiveViewCountWhileSwappingInandOut) {
407 const GURL kUrl1("http://www.google.com/"); 407 const GURL kUrl1("http://www.google.com/");
408 const GURL kUrl2("http://www.chromium.org/"); 408 const GURL kUrl2("http://www.chromium.org/");
409 409
410 // Navigate to an initial URL. 410 // Navigate to an initial URL.
411 contents()->NavigateAndCommit(kUrl1); 411 contents()->NavigateAndCommit(kUrl1);
412 TestRenderViewHost* rvh1 = test_rvh(); 412 TestRenderViewHost* rvh1 = test_rvh();
413 413
414 SiteInstanceImpl* instance1 = 414 SiteInstanceImpl* instance1 =
415 static_cast<SiteInstanceImpl*>(rvh1->GetSiteInstance()); 415 static_cast<SiteInstanceImpl*>(rvh1->GetSiteInstance());
416 EXPECT_EQ(instance1->active_view_count(), 1U); 416 EXPECT_EQ(instance1->active_view_count(), 1U);
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
470 RenderViewHost* render_view_host_; 470 RenderViewHost* render_view_host_;
471 WebContents* web_contents_; 471 WebContents* web_contents_;
472 472
473 DISALLOW_COPY_AND_ASSIGN(RenderViewHostDestroyer); 473 DISALLOW_COPY_AND_ASSIGN(RenderViewHostDestroyer);
474 }; 474 };
475 475
476 // Test if ShutdownRenderViewHostsInSiteInstance() does not touch any 476 // Test if ShutdownRenderViewHostsInSiteInstance() does not touch any
477 // RenderWidget that has been freed while deleting a RenderViewHost in 477 // RenderWidget that has been freed while deleting a RenderViewHost in
478 // a previous iteration. This is a regression test for 478 // a previous iteration. This is a regression test for
479 // http://crbug.com/259859. 479 // http://crbug.com/259859.
480 TEST_F(RenderViewHostManagerTest, 480 TEST_F(RenderFrameHostManagerTest,
481 DetectUseAfterFreeInShutdownRenderViewHostsInSiteInstance) { 481 DetectUseAfterFreeInShutdownRenderViewHostsInSiteInstance) {
482 const GURL kChromeURL("chrome://newtab"); 482 const GURL kChromeURL("chrome://newtab");
483 const GURL kUrl1("http://www.google.com"); 483 const GURL kUrl1("http://www.google.com");
484 const GURL kUrl2("http://www.chromium.org"); 484 const GURL kUrl2("http://www.chromium.org");
485 485
486 // Navigate our first tab to a chrome url and then to the destination. 486 // Navigate our first tab to a chrome url and then to the destination.
487 NavigateActiveAndCommit(kChromeURL); 487 NavigateActiveAndCommit(kChromeURL);
488 TestRenderViewHost* ntp_rvh = static_cast<TestRenderViewHost*>( 488 TestRenderViewHost* ntp_rvh = static_cast<TestRenderViewHost*>(
489 contents()->GetRenderManagerForTesting()->current_host()); 489 contents()->GetRenderManagerForTesting()->current_host());
490 490
(...skipping 12 matching lines...) Expand all
503 // SiteInstanceImpl::ShutdownRenderViewHostsInSiteInstance() can 503 // SiteInstanceImpl::ShutdownRenderViewHostsInSiteInstance() can
504 // touch any object freed in this way or not while iterating through 504 // touch any object freed in this way or not while iterating through
505 // all widgets. 505 // all widgets.
506 contents()->NavigateAndCommit(kUrl2); 506 contents()->NavigateAndCommit(kUrl2);
507 } 507 }
508 508
509 // When there is an error with the specified page, renderer exits view-source 509 // When there is an error with the specified page, renderer exits view-source
510 // mode. See WebFrameImpl::DidFail(). We check by this test that 510 // mode. See WebFrameImpl::DidFail(). We check by this test that
511 // EnableViewSourceMode message is sent on every navigation regardless 511 // EnableViewSourceMode message is sent on every navigation regardless
512 // RenderView is being newly created or reused. 512 // RenderView is being newly created or reused.
513 TEST_F(RenderViewHostManagerTest, AlwaysSendEnableViewSourceMode) { 513 TEST_F(RenderFrameHostManagerTest, AlwaysSendEnableViewSourceMode) {
514 const GURL kChromeUrl("chrome://foo"); 514 const GURL kChromeUrl("chrome://foo");
515 const GURL kUrl("view-source:http://foo"); 515 const GURL kUrl("view-source:http://foo");
516 516
517 // We have to navigate to some page at first since without this, the first 517 // We have to navigate to some page at first since without this, the first
518 // navigation will reuse the SiteInstance created by Init(), and the second 518 // navigation will reuse the SiteInstance created by Init(), and the second
519 // one will create a new SiteInstance. Because current_instance and 519 // one will create a new SiteInstance. Because current_instance and
520 // new_instance will be different, a new RenderViewHost will be created for 520 // new_instance will be different, a new RenderViewHost will be created for
521 // the second navigation. We have to avoid this in order to exercise the 521 // the second navigation. We have to avoid this in order to exercise the
522 // target code patch. 522 // target code patch.
523 NavigateActiveAndCommit(kChromeUrl); 523 NavigateActiveAndCommit(kChromeUrl);
(...skipping 28 matching lines...) Expand all
552 EXPECT_TRUE(last_rvh == rvh()); 552 EXPECT_TRUE(last_rvh == rvh());
553 test_rvh()->SendNavigate(new_id, kUrl); // The same page_id returned. 553 test_rvh()->SendNavigate(new_id, kUrl); // The same page_id returned.
554 EXPECT_EQ(controller().GetLastCommittedEntryIndex(), 1); 554 EXPECT_EQ(controller().GetLastCommittedEntryIndex(), 1);
555 EXPECT_FALSE(controller().GetPendingEntry()); 555 EXPECT_FALSE(controller().GetPendingEntry());
556 // New message should be sent out to make sure to enter view-source mode. 556 // New message should be sent out to make sure to enter view-source mode.
557 EXPECT_TRUE(process()->sink().GetUniqueMessageMatching( 557 EXPECT_TRUE(process()->sink().GetUniqueMessageMatching(
558 ViewMsg_EnableViewSourceMode::ID)); 558 ViewMsg_EnableViewSourceMode::ID));
559 } 559 }
560 560
561 // Tests the Init function by checking the initial RenderViewHost. 561 // Tests the Init function by checking the initial RenderViewHost.
562 TEST_F(RenderViewHostManagerTest, Init) { 562 TEST_F(RenderFrameHostManagerTest, Init) {
563 // Using TestBrowserContext. 563 // Using TestBrowserContext.
564 SiteInstanceImpl* instance = 564 SiteInstanceImpl* instance =
565 static_cast<SiteInstanceImpl*>(SiteInstance::Create(browser_context())); 565 static_cast<SiteInstanceImpl*>(SiteInstance::Create(browser_context()));
566 EXPECT_FALSE(instance->HasSite()); 566 EXPECT_FALSE(instance->HasSite());
567 567
568 scoped_ptr<TestWebContents> web_contents( 568 scoped_ptr<TestWebContents> web_contents(
569 TestWebContents::Create(browser_context(), instance)); 569 TestWebContents::Create(browser_context(), instance));
570 RenderViewHostManager manager(web_contents.get(), web_contents.get(), 570 RenderFrameHostManager manager(web_contents.get(), web_contents.get(),
571 web_contents.get()); 571 web_contents.get());
572 572
573 manager.Init(browser_context(), instance, MSG_ROUTING_NONE, MSG_ROUTING_NONE); 573 manager.Init(browser_context(), instance, MSG_ROUTING_NONE, MSG_ROUTING_NONE);
574 574
575 RenderViewHost* host = manager.current_host(); 575 RenderViewHost* host = manager.current_host();
576 ASSERT_TRUE(host); 576 ASSERT_TRUE(host);
577 EXPECT_EQ(instance, host->GetSiteInstance()); 577 EXPECT_EQ(instance, host->GetSiteInstance());
578 EXPECT_EQ(web_contents.get(), host->GetDelegate()); 578 EXPECT_EQ(web_contents.get(), host->GetDelegate());
579 EXPECT_TRUE(manager.GetRenderWidgetHostView()); 579 EXPECT_TRUE(manager.GetRenderWidgetHostView());
580 EXPECT_FALSE(manager.pending_render_view_host()); 580 EXPECT_FALSE(manager.pending_render_view_host());
581 } 581 }
582 582
583 // Tests the Navigate function. We navigate three sites consecutively and check 583 // Tests the Navigate function. We navigate three sites consecutively and check
584 // how the pending/committed RenderViewHost are modified. 584 // how the pending/committed RenderViewHost are modified.
585 TEST_F(RenderViewHostManagerTest, Navigate) { 585 TEST_F(RenderFrameHostManagerTest, Navigate) {
586 TestNotificationTracker notifications; 586 TestNotificationTracker notifications;
587 587
588 SiteInstance* instance = SiteInstance::Create(browser_context()); 588 SiteInstance* instance = SiteInstance::Create(browser_context());
589 589
590 scoped_ptr<TestWebContents> web_contents( 590 scoped_ptr<TestWebContents> web_contents(
591 TestWebContents::Create(browser_context(), instance)); 591 TestWebContents::Create(browser_context(), instance));
592 notifications.ListenFor(NOTIFICATION_RENDER_VIEW_HOST_CHANGED, 592 notifications.ListenFor(NOTIFICATION_RENDER_VIEW_HOST_CHANGED,
593 Source<WebContents>(web_contents.get())); 593 Source<WebContents>(web_contents.get()));
594 594
595 // Create. 595 // Create.
596 RenderViewHostManager manager(web_contents.get(), web_contents.get(), 596 RenderFrameHostManager manager(web_contents.get(), web_contents.get(),
597 web_contents.get()); 597 web_contents.get());
598 598
599 manager.Init(browser_context(), instance, MSG_ROUTING_NONE, MSG_ROUTING_NONE); 599 manager.Init(browser_context(), instance, MSG_ROUTING_NONE, MSG_ROUTING_NONE);
600 600
601 RenderViewHost* host; 601 RenderViewHost* host;
602 602
603 // 1) The first navigation. -------------------------- 603 // 1) The first navigation. --------------------------
604 const GURL kUrl1("http://www.google.com/"); 604 const GURL kUrl1("http://www.google.com/");
605 NavigationEntryImpl entry1( 605 NavigationEntryImpl entry1(
606 NULL /* instance */, -1 /* page_id */, kUrl1, Referrer(), 606 NULL /* instance */, -1 /* page_id */, kUrl1, Referrer(),
607 string16() /* title */, PAGE_TRANSITION_TYPED, 607 string16() /* title */, PAGE_TRANSITION_TYPED,
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
667 667
668 // We should observe a notification. 668 // We should observe a notification.
669 EXPECT_TRUE( 669 EXPECT_TRUE(
670 notifications.Check1AndReset(NOTIFICATION_RENDER_VIEW_HOST_CHANGED)); 670 notifications.Check1AndReset(NOTIFICATION_RENDER_VIEW_HOST_CHANGED));
671 } 671 }
672 672
673 // Tests the Navigate function. In this unit test we verify that the Navigate 673 // Tests the Navigate function. In this unit test we verify that the Navigate
674 // function can handle a new navigation event before the previous navigation 674 // function can handle a new navigation event before the previous navigation
675 // has been committed. This is also a regression test for 675 // has been committed. This is also a regression test for
676 // http://crbug.com/104600. 676 // http://crbug.com/104600.
677 TEST_F(RenderViewHostManagerTest, NavigateWithEarlyReNavigation) { 677 TEST_F(RenderFrameHostManagerTest, NavigateWithEarlyReNavigation) {
678 TestNotificationTracker notifications; 678 TestNotificationTracker notifications;
679 679
680 SiteInstance* instance = SiteInstance::Create(browser_context()); 680 SiteInstance* instance = SiteInstance::Create(browser_context());
681 681
682 scoped_ptr<TestWebContents> web_contents( 682 scoped_ptr<TestWebContents> web_contents(
683 TestWebContents::Create(browser_context(), instance)); 683 TestWebContents::Create(browser_context(), instance));
684 notifications.ListenFor(NOTIFICATION_RENDER_VIEW_HOST_CHANGED, 684 notifications.ListenFor(NOTIFICATION_RENDER_VIEW_HOST_CHANGED,
685 Source<WebContents>(web_contents.get())); 685 Source<WebContents>(web_contents.get()));
686 686
687 // Create. 687 // Create.
688 RenderViewHostManager manager(web_contents.get(), web_contents.get(), 688 RenderFrameHostManager manager(web_contents.get(), web_contents.get(),
689 web_contents.get()); 689 web_contents.get());
690 690
691 manager.Init(browser_context(), instance, MSG_ROUTING_NONE, MSG_ROUTING_NONE); 691 manager.Init(browser_context(), instance, MSG_ROUTING_NONE, MSG_ROUTING_NONE);
692 692
693 // 1) The first navigation. -------------------------- 693 // 1) The first navigation. --------------------------
694 const GURL kUrl1("http://www.google.com/"); 694 const GURL kUrl1("http://www.google.com/");
695 NavigationEntryImpl entry1(NULL /* instance */, -1 /* page_id */, kUrl1, 695 NavigationEntryImpl entry1(NULL /* instance */, -1 /* page_id */, kUrl1,
696 Referrer(), string16() /* title */, 696 Referrer(), string16() /* title */,
697 PAGE_TRANSITION_TYPED, 697 PAGE_TRANSITION_TYPED,
698 false /* is_renderer_init */); 698 false /* is_renderer_init */);
699 RenderViewHost* host = manager.Navigate(entry1); 699 RenderViewHost* host = manager.Navigate(entry1);
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
746 // the RVH): Simulate response from RenderView for ViewMsg_ShouldClose sent by 746 // the RVH): Simulate response from RenderView for ViewMsg_ShouldClose sent by
747 // FirePageBeforeUnload. 747 // FirePageBeforeUnload.
748 TestRenderViewHost* test_host = static_cast<TestRenderViewHost*>(host); 748 TestRenderViewHost* test_host = static_cast<TestRenderViewHost*>(host);
749 MockRenderProcessHost* test_process_host = 749 MockRenderProcessHost* test_process_host =
750 static_cast<MockRenderProcessHost*>(test_host->GetProcess()); 750 static_cast<MockRenderProcessHost*>(test_host->GetProcess());
751 EXPECT_TRUE(test_process_host->sink().GetUniqueMessageMatching( 751 EXPECT_TRUE(test_process_host->sink().GetUniqueMessageMatching(
752 ViewMsg_ShouldClose::ID)); 752 ViewMsg_ShouldClose::ID));
753 test_host->SendShouldCloseACK(true); 753 test_host->SendShouldCloseACK(true);
754 754
755 // CrossSiteResourceHandler::StartCrossSiteTransition triggers a 755 // CrossSiteResourceHandler::StartCrossSiteTransition triggers a
756 // call of RenderViewHostManager::SwapOutOldPage before 756 // call of RenderFrameHostManager::SwapOutOldPage before
757 // RenderViewHostManager::DidNavigateMainFrame is called. 757 // RenderFrameHostManager::DidNavigateMainFrame is called.
758 // The RVH is not swapped out until the commit. 758 // The RVH is not swapped out until the commit.
759 manager.SwapOutOldPage(); 759 manager.SwapOutOldPage();
760 EXPECT_TRUE(test_process_host->sink().GetUniqueMessageMatching( 760 EXPECT_TRUE(test_process_host->sink().GetUniqueMessageMatching(
761 ViewMsg_SwapOut::ID)); 761 ViewMsg_SwapOut::ID));
762 test_host->OnSwappedOut(false); 762 test_host->OnSwappedOut(false);
763 763
764 EXPECT_EQ(host, manager.current_host()); 764 EXPECT_EQ(host, manager.current_host());
765 EXPECT_FALSE(static_cast<RenderViewHostImpl*>( 765 EXPECT_FALSE(static_cast<RenderViewHostImpl*>(
766 manager.current_host())->is_swapped_out()); 766 manager.current_host())->is_swapped_out());
767 EXPECT_EQ(host2, manager.pending_render_view_host()); 767 EXPECT_EQ(host2, manager.pending_render_view_host());
(...skipping 24 matching lines...) Expand all
792 EXPECT_EQ(host, manager.current_host()); 792 EXPECT_EQ(host, manager.current_host());
793 EXPECT_FALSE(static_cast<RenderViewHostImpl*>( 793 EXPECT_FALSE(static_cast<RenderViewHostImpl*>(
794 manager.current_host())->is_swapped_out()); 794 manager.current_host())->is_swapped_out());
795 795
796 // Simulate a response to the second beforeunload request. 796 // Simulate a response to the second beforeunload request.
797 EXPECT_TRUE(test_process_host->sink().GetUniqueMessageMatching( 797 EXPECT_TRUE(test_process_host->sink().GetUniqueMessageMatching(
798 ViewMsg_ShouldClose::ID)); 798 ViewMsg_ShouldClose::ID));
799 test_host->SendShouldCloseACK(true); 799 test_host->SendShouldCloseACK(true);
800 800
801 // CrossSiteResourceHandler::StartCrossSiteTransition triggers a 801 // CrossSiteResourceHandler::StartCrossSiteTransition triggers a
802 // call of RenderViewHostManager::SwapOutOldPage before 802 // call of RenderFrameHostManager::SwapOutOldPage before
803 // RenderViewHostManager::DidNavigateMainFrame is called. 803 // RenderFrameHostManager::DidNavigateMainFrame is called.
804 // The RVH is not swapped out until the commit. 804 // The RVH is not swapped out until the commit.
805 manager.SwapOutOldPage(); 805 manager.SwapOutOldPage();
806 EXPECT_TRUE(test_process_host->sink().GetUniqueMessageMatching( 806 EXPECT_TRUE(test_process_host->sink().GetUniqueMessageMatching(
807 ViewMsg_SwapOut::ID)); 807 ViewMsg_SwapOut::ID));
808 test_host->OnSwappedOut(false); 808 test_host->OnSwappedOut(false);
809 809
810 // Commit. 810 // Commit.
811 manager.DidNavigateMainFrame(host3); 811 manager.DidNavigateMainFrame(host3);
812 EXPECT_TRUE(host3 == manager.current_host()); 812 EXPECT_TRUE(host3 == manager.current_host());
813 ASSERT_TRUE(host3); 813 ASSERT_TRUE(host3);
814 EXPECT_TRUE(static_cast<SiteInstanceImpl*>(host3->GetSiteInstance())-> 814 EXPECT_TRUE(static_cast<SiteInstanceImpl*>(host3->GetSiteInstance())->
815 HasSite()); 815 HasSite());
816 // Check the pending RenderViewHost has been committed. 816 // Check the pending RenderViewHost has been committed.
817 EXPECT_FALSE(manager.pending_render_view_host()); 817 EXPECT_FALSE(manager.pending_render_view_host());
818 818
819 // We should observe a notification. 819 // We should observe a notification.
820 EXPECT_TRUE( 820 EXPECT_TRUE(
821 notifications.Check1AndReset(NOTIFICATION_RENDER_VIEW_HOST_CHANGED)); 821 notifications.Check1AndReset(NOTIFICATION_RENDER_VIEW_HOST_CHANGED));
822 } 822 }
823 823
824 // Tests WebUI creation. 824 // Tests WebUI creation.
825 TEST_F(RenderViewHostManagerTest, WebUI) { 825 TEST_F(RenderFrameHostManagerTest, WebUI) {
826 set_should_create_webui(true); 826 set_should_create_webui(true);
827 SiteInstance* instance = SiteInstance::Create(browser_context()); 827 SiteInstance* instance = SiteInstance::Create(browser_context());
828 828
829 scoped_ptr<TestWebContents> web_contents( 829 scoped_ptr<TestWebContents> web_contents(
830 TestWebContents::Create(browser_context(), instance)); 830 TestWebContents::Create(browser_context(), instance));
831 RenderViewHostManager manager(web_contents.get(), web_contents.get(), 831 RenderFrameHostManager manager(web_contents.get(), web_contents.get(),
832 web_contents.get()); 832 web_contents.get());
833 833
834 manager.Init(browser_context(), instance, MSG_ROUTING_NONE, MSG_ROUTING_NONE); 834 manager.Init(browser_context(), instance, MSG_ROUTING_NONE, MSG_ROUTING_NONE);
835 EXPECT_FALSE(manager.current_host()->IsRenderViewLive()); 835 EXPECT_FALSE(manager.current_host()->IsRenderViewLive());
836 836
837 const GURL kUrl("chrome://foo"); 837 const GURL kUrl("chrome://foo");
838 NavigationEntryImpl entry(NULL /* instance */, -1 /* page_id */, kUrl, 838 NavigationEntryImpl entry(NULL /* instance */, -1 /* page_id */, kUrl,
839 Referrer(), string16() /* title */, 839 Referrer(), string16() /* title */,
840 PAGE_TRANSITION_TYPED, 840 PAGE_TRANSITION_TYPED,
841 false /* is_renderer_init */); 841 false /* is_renderer_init */);
842 RenderViewHost* host = manager.Navigate(entry); 842 RenderViewHost* host = manager.Navigate(entry);
(...skipping 18 matching lines...) Expand all
861 EXPECT_FALSE(manager.pending_web_ui()); 861 EXPECT_FALSE(manager.pending_web_ui());
862 EXPECT_TRUE(manager.web_ui()); 862 EXPECT_TRUE(manager.web_ui());
863 863
864 // Commit. 864 // Commit.
865 manager.DidNavigateMainFrame(host); 865 manager.DidNavigateMainFrame(host);
866 EXPECT_TRUE(host->GetEnabledBindings() & BINDINGS_POLICY_WEB_UI); 866 EXPECT_TRUE(host->GetEnabledBindings() & BINDINGS_POLICY_WEB_UI);
867 } 867 }
868 868
869 // Tests that we can open a WebUI link in a new tab from a WebUI page and still 869 // Tests that we can open a WebUI link in a new tab from a WebUI page and still
870 // grant the correct bindings. http://crbug.com/189101. 870 // grant the correct bindings. http://crbug.com/189101.
871 TEST_F(RenderViewHostManagerTest, WebUIInNewTab) { 871 TEST_F(RenderFrameHostManagerTest, WebUIInNewTab) {
872 set_should_create_webui(true); 872 set_should_create_webui(true);
873 SiteInstance* blank_instance = SiteInstance::Create(browser_context()); 873 SiteInstance* blank_instance = SiteInstance::Create(browser_context());
874 874
875 // Create a blank tab. 875 // Create a blank tab.
876 scoped_ptr<TestWebContents> web_contents1( 876 scoped_ptr<TestWebContents> web_contents1(
877 TestWebContents::Create(browser_context(), blank_instance)); 877 TestWebContents::Create(browser_context(), blank_instance));
878 RenderViewHostManager manager1(web_contents1.get(), web_contents1.get(), 878 RenderFrameHostManager manager1(web_contents1.get(), web_contents1.get(),
879 web_contents1.get()); 879 web_contents1.get());
880 manager1.Init( 880 manager1.Init(
881 browser_context(), blank_instance, MSG_ROUTING_NONE, MSG_ROUTING_NONE); 881 browser_context(), blank_instance, MSG_ROUTING_NONE, MSG_ROUTING_NONE);
882 // Test the case that new RVH is considered live. 882 // Test the case that new RVH is considered live.
883 manager1.current_host()->CreateRenderView(string16(), -1, -1); 883 manager1.current_host()->CreateRenderView(string16(), -1, -1);
884 884
885 // Navigate to a WebUI page. 885 // Navigate to a WebUI page.
886 const GURL kUrl1("chrome://foo"); 886 const GURL kUrl1("chrome://foo");
887 NavigationEntryImpl entry1(NULL /* instance */, -1 /* page_id */, kUrl1, 887 NavigationEntryImpl entry1(NULL /* instance */, -1 /* page_id */, kUrl1,
888 Referrer(), string16() /* title */, 888 Referrer(), string16() /* title */,
889 PAGE_TRANSITION_TYPED, 889 PAGE_TRANSITION_TYPED,
890 false /* is_renderer_init */); 890 false /* is_renderer_init */);
891 RenderViewHost* host1 = manager1.Navigate(entry1); 891 RenderViewHost* host1 = manager1.Navigate(entry1);
892 892
893 // We should have a pending navigation to the WebUI RenderViewHost. 893 // We should have a pending navigation to the WebUI RenderViewHost.
894 // It should already have bindings. 894 // It should already have bindings.
895 EXPECT_EQ(host1, manager1.pending_render_view_host()); 895 EXPECT_EQ(host1, manager1.pending_render_view_host());
896 EXPECT_NE(host1, manager1.current_host()); 896 EXPECT_NE(host1, manager1.current_host());
897 EXPECT_TRUE(host1->GetEnabledBindings() & BINDINGS_POLICY_WEB_UI); 897 EXPECT_TRUE(host1->GetEnabledBindings() & BINDINGS_POLICY_WEB_UI);
898 898
899 // Commit and ensure we still have bindings. 899 // Commit and ensure we still have bindings.
900 manager1.DidNavigateMainFrame(host1); 900 manager1.DidNavigateMainFrame(host1);
901 SiteInstance* webui_instance = host1->GetSiteInstance(); 901 SiteInstance* webui_instance = host1->GetSiteInstance();
902 EXPECT_EQ(host1, manager1.current_host()); 902 EXPECT_EQ(host1, manager1.current_host());
903 EXPECT_TRUE(host1->GetEnabledBindings() & BINDINGS_POLICY_WEB_UI); 903 EXPECT_TRUE(host1->GetEnabledBindings() & BINDINGS_POLICY_WEB_UI);
904 904
905 // Now simulate clicking a link that opens in a new tab. 905 // Now simulate clicking a link that opens in a new tab.
906 scoped_ptr<TestWebContents> web_contents2( 906 scoped_ptr<TestWebContents> web_contents2(
907 TestWebContents::Create(browser_context(), webui_instance)); 907 TestWebContents::Create(browser_context(), webui_instance));
908 RenderViewHostManager manager2(web_contents2.get(), web_contents2.get(), 908 RenderFrameHostManager manager2(web_contents2.get(), web_contents2.get(),
909 web_contents2.get()); 909 web_contents2.get());
910 manager2.Init( 910 manager2.Init(
911 browser_context(), webui_instance, MSG_ROUTING_NONE, MSG_ROUTING_NONE); 911 browser_context(), webui_instance, MSG_ROUTING_NONE, MSG_ROUTING_NONE);
912 // Make sure the new RVH is considered live. This is usually done in 912 // Make sure the new RVH is considered live. This is usually done in
913 // RenderWidgetHost::Init when opening a new tab from a link. 913 // RenderWidgetHost::Init when opening a new tab from a link.
914 manager2.current_host()->CreateRenderView(string16(), -1, -1); 914 manager2.current_host()->CreateRenderView(string16(), -1, -1);
915 915
916 const GURL kUrl2("chrome://foo/bar"); 916 const GURL kUrl2("chrome://foo/bar");
917 NavigationEntryImpl entry2(NULL /* instance */, -1 /* page_id */, kUrl2, 917 NavigationEntryImpl entry2(NULL /* instance */, -1 /* page_id */, kUrl2,
918 Referrer(), string16() /* title */, 918 Referrer(), string16() /* title */,
919 PAGE_TRANSITION_LINK, 919 PAGE_TRANSITION_LINK,
920 true /* is_renderer_init */); 920 true /* is_renderer_init */);
921 RenderViewHost* host2 = manager2.Navigate(entry2); 921 RenderViewHost* host2 = manager2.Navigate(entry2);
922 922
923 // No cross-process transition happens because we are already in the right 923 // No cross-process transition happens because we are already in the right
924 // SiteInstance. We should grant bindings immediately. 924 // SiteInstance. We should grant bindings immediately.
925 EXPECT_EQ(host2, manager2.current_host()); 925 EXPECT_EQ(host2, manager2.current_host());
926 EXPECT_TRUE(host2->GetEnabledBindings() & BINDINGS_POLICY_WEB_UI); 926 EXPECT_TRUE(host2->GetEnabledBindings() & BINDINGS_POLICY_WEB_UI);
927 927
928 manager2.DidNavigateMainFrame(host2); 928 manager2.DidNavigateMainFrame(host2);
929 } 929 }
930 930
931 // Tests that we don't end up in an inconsistent state if a page does a back and 931 // Tests that we don't end up in an inconsistent state if a page does a back and
932 // then reload. http://crbug.com/51680 932 // then reload. http://crbug.com/51680
933 TEST_F(RenderViewHostManagerTest, PageDoesBackAndReload) { 933 TEST_F(RenderFrameHostManagerTest, PageDoesBackAndReload) {
934 const GURL kUrl1("http://www.google.com/"); 934 const GURL kUrl1("http://www.google.com/");
935 const GURL kUrl2("http://www.evil-site.com/"); 935 const GURL kUrl2("http://www.evil-site.com/");
936 936
937 // Navigate to a safe site, then an evil site. 937 // Navigate to a safe site, then an evil site.
938 // This will switch RenderViewHosts. We cannot assert that the first and 938 // This will switch RenderViewHosts. We cannot assert that the first and
939 // second RVHs are different, though, because the first one may be promptly 939 // second RVHs are different, though, because the first one may be promptly
940 // deleted. 940 // deleted.
941 contents()->NavigateAndCommit(kUrl1); 941 contents()->NavigateAndCommit(kUrl1);
942 contents()->NavigateAndCommit(kUrl2); 942 contents()->NavigateAndCommit(kUrl2);
943 RenderViewHost* evil_rvh = contents()->GetRenderViewHost(); 943 RenderViewHost* evil_rvh = contents()->GetRenderViewHost();
(...skipping 26 matching lines...) Expand all
970 970
971 // Also we should not have a pending navigation entry. 971 // Also we should not have a pending navigation entry.
972 EXPECT_TRUE(contents()->GetController().GetPendingEntry() == NULL); 972 EXPECT_TRUE(contents()->GetController().GetPendingEntry() == NULL);
973 NavigationEntry* entry = contents()->GetController().GetVisibleEntry(); 973 NavigationEntry* entry = contents()->GetController().GetVisibleEntry();
974 ASSERT_TRUE(entry != NULL); 974 ASSERT_TRUE(entry != NULL);
975 EXPECT_EQ(kUrl2, entry->GetURL()); 975 EXPECT_EQ(kUrl2, entry->GetURL());
976 } 976 }
977 977
978 // Ensure that we can go back and forward even if a SwapOut ACK isn't received. 978 // Ensure that we can go back and forward even if a SwapOut ACK isn't received.
979 // See http://crbug.com/93427. 979 // See http://crbug.com/93427.
980 TEST_F(RenderViewHostManagerTest, NavigateAfterMissingSwapOutACK) { 980 TEST_F(RenderFrameHostManagerTest, NavigateAfterMissingSwapOutACK) {
981 const GURL kUrl1("http://www.google.com/"); 981 const GURL kUrl1("http://www.google.com/");
982 const GURL kUrl2("http://www.chromium.org/"); 982 const GURL kUrl2("http://www.chromium.org/");
983 983
984 // Navigate to two pages. 984 // Navigate to two pages.
985 contents()->NavigateAndCommit(kUrl1); 985 contents()->NavigateAndCommit(kUrl1);
986 TestRenderViewHost* rvh1 = test_rvh(); 986 TestRenderViewHost* rvh1 = test_rvh();
987 987
988 // Keep active_view_count nonzero so that no swapped out views in 988 // Keep active_view_count nonzero so that no swapped out views in
989 // this SiteInstance get forcefully deleted. 989 // this SiteInstance get forcefully deleted.
990 static_cast<SiteInstanceImpl*>(rvh1->GetSiteInstance())-> 990 static_cast<SiteInstanceImpl*>(rvh1->GetSiteInstance())->
(...skipping 27 matching lines...) Expand all
1018 const NavigationEntry* entry2 = contents()->GetController().GetPendingEntry(); 1018 const NavigationEntry* entry2 = contents()->GetController().GetPendingEntry();
1019 rvh2->SendNavigate(entry2->GetPageID(), entry2->GetURL()); 1019 rvh2->SendNavigate(entry2->GetPageID(), entry2->GetURL());
1020 EXPECT_EQ(rvh2, rvh()); 1020 EXPECT_EQ(rvh2, rvh());
1021 EXPECT_FALSE(rvh2->is_swapped_out()); 1021 EXPECT_FALSE(rvh2->is_swapped_out());
1022 EXPECT_TRUE(rvh1->is_swapped_out()); 1022 EXPECT_TRUE(rvh1->is_swapped_out());
1023 } 1023 }
1024 1024
1025 // Test that we create swapped out RVHs for the opener chain when navigating an 1025 // Test that we create swapped out RVHs for the opener chain when navigating an
1026 // opened tab cross-process. This allows us to support certain cross-process 1026 // opened tab cross-process. This allows us to support certain cross-process
1027 // JavaScript calls (http://crbug.com/99202). 1027 // JavaScript calls (http://crbug.com/99202).
1028 TEST_F(RenderViewHostManagerTest, CreateSwappedOutOpenerRVHs) { 1028 TEST_F(RenderFrameHostManagerTest, CreateSwappedOutOpenerRVHs) {
1029 const GURL kUrl1("http://www.google.com/"); 1029 const GURL kUrl1("http://www.google.com/");
1030 const GURL kUrl2("http://www.chromium.org/"); 1030 const GURL kUrl2("http://www.chromium.org/");
1031 const GURL kChromeUrl("chrome://foo"); 1031 const GURL kChromeUrl("chrome://foo");
1032 1032
1033 // Navigate to an initial URL. 1033 // Navigate to an initial URL.
1034 contents()->NavigateAndCommit(kUrl1); 1034 contents()->NavigateAndCommit(kUrl1);
1035 RenderViewHostManager* manager = contents()->GetRenderManagerForTesting(); 1035 RenderFrameHostManager* manager = contents()->GetRenderManagerForTesting();
1036 TestRenderViewHost* rvh1 = test_rvh(); 1036 TestRenderViewHost* rvh1 = test_rvh();
1037 1037
1038 // Create 2 new tabs and simulate them being the opener chain for the main 1038 // Create 2 new tabs and simulate them being the opener chain for the main
1039 // tab. They should be in the same SiteInstance. 1039 // tab. They should be in the same SiteInstance.
1040 scoped_ptr<TestWebContents> opener1( 1040 scoped_ptr<TestWebContents> opener1(
1041 TestWebContents::Create(browser_context(), rvh1->GetSiteInstance())); 1041 TestWebContents::Create(browser_context(), rvh1->GetSiteInstance()));
1042 RenderViewHostManager* opener1_manager = 1042 RenderFrameHostManager* opener1_manager =
1043 opener1->GetRenderManagerForTesting(); 1043 opener1->GetRenderManagerForTesting();
1044 contents()->SetOpener(opener1.get()); 1044 contents()->SetOpener(opener1.get());
1045 1045
1046 scoped_ptr<TestWebContents> opener2( 1046 scoped_ptr<TestWebContents> opener2(
1047 TestWebContents::Create(browser_context(), rvh1->GetSiteInstance())); 1047 TestWebContents::Create(browser_context(), rvh1->GetSiteInstance()));
1048 RenderViewHostManager* opener2_manager = 1048 RenderFrameHostManager* opener2_manager =
1049 opener2->GetRenderManagerForTesting(); 1049 opener2->GetRenderManagerForTesting();
1050 opener1->SetOpener(opener2.get()); 1050 opener1->SetOpener(opener2.get());
1051 1051
1052 // Navigate to a cross-site URL (different SiteInstance but same 1052 // Navigate to a cross-site URL (different SiteInstance but same
1053 // BrowsingInstance). 1053 // BrowsingInstance).
1054 contents()->NavigateAndCommit(kUrl2); 1054 contents()->NavigateAndCommit(kUrl2);
1055 TestRenderViewHost* rvh2 = test_rvh(); 1055 TestRenderViewHost* rvh2 = test_rvh();
1056 EXPECT_NE(rvh1->GetSiteInstance(), rvh2->GetSiteInstance()); 1056 EXPECT_NE(rvh1->GetSiteInstance(), rvh2->GetSiteInstance());
1057 EXPECT_TRUE(rvh1->GetSiteInstance()->IsRelatedSiteInstance( 1057 EXPECT_TRUE(rvh1->GetSiteInstance()->IsRelatedSiteInstance(
1058 rvh2->GetSiteInstance())); 1058 rvh2->GetSiteInstance()));
(...skipping 25 matching lines...) Expand all
1084 // No scripting is allowed across BrowsingInstances, so we should not create 1084 // No scripting is allowed across BrowsingInstances, so we should not create
1085 // swapped out RVHs for the opener chain in this case. 1085 // swapped out RVHs for the opener chain in this case.
1086 EXPECT_FALSE(opener1_manager->GetSwappedOutRenderViewHost( 1086 EXPECT_FALSE(opener1_manager->GetSwappedOutRenderViewHost(
1087 rvh3->GetSiteInstance())); 1087 rvh3->GetSiteInstance()));
1088 EXPECT_FALSE(opener2_manager->GetSwappedOutRenderViewHost( 1088 EXPECT_FALSE(opener2_manager->GetSwappedOutRenderViewHost(
1089 rvh3->GetSiteInstance())); 1089 rvh3->GetSiteInstance()));
1090 } 1090 }
1091 1091
1092 // Test that we clean up swapped out RenderViewHosts when a process hosting 1092 // Test that we clean up swapped out RenderViewHosts when a process hosting
1093 // those associated RenderViews crashes. http://crbug.com/258993 1093 // those associated RenderViews crashes. http://crbug.com/258993
1094 TEST_F(RenderViewHostManagerTest, CleanUpSwappedOutRVHOnProcessCrash) { 1094 TEST_F(RenderFrameHostManagerTest, CleanUpSwappedOutRVHOnProcessCrash) {
1095 const GURL kUrl1("http://www.google.com/"); 1095 const GURL kUrl1("http://www.google.com/");
1096 const GURL kUrl2("http://www.chromium.org/"); 1096 const GURL kUrl2("http://www.chromium.org/");
1097 1097
1098 // Navigate to an initial URL. 1098 // Navigate to an initial URL.
1099 contents()->NavigateAndCommit(kUrl1); 1099 contents()->NavigateAndCommit(kUrl1);
1100 TestRenderViewHost* rvh1 = test_rvh(); 1100 TestRenderViewHost* rvh1 = test_rvh();
1101 1101
1102 // Create a new tab as an opener for the main tab. 1102 // Create a new tab as an opener for the main tab.
1103 scoped_ptr<TestWebContents> opener1( 1103 scoped_ptr<TestWebContents> opener1(
1104 TestWebContents::Create(browser_context(), rvh1->GetSiteInstance())); 1104 TestWebContents::Create(browser_context(), rvh1->GetSiteInstance()));
1105 RenderViewHostManager* opener1_manager = 1105 RenderFrameHostManager* opener1_manager =
1106 opener1->GetRenderManagerForTesting(); 1106 opener1->GetRenderManagerForTesting();
1107 contents()->SetOpener(opener1.get()); 1107 contents()->SetOpener(opener1.get());
1108 1108
1109 // Make sure the new opener RVH is considered live. 1109 // Make sure the new opener RVH is considered live.
1110 opener1_manager->current_host()->CreateRenderView(string16(), -1, -1); 1110 opener1_manager->current_host()->CreateRenderView(string16(), -1, -1);
1111 1111
1112 // Use a cross-process navigation in the opener to swap out the old RVH. 1112 // Use a cross-process navigation in the opener to swap out the old RVH.
1113 EXPECT_FALSE(opener1_manager->GetSwappedOutRenderViewHost( 1113 EXPECT_FALSE(opener1_manager->GetSwappedOutRenderViewHost(
1114 rvh1->GetSiteInstance())); 1114 rvh1->GetSiteInstance()));
1115 opener1->NavigateAndCommit(kUrl2); 1115 opener1->NavigateAndCommit(kUrl2);
(...skipping 19 matching lines...) Expand all
1135 // in the original SiteInstance. 1135 // in the original SiteInstance.
1136 contents()->GetController().Reload(true); 1136 contents()->GetController().Reload(true);
1137 EXPECT_EQ(opener1_manager->GetSwappedOutRenderViewHost( 1137 EXPECT_EQ(opener1_manager->GetSwappedOutRenderViewHost(
1138 rvh1->GetSiteInstance())->GetRoutingID(), 1138 rvh1->GetSiteInstance())->GetRoutingID(),
1139 test_rvh()->opener_route_id()); 1139 test_rvh()->opener_route_id());
1140 } 1140 }
1141 1141
1142 // Test that RenderViewHosts created for WebUI navigations are properly 1142 // Test that RenderViewHosts created for WebUI navigations are properly
1143 // granted WebUI bindings even if an unprivileged swapped out RenderViewHost 1143 // granted WebUI bindings even if an unprivileged swapped out RenderViewHost
1144 // is in the same process (http://crbug.com/79918). 1144 // is in the same process (http://crbug.com/79918).
1145 TEST_F(RenderViewHostManagerTest, EnableWebUIWithSwappedOutOpener) { 1145 TEST_F(RenderFrameHostManagerTest, EnableWebUIWithSwappedOutOpener) {
1146 set_should_create_webui(true); 1146 set_should_create_webui(true);
1147 const GURL kSettingsUrl("chrome://chrome/settings"); 1147 const GURL kSettingsUrl("chrome://chrome/settings");
1148 const GURL kPluginUrl("chrome://plugins"); 1148 const GURL kPluginUrl("chrome://plugins");
1149 1149
1150 // Navigate to an initial WebUI URL. 1150 // Navigate to an initial WebUI URL.
1151 contents()->NavigateAndCommit(kSettingsUrl); 1151 contents()->NavigateAndCommit(kSettingsUrl);
1152 1152
1153 // Ensure the RVH has WebUI bindings. 1153 // Ensure the RVH has WebUI bindings.
1154 TestRenderViewHost* rvh1 = test_rvh(); 1154 TestRenderViewHost* rvh1 = test_rvh();
1155 EXPECT_TRUE(rvh1->GetEnabledBindings() & BINDINGS_POLICY_WEB_UI); 1155 EXPECT_TRUE(rvh1->GetEnabledBindings() & BINDINGS_POLICY_WEB_UI);
1156 1156
1157 // Create a new tab and simulate it being the opener for the main 1157 // Create a new tab and simulate it being the opener for the main
1158 // tab. It should be in the same SiteInstance. 1158 // tab. It should be in the same SiteInstance.
1159 scoped_ptr<TestWebContents> opener1( 1159 scoped_ptr<TestWebContents> opener1(
1160 TestWebContents::Create(browser_context(), rvh1->GetSiteInstance())); 1160 TestWebContents::Create(browser_context(), rvh1->GetSiteInstance()));
1161 RenderViewHostManager* opener1_manager = 1161 RenderFrameHostManager* opener1_manager =
1162 opener1->GetRenderManagerForTesting(); 1162 opener1->GetRenderManagerForTesting();
1163 contents()->SetOpener(opener1.get()); 1163 contents()->SetOpener(opener1.get());
1164 1164
1165 // Navigate to a different WebUI URL (different SiteInstance, same 1165 // Navigate to a different WebUI URL (different SiteInstance, same
1166 // BrowsingInstance). 1166 // BrowsingInstance).
1167 contents()->NavigateAndCommit(kPluginUrl); 1167 contents()->NavigateAndCommit(kPluginUrl);
1168 TestRenderViewHost* rvh2 = test_rvh(); 1168 TestRenderViewHost* rvh2 = test_rvh();
1169 EXPECT_NE(rvh1->GetSiteInstance(), rvh2->GetSiteInstance()); 1169 EXPECT_NE(rvh1->GetSiteInstance(), rvh2->GetSiteInstance());
1170 EXPECT_TRUE(rvh1->GetSiteInstance()->IsRelatedSiteInstance( 1170 EXPECT_TRUE(rvh1->GetSiteInstance()->IsRelatedSiteInstance(
1171 rvh2->GetSiteInstance())); 1171 rvh2->GetSiteInstance()));
1172 1172
1173 // Ensure a swapped out RVH is created in the first opener tab. 1173 // Ensure a swapped out RVH is created in the first opener tab.
1174 TestRenderViewHost* opener1_rvh = static_cast<TestRenderViewHost*>( 1174 TestRenderViewHost* opener1_rvh = static_cast<TestRenderViewHost*>(
1175 opener1_manager->GetSwappedOutRenderViewHost(rvh2->GetSiteInstance())); 1175 opener1_manager->GetSwappedOutRenderViewHost(rvh2->GetSiteInstance()));
1176 EXPECT_TRUE(opener1_manager->IsOnSwappedOutList(opener1_rvh)); 1176 EXPECT_TRUE(opener1_manager->IsOnSwappedOutList(opener1_rvh));
1177 EXPECT_TRUE(opener1_rvh->is_swapped_out()); 1177 EXPECT_TRUE(opener1_rvh->is_swapped_out());
1178 1178
1179 // Ensure the new RVH has WebUI bindings. 1179 // Ensure the new RVH has WebUI bindings.
1180 EXPECT_TRUE(rvh2->GetEnabledBindings() & BINDINGS_POLICY_WEB_UI); 1180 EXPECT_TRUE(rvh2->GetEnabledBindings() & BINDINGS_POLICY_WEB_UI);
1181 } 1181 }
1182 1182
1183 // Test that we reuse the same guest SiteInstance if we navigate across sites. 1183 // Test that we reuse the same guest SiteInstance if we navigate across sites.
1184 TEST_F(RenderViewHostManagerTest, NoSwapOnGuestNavigations) { 1184 TEST_F(RenderFrameHostManagerTest, NoSwapOnGuestNavigations) {
1185 TestNotificationTracker notifications; 1185 TestNotificationTracker notifications;
1186 1186
1187 GURL guest_url(std::string(kGuestScheme).append("://abc123")); 1187 GURL guest_url(std::string(kGuestScheme).append("://abc123"));
1188 SiteInstance* instance = 1188 SiteInstance* instance =
1189 SiteInstance::CreateForURL(browser_context(), guest_url); 1189 SiteInstance::CreateForURL(browser_context(), guest_url);
1190 scoped_ptr<TestWebContents> web_contents( 1190 scoped_ptr<TestWebContents> web_contents(
1191 TestWebContents::Create(browser_context(), instance)); 1191 TestWebContents::Create(browser_context(), instance));
1192 1192
1193 // Create. 1193 // Create.
1194 RenderViewHostManager manager(web_contents.get(), web_contents.get(), 1194 RenderFrameHostManager manager(web_contents.get(), web_contents.get(),
1195 web_contents.get()); 1195 web_contents.get());
1196 1196
1197 manager.Init(browser_context(), instance, MSG_ROUTING_NONE, MSG_ROUTING_NONE); 1197 manager.Init(browser_context(), instance, MSG_ROUTING_NONE, MSG_ROUTING_NONE);
1198 1198
1199 RenderViewHost* host; 1199 RenderViewHost* host;
1200 1200
1201 // 1) The first navigation. -------------------------- 1201 // 1) The first navigation. --------------------------
1202 const GURL kUrl1("http://www.google.com/"); 1202 const GURL kUrl1("http://www.google.com/");
1203 NavigationEntryImpl entry1( 1203 NavigationEntryImpl entry1(
1204 NULL /* instance */, -1 /* page_id */, kUrl1, Referrer(), 1204 NULL /* instance */, -1 /* page_id */, kUrl1, Referrer(),
1205 string16() /* title */, PAGE_TRANSITION_TYPED, 1205 string16() /* title */, PAGE_TRANSITION_TYPED,
(...skipping 30 matching lines...) Expand all
1236 // Commit. 1236 // Commit.
1237 manager.DidNavigateMainFrame(host); 1237 manager.DidNavigateMainFrame(host);
1238 EXPECT_EQ(host, manager.current_host()); 1238 EXPECT_EQ(host, manager.current_host());
1239 ASSERT_TRUE(host); 1239 ASSERT_TRUE(host);
1240 EXPECT_EQ(static_cast<SiteInstanceImpl*>(host->GetSiteInstance()), 1240 EXPECT_EQ(static_cast<SiteInstanceImpl*>(host->GetSiteInstance()),
1241 instance); 1241 instance);
1242 } 1242 }
1243 1243
1244 // Test that we cancel a pending RVH if we close the tab while it's pending. 1244 // Test that we cancel a pending RVH if we close the tab while it's pending.
1245 // http://crbug.com/294697. 1245 // http://crbug.com/294697.
1246 TEST_F(RenderViewHostManagerTest, NavigateWithEarlyClose) { 1246 TEST_F(RenderFrameHostManagerTest, NavigateWithEarlyClose) {
1247 TestNotificationTracker notifications; 1247 TestNotificationTracker notifications;
1248 1248
1249 SiteInstance* instance = SiteInstance::Create(browser_context()); 1249 SiteInstance* instance = SiteInstance::Create(browser_context());
1250 1250
1251 BeforeUnloadFiredWebContentsDelegate delegate; 1251 BeforeUnloadFiredWebContentsDelegate delegate;
1252 scoped_ptr<TestWebContents> web_contents( 1252 scoped_ptr<TestWebContents> web_contents(
1253 TestWebContents::Create(browser_context(), instance)); 1253 TestWebContents::Create(browser_context(), instance));
1254 web_contents->SetDelegate(&delegate); 1254 web_contents->SetDelegate(&delegate);
1255 notifications.ListenFor(NOTIFICATION_RENDER_VIEW_HOST_CHANGED, 1255 notifications.ListenFor(NOTIFICATION_RENDER_VIEW_HOST_CHANGED,
1256 Source<WebContents>(web_contents.get())); 1256 Source<WebContents>(web_contents.get()));
1257 1257
1258 // Create. 1258 // Create.
1259 RenderViewHostManager manager(web_contents.get(), web_contents.get(), 1259 RenderFrameHostManager manager(web_contents.get(), web_contents.get(),
1260 web_contents.get()); 1260 web_contents.get());
1261 1261
1262 manager.Init(browser_context(), instance, MSG_ROUTING_NONE, MSG_ROUTING_NONE); 1262 manager.Init(browser_context(), instance, MSG_ROUTING_NONE, MSG_ROUTING_NONE);
1263 1263
1264 // 1) The first navigation. -------------------------- 1264 // 1) The first navigation. --------------------------
1265 const GURL kUrl1("http://www.google.com/"); 1265 const GURL kUrl1("http://www.google.com/");
1266 NavigationEntryImpl entry1(NULL /* instance */, -1 /* page_id */, kUrl1, 1266 NavigationEntryImpl entry1(NULL /* instance */, -1 /* page_id */, kUrl1,
1267 Referrer(), string16() /* title */, 1267 Referrer(), string16() /* title */,
1268 PAGE_TRANSITION_TYPED, 1268 PAGE_TRANSITION_TYPED,
1269 false /* is_renderer_init */); 1269 false /* is_renderer_init */);
1270 RenderViewHost* host = manager.Navigate(entry1); 1270 RenderViewHost* host = manager.Navigate(entry1);
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
1310 Source<RenderWidgetHost>(host2)); 1310 Source<RenderWidgetHost>(host2));
1311 manager.ShouldClosePage(false, true, base::TimeTicks()); 1311 manager.ShouldClosePage(false, true, base::TimeTicks());
1312 1312
1313 EXPECT_TRUE( 1313 EXPECT_TRUE(
1314 notifications.Check1AndReset(NOTIFICATION_RENDER_WIDGET_HOST_DESTROYED)); 1314 notifications.Check1AndReset(NOTIFICATION_RENDER_WIDGET_HOST_DESTROYED));
1315 EXPECT_FALSE(manager.pending_render_view_host()); 1315 EXPECT_FALSE(manager.pending_render_view_host());
1316 EXPECT_EQ(host, manager.current_host()); 1316 EXPECT_EQ(host, manager.current_host());
1317 } 1317 }
1318 1318
1319 } // namespace content 1319 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698