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

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 for swapped out RFHs. 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 1407 matching lines...) Expand 10 before | Expand all | Expand 10 after
1418 1418
1419 contents()->SetDelegate(NULL); 1419 contents()->SetDelegate(NULL);
1420 } 1420 }
1421 1421
1422 TEST_F(WebContentsImplTest, TerminateHidesValidationMessage) { 1422 TEST_F(WebContentsImplTest, TerminateHidesValidationMessage) {
1423 FakeValidationMessageDelegate fake_delegate; 1423 FakeValidationMessageDelegate fake_delegate;
1424 contents()->SetDelegate(&fake_delegate); 1424 contents()->SetDelegate(&fake_delegate);
1425 EXPECT_FALSE(fake_delegate.hide_validation_message_was_called()); 1425 EXPECT_FALSE(fake_delegate.hide_validation_message_was_called());
1426 1426
1427 // Crash the renderer. 1427 // Crash the renderer.
1428 contents()->GetMainFrame()->GetRenderViewHost()->OnMessageReceived( 1428 contents()->GetMainFrame()->OnMessageReceived(
1429 ViewHostMsg_RenderProcessGone( 1429 FrameHostMsg_RenderProcessGone(
1430 0, base::TERMINATION_STATUS_PROCESS_CRASHED, -1)); 1430 0, base::TERMINATION_STATUS_PROCESS_CRASHED, -1));
1431 1431
1432 // Confirm HideValidationMessage was called. 1432 // Confirm HideValidationMessage was called.
1433 EXPECT_TRUE(fake_delegate.hide_validation_message_was_called()); 1433 EXPECT_TRUE(fake_delegate.hide_validation_message_was_called());
1434 1434
1435 contents()->SetDelegate(NULL); 1435 contents()->SetDelegate(NULL);
1436 } 1436 }
1437 1437
1438 // Tests that fullscreen is exited throughout the object hierarchy on a renderer 1438 // Tests that fullscreen is exited throughout the object hierarchy on a renderer
1439 // crash. 1439 // crash.
(...skipping 12 matching lines...) Expand all
1452 EXPECT_FALSE(test_rvh()->IsFullscreen()); 1452 EXPECT_FALSE(test_rvh()->IsFullscreen());
1453 EXPECT_FALSE(contents()->IsFullscreenForCurrentTab()); 1453 EXPECT_FALSE(contents()->IsFullscreenForCurrentTab());
1454 EXPECT_FALSE(fake_delegate.IsFullscreenForTabOrPending(contents())); 1454 EXPECT_FALSE(fake_delegate.IsFullscreenForTabOrPending(contents()));
1455 contents()->GetMainFrame()->OnMessageReceived(FrameHostMsg_ToggleFullscreen( 1455 contents()->GetMainFrame()->OnMessageReceived(FrameHostMsg_ToggleFullscreen(
1456 contents()->GetMainFrame()->GetRoutingID(), true)); 1456 contents()->GetMainFrame()->GetRoutingID(), true));
1457 EXPECT_TRUE(test_rvh()->IsFullscreen()); 1457 EXPECT_TRUE(test_rvh()->IsFullscreen());
1458 EXPECT_TRUE(contents()->IsFullscreenForCurrentTab()); 1458 EXPECT_TRUE(contents()->IsFullscreenForCurrentTab());
1459 EXPECT_TRUE(fake_delegate.IsFullscreenForTabOrPending(contents())); 1459 EXPECT_TRUE(fake_delegate.IsFullscreenForTabOrPending(contents()));
1460 1460
1461 // Crash the renderer. 1461 // Crash the renderer.
1462 test_rvh()->OnMessageReceived( 1462 main_rfh()->OnMessageReceived(
1463 ViewHostMsg_RenderProcessGone( 1463 FrameHostMsg_RenderProcessGone(
1464 0, base::TERMINATION_STATUS_PROCESS_CRASHED, -1)); 1464 0, base::TERMINATION_STATUS_PROCESS_CRASHED, -1));
1465 1465
1466 // Confirm fullscreen has exited. 1466 // Confirm fullscreen has exited.
1467 EXPECT_FALSE(test_rvh()->IsFullscreen()); 1467 EXPECT_FALSE(test_rvh()->IsFullscreen());
1468 EXPECT_FALSE(contents()->IsFullscreenForCurrentTab()); 1468 EXPECT_FALSE(contents()->IsFullscreenForCurrentTab());
1469 EXPECT_FALSE(fake_delegate.IsFullscreenForTabOrPending(contents())); 1469 EXPECT_FALSE(fake_delegate.IsFullscreenForTabOrPending(contents()));
1470 1470
1471 contents()->SetDelegate(NULL); 1471 contents()->SetDelegate(NULL);
1472 } 1472 }
1473 1473
(...skipping 384 matching lines...) Expand 10 before | Expand all | Expand 10 after
1858 bool deleted = false; 1858 bool deleted = false;
1859 GURL interstitial_url("http://interstitial"); 1859 GURL interstitial_url("http://interstitial");
1860 TestInterstitialPage* interstitial = 1860 TestInterstitialPage* interstitial =
1861 new TestInterstitialPage(contents(), true, interstitial_url, 1861 new TestInterstitialPage(contents(), true, interstitial_url,
1862 &state, &deleted); 1862 &state, &deleted);
1863 TestInterstitialPageStateGuard state_guard(interstitial); 1863 TestInterstitialPageStateGuard state_guard(interstitial);
1864 interstitial->Show(); 1864 interstitial->Show();
1865 interstitial->TestDidNavigate(2, interstitial_url); 1865 interstitial->TestDidNavigate(2, interstitial_url);
1866 1866
1867 // Crash the renderer 1867 // Crash the renderer
1868 test_rvh()->OnMessageReceived( 1868 main_rfh()->OnMessageReceived(
1869 ViewHostMsg_RenderProcessGone( 1869 FrameHostMsg_RenderProcessGone(
1870 0, base::TERMINATION_STATUS_PROCESS_CRASHED, -1)); 1870 0, base::TERMINATION_STATUS_PROCESS_CRASHED, -1));
1871 1871
1872 // While the interstitial is showing, go back. 1872 // While the interstitial is showing, go back.
1873 controller().GoBack(); 1873 controller().GoBack();
1874 contents()->GetMainFrame()->SendNavigate(1, url1); 1874 contents()->GetMainFrame()->SendNavigate(1, url1);
1875 1875
1876 // Make sure we are back to the original page and that the interstitial is 1876 // Make sure we are back to the original page and that the interstitial is
1877 // gone. 1877 // gone.
1878 EXPECT_EQ(TestInterstitialPage::CANCELED, state); 1878 EXPECT_EQ(TestInterstitialPage::CANCELED, state);
1879 NavigationEntry* entry = controller().GetVisibleEntry(); 1879 NavigationEntry* entry = controller().GetVisibleEntry();
(...skipping 17 matching lines...) Expand all
1897 TestInterstitialPage::INVALID; 1897 TestInterstitialPage::INVALID;
1898 bool deleted = false; 1898 bool deleted = false;
1899 GURL interstitial_url("http://interstitial"); 1899 GURL interstitial_url("http://interstitial");
1900 TestInterstitialPage* interstitial = 1900 TestInterstitialPage* interstitial =
1901 new TestInterstitialPage(contents(), true, interstitial_url, 1901 new TestInterstitialPage(contents(), true, interstitial_url,
1902 &state, &deleted); 1902 &state, &deleted);
1903 TestInterstitialPageStateGuard state_guard(interstitial); 1903 TestInterstitialPageStateGuard state_guard(interstitial);
1904 interstitial->Show(); 1904 interstitial->Show();
1905 1905
1906 // Crash the renderer 1906 // Crash the renderer
1907 test_rvh()->OnMessageReceived( 1907 main_rfh()->OnMessageReceived(
1908 ViewHostMsg_RenderProcessGone( 1908 FrameHostMsg_RenderProcessGone(
1909 0, base::TERMINATION_STATUS_PROCESS_CRASHED, -1)); 1909 0, base::TERMINATION_STATUS_PROCESS_CRASHED, -1));
1910 1910
1911 interstitial->TestDidNavigate(2, interstitial_url); 1911 interstitial->TestDidNavigate(2, interstitial_url);
1912 } 1912 }
1913 1913
1914 // Test navigating to a page that shows an interstitial, then close the 1914 // Test navigating to a page that shows an interstitial, then close the
1915 // contents. 1915 // contents.
1916 TEST_F(WebContentsImplTest, ShowInterstitialThenCloseTab) { 1916 TEST_F(WebContentsImplTest, ShowInterstitialThenCloseTab) {
1917 // Show interstitial. 1917 // Show interstitial.
1918 TestInterstitialPage::InterstitialState state = 1918 TestInterstitialPage::InterstitialState state =
(...skipping 30 matching lines...) Expand all
1949 RenderViewHostImpl* rvh = static_cast<RenderViewHostImpl*>( 1949 RenderViewHostImpl* rvh = static_cast<RenderViewHostImpl*>(
1950 interstitial->GetMainFrame()->GetRenderViewHost()); 1950 interstitial->GetMainFrame()->GetRenderViewHost());
1951 1951
1952 // Now close the contents. 1952 // Now close the contents.
1953 DeleteContents(); 1953 DeleteContents();
1954 EXPECT_EQ(TestInterstitialPage::CANCELED, state); 1954 EXPECT_EQ(TestInterstitialPage::CANCELED, state);
1955 1955
1956 // Before the interstitial has a chance to process its shutdown task, 1956 // Before the interstitial has a chance to process its shutdown task,
1957 // simulate quitting the browser. This goes through all processes and 1957 // simulate quitting the browser. This goes through all processes and
1958 // tells them to destruct. 1958 // tells them to destruct.
1959 rvh->OnMessageReceived( 1959 rvh->GetMainFrame()->OnMessageReceived(
1960 ViewHostMsg_RenderProcessGone(0, 0, 0)); 1960 FrameHostMsg_RenderProcessGone(0, 0, 0));
1961 1961
1962 RunAllPendingInMessageLoop(); 1962 RunAllPendingInMessageLoop();
1963 EXPECT_TRUE(deleted); 1963 EXPECT_TRUE(deleted);
1964 } 1964 }
1965 1965
1966 // Test that after Proceed is called and an interstitial is still shown, no more 1966 // Test that after Proceed is called and an interstitial is still shown, no more
1967 // commands get executed. 1967 // commands get executed.
1968 TEST_F(WebContentsImplTest, ShowInterstitialProceedMultipleCommands) { 1968 TEST_F(WebContentsImplTest, ShowInterstitialProceedMultipleCommands) {
1969 // Navigate to a page so we have a navigation entry in the controller. 1969 // Navigate to a page so we have a navigation entry in the controller.
1970 GURL url1("http://www.google.com"); 1970 GURL url1("http://www.google.com");
(...skipping 1052 matching lines...) Expand 10 before | Expand all | Expand 10 after
3023 3023
3024 // Destroy the remote player. No power save blockers should remain. 3024 // Destroy the remote player. No power save blockers should remain.
3025 rfh->OnMessageReceived( 3025 rfh->OnMessageReceived(
3026 FrameHostMsg_MediaPausedNotification(0, kPlayerRemoteId)); 3026 FrameHostMsg_MediaPausedNotification(0, kPlayerRemoteId));
3027 EXPECT_FALSE(contents()->has_video_power_save_blocker_for_testing()); 3027 EXPECT_FALSE(contents()->has_video_power_save_blocker_for_testing());
3028 EXPECT_FALSE(contents()->has_audio_power_save_blocker_for_testing()); 3028 EXPECT_FALSE(contents()->has_audio_power_save_blocker_for_testing());
3029 } 3029 }
3030 #endif 3030 #endif
3031 3031
3032 } // namespace content 3032 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698