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

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

Issue 1418853003: Remove RFHM::GetNavigatingWebUI() and RFHM::web_ui(). (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@webui-refactor
Patch Set: Remove RFHM::web_ui(). Created 5 years, 1 month 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 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/compositor/test/no_transport_image_transport_factory.h " 10 #include "content/browser/compositor/test/no_transport_image_transport_factory.h "
(...skipping 1078 matching lines...) Expand 10 before | Expand all | Expand 10 after
1089 TEST_F(RenderFrameHostManagerTest, WebUI) { 1089 TEST_F(RenderFrameHostManagerTest, WebUI) {
1090 set_should_create_webui(true); 1090 set_should_create_webui(true);
1091 SiteInstance* instance = SiteInstance::Create(browser_context()); 1091 SiteInstance* instance = SiteInstance::Create(browser_context());
1092 1092
1093 scoped_ptr<TestWebContents> web_contents( 1093 scoped_ptr<TestWebContents> web_contents(
1094 TestWebContents::Create(browser_context(), instance)); 1094 TestWebContents::Create(browser_context(), instance));
1095 RenderFrameHostManager* manager = web_contents->GetRenderManagerForTesting(); 1095 RenderFrameHostManager* manager = web_contents->GetRenderManagerForTesting();
1096 RenderFrameHostImpl* initial_rfh = manager->current_frame_host(); 1096 RenderFrameHostImpl* initial_rfh = manager->current_frame_host();
1097 1097
1098 EXPECT_FALSE(manager->current_host()->IsRenderViewLive()); 1098 EXPECT_FALSE(manager->current_host()->IsRenderViewLive());
1099 EXPECT_FALSE(manager->web_ui()); 1099 EXPECT_FALSE(manager->current_frame_host()->web_ui());
1100 EXPECT_TRUE(initial_rfh); 1100 EXPECT_TRUE(initial_rfh);
1101 1101
1102 const GURL kUrl("chrome://foo"); 1102 const GURL kUrl("chrome://foo");
1103 NavigationEntryImpl entry(NULL /* instance */, -1 /* page_id */, kUrl, 1103 NavigationEntryImpl entry(NULL /* instance */, -1 /* page_id */, kUrl,
1104 Referrer(), base::string16() /* title */, 1104 Referrer(), base::string16() /* title */,
1105 ui::PAGE_TRANSITION_TYPED, 1105 ui::PAGE_TRANSITION_TYPED,
1106 false /* is_renderer_init */); 1106 false /* is_renderer_init */);
1107 RenderFrameHostImpl* host = NavigateToEntry(manager, entry); 1107 RenderFrameHostImpl* host = NavigateToEntry(manager, entry);
1108 1108
1109 // We commit the pending RenderFrameHost immediately because the previous 1109 // We commit the pending RenderFrameHost immediately because the previous
1110 // RenderFrameHost was not live. We test a case where it is live in 1110 // RenderFrameHost was not live. We test a case where it is live in
1111 // WebUIInNewTab. 1111 // WebUIInNewTab.
1112 EXPECT_TRUE(host); 1112 EXPECT_TRUE(host);
1113 EXPECT_NE(initial_rfh, host); 1113 EXPECT_NE(initial_rfh, host);
1114 EXPECT_EQ(host, manager->current_frame_host()); 1114 EXPECT_EQ(host, manager->current_frame_host());
1115 EXPECT_FALSE(GetPendingFrameHost(manager)); 1115 EXPECT_FALSE(GetPendingFrameHost(manager));
1116 1116
1117 // It's important that the SiteInstance get set on the Web UI page as soon 1117 // It's important that the SiteInstance get set on the Web UI page as soon
1118 // as the navigation starts, rather than lazily after it commits, so we don't 1118 // as the navigation starts, rather than lazily after it commits, so we don't
1119 // try to re-use the SiteInstance/process for non Web UI things that may 1119 // try to re-use the SiteInstance/process for non Web UI things that may
1120 // get loaded in between. 1120 // get loaded in between.
1121 EXPECT_TRUE(host->GetSiteInstance()->HasSite()); 1121 EXPECT_TRUE(host->GetSiteInstance()->HasSite());
1122 EXPECT_EQ(kUrl, host->GetSiteInstance()->GetSiteURL()); 1122 EXPECT_EQ(kUrl, host->GetSiteInstance()->GetSiteURL());
1123 1123
1124 // The Web UI is committed immediately because the RenderViewHost has not been 1124 // The Web UI is committed immediately because the RenderViewHost has not been
1125 // used yet. UpdateStateForNavigate() took the short cut path. 1125 // used yet. UpdateStateForNavigate() took the short cut path.
1126 EXPECT_FALSE(manager->GetNavigatingWebUI()); 1126 EXPECT_TRUE(manager->current_frame_host()->web_ui());
1127 EXPECT_TRUE(manager->web_ui());
1128 1127
1129 // Commit. 1128 // Commit.
1130 manager->DidNavigateFrame(host, true); 1129 manager->DidNavigateFrame(host, true);
1131 EXPECT_TRUE( 1130 EXPECT_TRUE(
1132 host->render_view_host()->GetEnabledBindings() & BINDINGS_POLICY_WEB_UI); 1131 host->render_view_host()->GetEnabledBindings() & BINDINGS_POLICY_WEB_UI);
1133 } 1132 }
1134 1133
1135 // Tests that we can open a WebUI link in a new tab from a WebUI page and still 1134 // Tests that we can open a WebUI link in a new tab from a WebUI page and still
1136 // grant the correct bindings. http://crbug.com/189101. 1135 // grant the correct bindings. http://crbug.com/189101.
1137 TEST_F(RenderFrameHostManagerTest, WebUIInNewTab) { 1136 TEST_F(RenderFrameHostManagerTest, WebUIInNewTab) {
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
1186 const GURL kUrl2("chrome://foo/bar"); 1185 const GURL kUrl2("chrome://foo/bar");
1187 NavigationEntryImpl entry2(NULL /* instance */, -1 /* page_id */, kUrl2, 1186 NavigationEntryImpl entry2(NULL /* instance */, -1 /* page_id */, kUrl2,
1188 Referrer(), base::string16() /* title */, 1187 Referrer(), base::string16() /* title */,
1189 ui::PAGE_TRANSITION_LINK, 1188 ui::PAGE_TRANSITION_LINK,
1190 true /* is_renderer_init */); 1189 true /* is_renderer_init */);
1191 RenderFrameHostImpl* host2 = NavigateToEntry(manager2, entry2); 1190 RenderFrameHostImpl* host2 = NavigateToEntry(manager2, entry2);
1192 1191
1193 // No cross-process transition happens because we are already in the right 1192 // No cross-process transition happens because we are already in the right
1194 // SiteInstance. We should grant bindings immediately. 1193 // SiteInstance. We should grant bindings immediately.
1195 EXPECT_EQ(host2, manager2->current_frame_host()); 1194 EXPECT_EQ(host2, manager2->current_frame_host());
1196 EXPECT_TRUE(manager2->GetNavigatingWebUI()); 1195 EXPECT_TRUE(host2->web_ui());
1197 EXPECT_TRUE( 1196 EXPECT_TRUE(
1198 host2->render_view_host()->GetEnabledBindings() & BINDINGS_POLICY_WEB_UI); 1197 host2->render_view_host()->GetEnabledBindings() & BINDINGS_POLICY_WEB_UI);
1199 1198
1200 manager2->DidNavigateFrame(host2, true); 1199 manager2->DidNavigateFrame(host2, true);
1201 } 1200 }
1202 1201
1203 // Tests that a WebUI is correctly reused between chrome:// pages. 1202 // Tests that a WebUI is correctly reused between chrome:// pages.
1204 TEST_F(RenderFrameHostManagerTest, WebUIWasReused) { 1203 TEST_F(RenderFrameHostManagerTest, WebUIWasReused) {
1205 set_should_create_webui(true); 1204 set_should_create_webui(true);
1206 1205
1207 // Navigate to a WebUI page. 1206 // Navigate to a WebUI page.
1208 const GURL kUrl1("chrome://foo"); 1207 const GURL kUrl1("chrome://foo");
1209 contents()->NavigateAndCommit(kUrl1); 1208 contents()->NavigateAndCommit(kUrl1);
1210 RenderFrameHostManager* manager = 1209 WebUIImpl* web_ui = main_test_rfh()->web_ui();
1211 main_test_rfh()->frame_tree_node()->render_manager();
1212 WebUIImpl* web_ui = manager->web_ui();
1213 EXPECT_TRUE(web_ui); 1210 EXPECT_TRUE(web_ui);
1214 1211
1215 // Navigate to another WebUI page which should be same-site and keep the 1212 // Navigate to another WebUI page which should be same-site and keep the
1216 // current WebUI. 1213 // current WebUI.
1217 const GURL kUrl2("chrome://foo/bar"); 1214 const GURL kUrl2("chrome://foo/bar");
1218 contents()->NavigateAndCommit(kUrl2); 1215 contents()->NavigateAndCommit(kUrl2);
1219 EXPECT_EQ(web_ui, manager->web_ui()); 1216 EXPECT_EQ(web_ui, main_test_rfh()->web_ui());
1220 } 1217 }
1221 1218
1222 // Tests that a WebUI is correctly cleaned up when navigating from a chrome:// 1219 // Tests that a WebUI is correctly cleaned up when navigating from a chrome://
1223 // page to a non-chrome:// page. 1220 // page to a non-chrome:// page.
1224 TEST_F(RenderFrameHostManagerTest, WebUIWasCleared) { 1221 TEST_F(RenderFrameHostManagerTest, WebUIWasCleared) {
1225 set_should_create_webui(true); 1222 set_should_create_webui(true);
1226 1223
1227 // Navigate to a WebUI page. 1224 // Navigate to a WebUI page.
1228 const GURL kUrl1("chrome://foo"); 1225 const GURL kUrl1("chrome://foo");
1229 contents()->NavigateAndCommit(kUrl1); 1226 contents()->NavigateAndCommit(kUrl1);
1230 EXPECT_TRUE(main_test_rfh()->frame_tree_node()->render_manager()->web_ui()); 1227 EXPECT_TRUE(main_test_rfh()->web_ui());
1231 1228
1232 // Navigate to a non-WebUI page. 1229 // Navigate to a non-WebUI page.
1233 const GURL kUrl2("http://www.google.com"); 1230 const GURL kUrl2("http://www.google.com");
1234 contents()->NavigateAndCommit(kUrl2); 1231 contents()->NavigateAndCommit(kUrl2);
1235 EXPECT_FALSE(main_test_rfh()->frame_tree_node()->render_manager()->web_ui()); 1232 EXPECT_FALSE(main_test_rfh()->web_ui());
1236 } 1233 }
1237 1234
1238 // Tests that we don't end up in an inconsistent state if a page does a back and 1235 // Tests that we don't end up in an inconsistent state if a page does a back and
1239 // then reload. http://crbug.com/51680 1236 // then reload. http://crbug.com/51680
1240 // Also tests that only user-gesture navigations can interrupt cross-process 1237 // Also tests that only user-gesture navigations can interrupt cross-process
1241 // navigations. http://crbug.com/75195 1238 // navigations. http://crbug.com/75195
1242 TEST_F(RenderFrameHostManagerTest, PageDoesBackAndReload) { 1239 TEST_F(RenderFrameHostManagerTest, PageDoesBackAndReload) {
1243 if (base::CommandLine::ForCurrentProcess()->HasSwitch( 1240 if (base::CommandLine::ForCurrentProcess()->HasSwitch(
1244 switches::kEnableBrowserSideNavigation)) { 1241 switches::kEnableBrowserSideNavigation)) {
1245 // PlzNavigate uses a significantly different logic for renderer initiated 1242 // PlzNavigate uses a significantly different logic for renderer initiated
(...skipping 1401 matching lines...) Expand 10 before | Expand all | Expand 10 after
2647 root->render_manager()->GetRenderFrameProxyHost(hostC->GetSiteInstance()); 2644 root->render_manager()->GetRenderFrameProxyHost(hostC->GetSiteInstance());
2648 EXPECT_TRUE(proxy); 2645 EXPECT_TRUE(proxy);
2649 2646
2650 // Since the B->C navigation happened while the current page was focused, 2647 // Since the B->C navigation happened while the current page was focused,
2651 // page focus should propagate to the new subframe process. Check that 2648 // page focus should propagate to the new subframe process. Check that
2652 // process C received the proper focus message. 2649 // process C received the proper focus message.
2653 VerifyPageFocusMessage(hostC->GetProcess(), true, proxy->GetRoutingID()); 2650 VerifyPageFocusMessage(hostC->GetProcess(), true, proxy->GetRoutingID());
2654 } 2651 }
2655 2652
2656 } // namespace content 2653 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698