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/command_line.h" | 5 #include "base/command_line.h" |
6 #include "base/files/file_path.h" | 6 #include "base/files/file_path.h" |
7 #include "base/strings/utf_string_conversions.h" | 7 #include "base/strings/utf_string_conversions.h" |
8 #include "base/test/histogram_tester.h" | 8 #include "base/test/histogram_tester.h" |
9 #include "base/time/time.h" | 9 #include "base/time/time.h" |
10 #include "content/browser/frame_host/cross_site_transferring_request.h" | 10 #include "content/browser/frame_host/cross_site_transferring_request.h" |
(...skipping 1018 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1029 | 1029 |
1030 // No cross-process transition happens because we are already in the right | 1030 // No cross-process transition happens because we are already in the right |
1031 // SiteInstance. We should grant bindings immediately. | 1031 // SiteInstance. We should grant bindings immediately. |
1032 EXPECT_EQ(host2, manager2->current_frame_host()); | 1032 EXPECT_EQ(host2, manager2->current_frame_host()); |
1033 EXPECT_TRUE( | 1033 EXPECT_TRUE( |
1034 host2->render_view_host()->GetEnabledBindings() & BINDINGS_POLICY_WEB_UI); | 1034 host2->render_view_host()->GetEnabledBindings() & BINDINGS_POLICY_WEB_UI); |
1035 | 1035 |
1036 manager2->DidNavigateFrame(host2); | 1036 manager2->DidNavigateFrame(host2); |
1037 } | 1037 } |
1038 | 1038 |
| 1039 // Test that WebUI can be navigated to in single-process mode. |
| 1040 TEST_F(RenderFrameHostManagerTest, |
| 1041 CanNavigateBetweenNormalPagesAndWebUIInSingleProcess) { |
| 1042 const GURL kNormalUrl1("http://chromium.org"); |
| 1043 const GURL kNormalUrl2("http://example.com"); |
| 1044 const GURL kWebUIUrl("chrome://foo"); |
| 1045 |
| 1046 // We both set flag on RenderProcesHost and append the switch due to the fact |
| 1047 // that some code checks the switch directly instead of relying |
| 1048 // on RenderProcessHost |
| 1049 RenderProcessHost::SetRunRendererInProcess(true); |
| 1050 CommandLine::ForCurrentProcess()->AppendSwitch(switches::kSingleProcess); |
| 1051 set_should_create_webui(true); |
| 1052 |
| 1053 RenderFrameHostManager* manager = static_cast<TestWebContents*>( |
| 1054 web_contents())->GetRenderManagerForTesting(); |
| 1055 |
| 1056 NavigateAndCommit(kNormalUrl1); |
| 1057 EXPECT_EQ(kNormalUrl1, |
| 1058 manager->current_frame_host()->GetSiteInstance()->GetSiteURL()); |
| 1059 EXPECT_FALSE(manager->web_ui()); |
| 1060 NavigateAndCommit(kWebUIUrl); |
| 1061 EXPECT_EQ(kWebUIUrl, |
| 1062 manager->current_frame_host()->GetSiteInstance()->GetSiteURL()); |
| 1063 EXPECT_TRUE(manager->web_ui()); |
| 1064 NavigateAndCommit(kNormalUrl2); |
| 1065 EXPECT_EQ(kNormalUrl2, |
| 1066 manager->current_frame_host()->GetSiteInstance()->GetSiteURL()); |
| 1067 EXPECT_FALSE(manager->web_ui()); |
| 1068 } |
| 1069 |
1039 // Tests that we don't end up in an inconsistent state if a page does a back and | 1070 // Tests that we don't end up in an inconsistent state if a page does a back and |
1040 // then reload. http://crbug.com/51680 | 1071 // then reload. http://crbug.com/51680 |
1041 TEST_F(RenderFrameHostManagerTest, PageDoesBackAndReload) { | 1072 TEST_F(RenderFrameHostManagerTest, PageDoesBackAndReload) { |
1042 const GURL kUrl1("http://www.google.com/"); | 1073 const GURL kUrl1("http://www.google.com/"); |
1043 const GURL kUrl2("http://www.evil-site.com/"); | 1074 const GURL kUrl2("http://www.evil-site.com/"); |
1044 | 1075 |
1045 // Navigate to a safe site, then an evil site. | 1076 // Navigate to a safe site, then an evil site. |
1046 // This will switch RenderFrameHosts. We cannot assert that the first and | 1077 // This will switch RenderFrameHosts. We cannot assert that the first and |
1047 // second RFHs are different, though, because the first one may be promptly | 1078 // second RFHs are different, though, because the first one may be promptly |
1048 // deleted. | 1079 // deleted. |
(...skipping 926 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1975 FrameMsg_Navigate_Type::RELOAD_IGNORING_CACHE); | 2006 FrameMsg_Navigate_Type::RELOAD_IGNORING_CACHE); |
1976 contents()->GetMainFrame()->SendBeginNavigationWithURL(kUrl); | 2007 contents()->GetMainFrame()->SendBeginNavigationWithURL(kUrl); |
1977 // A NavigationRequest should have been generated. | 2008 // A NavigationRequest should have been generated. |
1978 main_request = GetNavigationRequestForRenderFrameManager(render_manager); | 2009 main_request = GetNavigationRequestForRenderFrameManager(render_manager); |
1979 ASSERT_TRUE(main_request != NULL); | 2010 ASSERT_TRUE(main_request != NULL); |
1980 EXPECT_EQ(FrameMsg_Navigate_Type::RELOAD_IGNORING_CACHE, | 2011 EXPECT_EQ(FrameMsg_Navigate_Type::RELOAD_IGNORING_CACHE, |
1981 main_request->common_params().navigation_type); | 2012 main_request->common_params().navigation_type); |
1982 } | 2013 } |
1983 | 2014 |
1984 } // namespace content | 2015 } // namespace content |
OLD | NEW |