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

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

Issue 894843003: Move the RenderProcessGone IPC from RenderViewHost to RenderFrameHost (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix conflict with dalecurtis' CL Created 5 years, 10 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
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/command_line.h" 5 #include "base/command_line.h"
6 #include "base/logging.h" 6 #include "base/logging.h"
7 #include "base/strings/utf_string_conversions.h" 7 #include "base/strings/utf_string_conversions.h"
8 #include "content/browser/frame_host/cross_site_transferring_request.h" 8 #include "content/browser/frame_host/cross_site_transferring_request.h"
9 #include "content/browser/frame_host/interstitial_page_impl.h" 9 #include "content/browser/frame_host/interstitial_page_impl.h"
10 #include "content/browser/frame_host/navigation_entry_impl.h" 10 #include "content/browser/frame_host/navigation_entry_impl.h"
(...skipping 1408 matching lines...) Expand 10 before | Expand all | Expand 10 after
1419 1419
1420 contents()->SetDelegate(NULL); 1420 contents()->SetDelegate(NULL);
1421 } 1421 }
1422 1422
1423 TEST_F(WebContentsImplTest, TerminateHidesValidationMessage) { 1423 TEST_F(WebContentsImplTest, TerminateHidesValidationMessage) {
1424 FakeValidationMessageDelegate fake_delegate; 1424 FakeValidationMessageDelegate fake_delegate;
1425 contents()->SetDelegate(&fake_delegate); 1425 contents()->SetDelegate(&fake_delegate);
1426 EXPECT_FALSE(fake_delegate.hide_validation_message_was_called()); 1426 EXPECT_FALSE(fake_delegate.hide_validation_message_was_called());
1427 1427
1428 // Crash the renderer. 1428 // Crash the renderer.
1429 contents()->GetMainFrame()->GetRenderViewHost()->OnMessageReceived( 1429 contents()->GetMainFrame()->OnMessageReceived(
1430 ViewHostMsg_RenderProcessGone( 1430 FrameHostMsg_RenderProcessGone(
1431 0, base::TERMINATION_STATUS_PROCESS_CRASHED, -1)); 1431 0, base::TERMINATION_STATUS_PROCESS_CRASHED, -1));
1432 1432
1433 // Confirm HideValidationMessage was called. 1433 // Confirm HideValidationMessage was called.
1434 EXPECT_TRUE(fake_delegate.hide_validation_message_was_called()); 1434 EXPECT_TRUE(fake_delegate.hide_validation_message_was_called());
1435 1435
1436 contents()->SetDelegate(NULL); 1436 contents()->SetDelegate(NULL);
1437 } 1437 }
1438 1438
1439 // Tests that fullscreen is exited throughout the object hierarchy on a renderer 1439 // Tests that fullscreen is exited throughout the object hierarchy on a renderer
1440 // crash. 1440 // crash.
(...skipping 12 matching lines...) Expand all
1453 EXPECT_FALSE(test_rvh()->IsFullscreen()); 1453 EXPECT_FALSE(test_rvh()->IsFullscreen());
1454 EXPECT_FALSE(contents()->IsFullscreenForCurrentTab()); 1454 EXPECT_FALSE(contents()->IsFullscreenForCurrentTab());
1455 EXPECT_FALSE(fake_delegate.IsFullscreenForTabOrPending(contents())); 1455 EXPECT_FALSE(fake_delegate.IsFullscreenForTabOrPending(contents()));
1456 contents()->GetMainFrame()->OnMessageReceived(FrameHostMsg_ToggleFullscreen( 1456 contents()->GetMainFrame()->OnMessageReceived(FrameHostMsg_ToggleFullscreen(
1457 contents()->GetMainFrame()->GetRoutingID(), true)); 1457 contents()->GetMainFrame()->GetRoutingID(), true));
1458 EXPECT_TRUE(test_rvh()->IsFullscreen()); 1458 EXPECT_TRUE(test_rvh()->IsFullscreen());
1459 EXPECT_TRUE(contents()->IsFullscreenForCurrentTab()); 1459 EXPECT_TRUE(contents()->IsFullscreenForCurrentTab());
1460 EXPECT_TRUE(fake_delegate.IsFullscreenForTabOrPending(contents())); 1460 EXPECT_TRUE(fake_delegate.IsFullscreenForTabOrPending(contents()));
1461 1461
1462 // Crash the renderer. 1462 // Crash the renderer.
1463 test_rvh()->OnMessageReceived( 1463 main_rfh()->OnMessageReceived(
1464 ViewHostMsg_RenderProcessGone( 1464 FrameHostMsg_RenderProcessGone(
1465 0, base::TERMINATION_STATUS_PROCESS_CRASHED, -1)); 1465 0, base::TERMINATION_STATUS_PROCESS_CRASHED, -1));
1466 1466
1467 // Confirm fullscreen has exited. 1467 // Confirm fullscreen has exited.
1468 EXPECT_FALSE(test_rvh()->IsFullscreen()); 1468 EXPECT_FALSE(test_rvh()->IsFullscreen());
1469 EXPECT_FALSE(contents()->IsFullscreenForCurrentTab()); 1469 EXPECT_FALSE(contents()->IsFullscreenForCurrentTab());
1470 EXPECT_FALSE(fake_delegate.IsFullscreenForTabOrPending(contents())); 1470 EXPECT_FALSE(fake_delegate.IsFullscreenForTabOrPending(contents()));
1471 1471
1472 contents()->SetDelegate(NULL); 1472 contents()->SetDelegate(NULL);
1473 } 1473 }
1474 1474
(...skipping 384 matching lines...) Expand 10 before | Expand all | Expand 10 after
1859 bool deleted = false; 1859 bool deleted = false;
1860 GURL interstitial_url("http://interstitial"); 1860 GURL interstitial_url("http://interstitial");
1861 TestInterstitialPage* interstitial = 1861 TestInterstitialPage* interstitial =
1862 new TestInterstitialPage(contents(), true, interstitial_url, 1862 new TestInterstitialPage(contents(), true, interstitial_url,
1863 &state, &deleted); 1863 &state, &deleted);
1864 TestInterstitialPageStateGuard state_guard(interstitial); 1864 TestInterstitialPageStateGuard state_guard(interstitial);
1865 interstitial->Show(); 1865 interstitial->Show();
1866 interstitial->TestDidNavigate(2, interstitial_url); 1866 interstitial->TestDidNavigate(2, interstitial_url);
1867 1867
1868 // Crash the renderer 1868 // Crash the renderer
1869 test_rvh()->OnMessageReceived( 1869 main_rfh()->OnMessageReceived(
1870 ViewHostMsg_RenderProcessGone( 1870 FrameHostMsg_RenderProcessGone(
1871 0, base::TERMINATION_STATUS_PROCESS_CRASHED, -1)); 1871 0, base::TERMINATION_STATUS_PROCESS_CRASHED, -1));
1872 1872
1873 // While the interstitial is showing, go back. 1873 // While the interstitial is showing, go back.
1874 controller().GoBack(); 1874 controller().GoBack();
1875 contents()->GetMainFrame()->SendNavigate(1, url1); 1875 contents()->GetMainFrame()->SendNavigate(1, url1);
1876 1876
1877 // Make sure we are back to the original page and that the interstitial is 1877 // Make sure we are back to the original page and that the interstitial is
1878 // gone. 1878 // gone.
1879 EXPECT_EQ(TestInterstitialPage::CANCELED, state); 1879 EXPECT_EQ(TestInterstitialPage::CANCELED, state);
1880 NavigationEntry* entry = controller().GetVisibleEntry(); 1880 NavigationEntry* entry = controller().GetVisibleEntry();
(...skipping 17 matching lines...) Expand all
1898 TestInterstitialPage::INVALID; 1898 TestInterstitialPage::INVALID;
1899 bool deleted = false; 1899 bool deleted = false;
1900 GURL interstitial_url("http://interstitial"); 1900 GURL interstitial_url("http://interstitial");
1901 TestInterstitialPage* interstitial = 1901 TestInterstitialPage* interstitial =
1902 new TestInterstitialPage(contents(), true, interstitial_url, 1902 new TestInterstitialPage(contents(), true, interstitial_url,
1903 &state, &deleted); 1903 &state, &deleted);
1904 TestInterstitialPageStateGuard state_guard(interstitial); 1904 TestInterstitialPageStateGuard state_guard(interstitial);
1905 interstitial->Show(); 1905 interstitial->Show();
1906 1906
1907 // Crash the renderer 1907 // Crash the renderer
1908 test_rvh()->OnMessageReceived( 1908 main_rfh()->OnMessageReceived(
1909 ViewHostMsg_RenderProcessGone( 1909 FrameHostMsg_RenderProcessGone(
1910 0, base::TERMINATION_STATUS_PROCESS_CRASHED, -1)); 1910 0, base::TERMINATION_STATUS_PROCESS_CRASHED, -1));
1911 1911
1912 interstitial->TestDidNavigate(2, interstitial_url); 1912 interstitial->TestDidNavigate(2, interstitial_url);
1913 } 1913 }
1914 1914
1915 // Test navigating to a page that shows an interstitial, then close the 1915 // Test navigating to a page that shows an interstitial, then close the
1916 // contents. 1916 // contents.
1917 TEST_F(WebContentsImplTest, ShowInterstitialThenCloseTab) { 1917 TEST_F(WebContentsImplTest, ShowInterstitialThenCloseTab) {
1918 // Show interstitial. 1918 // Show interstitial.
1919 TestInterstitialPage::InterstitialState state = 1919 TestInterstitialPage::InterstitialState state =
(...skipping 30 matching lines...) Expand all
1950 RenderViewHostImpl* rvh = static_cast<RenderViewHostImpl*>( 1950 RenderViewHostImpl* rvh = static_cast<RenderViewHostImpl*>(
1951 interstitial->GetMainFrame()->GetRenderViewHost()); 1951 interstitial->GetMainFrame()->GetRenderViewHost());
1952 1952
1953 // Now close the contents. 1953 // Now close the contents.
1954 DeleteContents(); 1954 DeleteContents();
1955 EXPECT_EQ(TestInterstitialPage::CANCELED, state); 1955 EXPECT_EQ(TestInterstitialPage::CANCELED, state);
1956 1956
1957 // Before the interstitial has a chance to process its shutdown task, 1957 // Before the interstitial has a chance to process its shutdown task,
1958 // simulate quitting the browser. This goes through all processes and 1958 // simulate quitting the browser. This goes through all processes and
1959 // tells them to destruct. 1959 // tells them to destruct.
1960 rvh->OnMessageReceived( 1960 rvh->GetMainFrame()->OnMessageReceived(
1961 ViewHostMsg_RenderProcessGone(0, 0, 0)); 1961 FrameHostMsg_RenderProcessGone(0, 0, 0));
1962 1962
1963 RunAllPendingInMessageLoop(); 1963 RunAllPendingInMessageLoop();
1964 EXPECT_TRUE(deleted); 1964 EXPECT_TRUE(deleted);
1965 } 1965 }
1966 1966
1967 // Test that after Proceed is called and an interstitial is still shown, no more 1967 // Test that after Proceed is called and an interstitial is still shown, no more
1968 // commands get executed. 1968 // commands get executed.
1969 TEST_F(WebContentsImplTest, ShowInterstitialProceedMultipleCommands) { 1969 TEST_F(WebContentsImplTest, ShowInterstitialProceedMultipleCommands) {
1970 // Navigate to a page so we have a navigation entry in the controller. 1970 // Navigate to a page so we have a navigation entry in the controller.
1971 GURL url1("http://www.google.com"); 1971 GURL url1("http://www.google.com");
(...skipping 1009 matching lines...) Expand 10 before | Expand all | Expand 10 after
2981 // Start a player with both audio and video. A video power save blocker 2981 // Start a player with both audio and video. A video power save blocker
2982 // should be created. If audio stream monitoring is available, an audio power 2982 // should be created. If audio stream monitoring is available, an audio power
2983 // save blocker should be created too. 2983 // save blocker should be created too.
2984 rfh->OnMessageReceived(FrameHostMsg_MediaPlayingNotification( 2984 rfh->OnMessageReceived(FrameHostMsg_MediaPlayingNotification(
2985 0, kPlayerAudioVideoId, true, true, false)); 2985 0, kPlayerAudioVideoId, true, true, false));
2986 EXPECT_TRUE(contents()->has_video_power_save_blocker_for_testing()); 2986 EXPECT_TRUE(contents()->has_video_power_save_blocker_for_testing());
2987 EXPECT_EQ(contents()->has_audio_power_save_blocker_for_testing(), 2987 EXPECT_EQ(contents()->has_audio_power_save_blocker_for_testing(),
2988 !AudioStreamMonitor::monitoring_available()); 2988 !AudioStreamMonitor::monitoring_available());
2989 2989
2990 // Crash the renderer. 2990 // Crash the renderer.
2991 contents()->GetMainFrame()->GetRenderViewHost()->OnMessageReceived( 2991 contents()->GetMainFrame()->OnMessageReceived(
2992 ViewHostMsg_RenderProcessGone( 2992 FrameHostMsg_RenderProcessGone(
2993 0, base::TERMINATION_STATUS_PROCESS_CRASHED, -1)); 2993 0, base::TERMINATION_STATUS_PROCESS_CRASHED, -1));
2994 2994
2995 // Verify that all the power save blockers have been released. 2995 // Verify that all the power save blockers have been released.
2996 EXPECT_FALSE(contents()->has_video_power_save_blocker_for_testing()); 2996 EXPECT_FALSE(contents()->has_video_power_save_blocker_for_testing());
2997 EXPECT_FALSE(contents()->has_audio_power_save_blocker_for_testing()); 2997 EXPECT_FALSE(contents()->has_audio_power_save_blocker_for_testing());
2998 } 2998 }
2999 #endif 2999 #endif
3000 3000
3001 // Test that sudden termination status is properly tracked for a frame. 3001 // Test that sudden termination status is properly tracked for a frame.
3002 TEST_F(WebContentsImplTest, SuddenTerminationForFrame) { 3002 TEST_F(WebContentsImplTest, SuddenTerminationForFrame) {
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
3038 frame->SendBeforeUnloadHandlersPresent(false); 3038 frame->SendBeforeUnloadHandlersPresent(false);
3039 EXPECT_FALSE(frame->SuddenTerminationAllowed()); 3039 EXPECT_FALSE(frame->SuddenTerminationAllowed());
3040 frame->SendBeforeUnloadHandlersPresent(true); 3040 frame->SendBeforeUnloadHandlersPresent(true);
3041 frame->SendUnloadHandlersPresent(false); 3041 frame->SendUnloadHandlersPresent(false);
3042 EXPECT_FALSE(frame->SuddenTerminationAllowed()); 3042 EXPECT_FALSE(frame->SuddenTerminationAllowed());
3043 frame->SendBeforeUnloadHandlersPresent(false); 3043 frame->SendBeforeUnloadHandlersPresent(false);
3044 EXPECT_TRUE(frame->SuddenTerminationAllowed()); 3044 EXPECT_TRUE(frame->SuddenTerminationAllowed());
3045 } 3045 }
3046 3046
3047 } // namespace content 3047 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/renderer_host/render_widget_host_impl.cc ('k') | content/common/frame_messages.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698