OLD | NEW |
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/files/file_path.h" | 5 #include "base/files/file_path.h" |
6 #include "base/strings/utf_string_conversions.h" | 6 #include "base/strings/utf_string_conversions.h" |
7 #include "content/browser/frame_host/cross_site_transferring_request.h" | 7 #include "content/browser/frame_host/cross_site_transferring_request.h" |
8 #include "content/browser/frame_host/navigation_controller_impl.h" | 8 #include "content/browser/frame_host/navigation_controller_impl.h" |
9 #include "content/browser/frame_host/navigation_entry_impl.h" | 9 #include "content/browser/frame_host/navigation_entry_impl.h" |
10 #include "content/browser/frame_host/navigator.h" | 10 #include "content/browser/frame_host/navigator.h" |
(...skipping 353 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
364 | 364 |
365 // Send an update favicon message and make sure it works. | 365 // Send an update favicon message and make sure it works. |
366 const base::string16 ntp_title = base::ASCIIToUTF16("NTP Title"); | 366 const base::string16 ntp_title = base::ASCIIToUTF16("NTP Title"); |
367 { | 367 { |
368 PluginFaviconMessageObserver observer(contents()); | 368 PluginFaviconMessageObserver observer(contents()); |
369 EXPECT_TRUE(ntp_rvh->OnMessageReceived( | 369 EXPECT_TRUE(ntp_rvh->OnMessageReceived( |
370 ViewHostMsg_UpdateFaviconURL( | 370 ViewHostMsg_UpdateFaviconURL( |
371 rvh()->GetRoutingID(), 0, icons))); | 371 rvh()->GetRoutingID(), 0, icons))); |
372 EXPECT_TRUE(observer.favicon_received()); | 372 EXPECT_TRUE(observer.favicon_received()); |
373 } | 373 } |
374 // Create one more view in the same SiteInstance where dest_rvh2 | 374 // Create one more view in the same SiteInstance where ntp_rvh |
375 // exists so that it doesn't get deleted on navigation to another | 375 // exists so that it doesn't get deleted on navigation to another |
376 // site. | 376 // site. |
377 static_cast<SiteInstanceImpl*>(ntp_rvh->GetSiteInstance())-> | 377 static_cast<SiteInstanceImpl*>(ntp_rvh->GetSiteInstance())-> |
378 increment_active_view_count(); | 378 increment_active_view_count(); |
379 | 379 |
380 | 380 |
381 // Navigate to a cross-site URL. | 381 // Navigate to a cross-site URL. |
382 NavigateActiveAndCommit(kDestUrl); | 382 NavigateActiveAndCommit(kDestUrl); |
383 TestRenderViewHost* dest_rvh = static_cast<TestRenderViewHost*>( | 383 TestRenderViewHost* dest_rvh = static_cast<TestRenderViewHost*>( |
384 contents()->GetRenderViewHost()); | 384 contents()->GetRenderViewHost()); |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
419 EXPECT_FALSE(observer.plugin_crashed()); | 419 EXPECT_FALSE(observer.plugin_crashed()); |
420 } | 420 } |
421 | 421 |
422 // We cannot filter out synchronous IPC messages, because the renderer would | 422 // We cannot filter out synchronous IPC messages, because the renderer would |
423 // be left waiting for a reply. We pick RunBeforeUnloadConfirm as an example | 423 // be left waiting for a reply. We pick RunBeforeUnloadConfirm as an example |
424 // that can run easily within a unit test, and that needs to receive a reply | 424 // that can run easily within a unit test, and that needs to receive a reply |
425 // without showing an actual dialog. | 425 // without showing an actual dialog. |
426 MockRenderProcessHost* ntp_process_host = | 426 MockRenderProcessHost* ntp_process_host = |
427 static_cast<MockRenderProcessHost*>(ntp_rvh->GetProcess()); | 427 static_cast<MockRenderProcessHost*>(ntp_rvh->GetProcess()); |
428 ntp_process_host->sink().ClearMessages(); | 428 ntp_process_host->sink().ClearMessages(); |
| 429 RenderFrameHost* ntp_rfh = ntp_rvh->GetMainFrame(); |
429 const base::string16 msg = base::ASCIIToUTF16("Message"); | 430 const base::string16 msg = base::ASCIIToUTF16("Message"); |
430 bool result = false; | 431 bool result = false; |
431 base::string16 unused; | 432 base::string16 unused; |
432 ViewHostMsg_RunBeforeUnloadConfirm before_unload_msg( | 433 FrameHostMsg_RunBeforeUnloadConfirm before_unload_msg( |
433 rvh()->GetRoutingID(), kChromeURL, msg, false, &result, &unused); | 434 ntp_rfh->GetRoutingID(), kChromeURL, msg, false, &result, &unused); |
434 // Enable pumping for check in BrowserMessageFilter::CheckCanDispatchOnUI. | 435 // Enable pumping for check in BrowserMessageFilter::CheckCanDispatchOnUI. |
435 before_unload_msg.EnableMessagePumping(); | 436 before_unload_msg.EnableMessagePumping(); |
436 EXPECT_TRUE(ntp_rvh->OnMessageReceived(before_unload_msg)); | 437 EXPECT_TRUE(ntp_rfh->OnMessageReceived(before_unload_msg)); |
437 EXPECT_TRUE(ntp_process_host->sink().GetUniqueMessageMatching(IPC_REPLY_ID)); | 438 EXPECT_TRUE(ntp_process_host->sink().GetUniqueMessageMatching(IPC_REPLY_ID)); |
438 | 439 |
439 // Also test RunJavaScriptMessage. | 440 // Also test RunJavaScriptMessage. |
440 ntp_process_host->sink().ClearMessages(); | 441 ntp_process_host->sink().ClearMessages(); |
441 ViewHostMsg_RunJavaScriptMessage js_msg( | 442 FrameHostMsg_RunJavaScriptMessage js_msg( |
442 rvh()->GetRoutingID(), msg, msg, kChromeURL, | 443 ntp_rfh->GetRoutingID(), msg, msg, kChromeURL, |
443 JAVASCRIPT_MESSAGE_TYPE_CONFIRM, &result, &unused); | 444 JAVASCRIPT_MESSAGE_TYPE_CONFIRM, &result, &unused); |
444 js_msg.EnableMessagePumping(); | 445 js_msg.EnableMessagePumping(); |
445 EXPECT_TRUE(ntp_rvh->OnMessageReceived(js_msg)); | 446 EXPECT_TRUE(ntp_rfh->OnMessageReceived(js_msg)); |
446 EXPECT_TRUE(ntp_process_host->sink().GetUniqueMessageMatching(IPC_REPLY_ID)); | 447 EXPECT_TRUE(ntp_process_host->sink().GetUniqueMessageMatching(IPC_REPLY_ID)); |
447 } | 448 } |
448 | 449 |
449 TEST_F(RenderFrameHostManagerTest, WhiteListSwapCompositorFrame) { | 450 TEST_F(RenderFrameHostManagerTest, WhiteListSwapCompositorFrame) { |
450 TestRenderViewHost* swapped_out_rvh = CreateSwappedOutRenderViewHost(); | 451 TestRenderViewHost* swapped_out_rvh = CreateSwappedOutRenderViewHost(); |
451 TestRenderWidgetHostView* swapped_out_rwhv = | 452 TestRenderWidgetHostView* swapped_out_rwhv = |
452 static_cast<TestRenderWidgetHostView*>(swapped_out_rvh->GetView()); | 453 static_cast<TestRenderWidgetHostView*>(swapped_out_rvh->GetView()); |
453 EXPECT_FALSE(swapped_out_rwhv->did_swap_compositor_frame()); | 454 EXPECT_FALSE(swapped_out_rwhv->did_swap_compositor_frame()); |
454 | 455 |
455 MockRenderProcessHost* process_host = | 456 MockRenderProcessHost* process_host = |
(...skipping 1258 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1714 | 1715 |
1715 // Simulate the swap out ack. | 1716 // Simulate the swap out ack. |
1716 rvh1->OnSwappedOut(false); | 1717 rvh1->OnSwappedOut(false); |
1717 | 1718 |
1718 // rvh1 should be swapped out. | 1719 // rvh1 should be swapped out. |
1719 EXPECT_FALSE(rvh_deleted_observer.deleted()); | 1720 EXPECT_FALSE(rvh_deleted_observer.deleted()); |
1720 EXPECT_TRUE(rvh1->IsSwappedOut()); | 1721 EXPECT_TRUE(rvh1->IsSwappedOut()); |
1721 } | 1722 } |
1722 | 1723 |
1723 } // namespace content | 1724 } // namespace content |
OLD | NEW |