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

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

Issue 1229133005: Fix for single-process WebUI transition CHECK failure. Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 5 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
« no previous file with comments | « content/browser/frame_host/render_frame_host_manager.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 1220 matching lines...) Expand 10 before | Expand all | Expand 10 after
1231 const GURL kUrl1("chrome://foo"); 1231 const GURL kUrl1("chrome://foo");
1232 contents()->NavigateAndCommit(kUrl1); 1232 contents()->NavigateAndCommit(kUrl1);
1233 EXPECT_TRUE(main_test_rfh()->frame_tree_node()->render_manager()->web_ui()); 1233 EXPECT_TRUE(main_test_rfh()->frame_tree_node()->render_manager()->web_ui());
1234 1234
1235 // Navigate to a non-WebUI page. 1235 // Navigate to a non-WebUI page.
1236 const GURL kUrl2("http://www.google.com"); 1236 const GURL kUrl2("http://www.google.com");
1237 contents()->NavigateAndCommit(kUrl2); 1237 contents()->NavigateAndCommit(kUrl2);
1238 EXPECT_FALSE(main_test_rfh()->frame_tree_node()->render_manager()->web_ui()); 1238 EXPECT_FALSE(main_test_rfh()->frame_tree_node()->render_manager()->web_ui());
1239 } 1239 }
1240 1240
1241 // Test that WebUI can be navigated to in single-process mode.
1242 TEST_F(RenderFrameHostManagerTest,
1243 CanNavigateBetweenNormalPagesAndWebUIInSingleProcess) {
1244 const GURL kNormalUrl1("http://chromium.org");
1245 const GURL kNormalUrl2("http://example.com");
1246 const GURL kWebUIUrl("chrome://foo");
1247
1248 // We both set flag on RenderProcesHost and append the switch due to the fact
1249 // that some code checks the switch directly instead of relying
1250 // on RenderProcessHost
1251 RenderProcessHost::SetRunRendererInProcess(true);
1252 CommandLine::ForCurrentProcess()->AppendSwitch(switches::kSingleProcess);
1253 set_should_create_webui(true);
1254
1255 RenderFrameHostManager* manager = static_cast<TestWebContents*>(
1256 web_contents())->GetRenderManagerForTesting();
1257
1258 NavigateAndCommit(kNormalUrl1);
1259 EXPECT_EQ(kNormalUrl1,
1260 manager->current_frame_host()->GetSiteInstance()->GetSiteURL());
1261 EXPECT_FALSE(manager->web_ui());
1262 NavigateAndCommit(kWebUIUrl);
1263 EXPECT_EQ(kWebUIUrl,
1264 manager->current_frame_host()->GetSiteInstance()->GetSiteURL());
1265 EXPECT_TRUE(manager->web_ui());
1266 NavigateAndCommit(kNormalUrl2);
1267 EXPECT_EQ(kNormalUrl2,
1268 manager->current_frame_host()->GetSiteInstance()->GetSiteURL());
1269 EXPECT_FALSE(manager->web_ui());
1270 }
1271
1241 // Tests that we don't end up in an inconsistent state if a page does a back and 1272 // Tests that we don't end up in an inconsistent state if a page does a back and
1242 // then reload. http://crbug.com/51680 1273 // then reload. http://crbug.com/51680
1243 // Also tests that only user-gesture navigations can interrupt cross-process 1274 // Also tests that only user-gesture navigations can interrupt cross-process
1244 // navigations. http://crbug.com/75195 1275 // navigations. http://crbug.com/75195
1245 TEST_F(RenderFrameHostManagerTest, PageDoesBackAndReload) { 1276 TEST_F(RenderFrameHostManagerTest, PageDoesBackAndReload) {
1246 const GURL kUrl1("http://www.google.com/"); 1277 const GURL kUrl1("http://www.google.com/");
1247 const GURL kUrl2("http://www.evil-site.com/"); 1278 const GURL kUrl2("http://www.evil-site.com/");
1248 1279
1249 // Navigate to a safe site, then an evil site. 1280 // Navigate to a safe site, then an evil site.
1250 // This will switch RenderFrameHosts. We cannot assert that the first and 1281 // This will switch RenderFrameHosts. We cannot assert that the first and
(...skipping 993 matching lines...) Expand 10 before | Expand all | Expand 10 after
2244 EXPECT_FALSE(contents2->GetMainFrame()->IsRenderFrameLive()); 2275 EXPECT_FALSE(contents2->GetMainFrame()->IsRenderFrameLive());
2245 contents2->NavigateAndCommit(kUrl3); 2276 contents2->NavigateAndCommit(kUrl3);
2246 EXPECT_TRUE(contents2->GetMainFrame()->IsRenderFrameLive()); 2277 EXPECT_TRUE(contents2->GetMainFrame()->IsRenderFrameLive());
2247 EXPECT_NE(nullptr, 2278 EXPECT_NE(nullptr,
2248 iframe->GetRenderFrameProxyHost(contents1->GetSiteInstance())); 2279 iframe->GetRenderFrameProxyHost(contents1->GetSiteInstance()));
2249 EXPECT_EQ(nullptr, 2280 EXPECT_EQ(nullptr,
2250 iframe->GetRenderFrameProxyHost(contents2->GetSiteInstance())); 2281 iframe->GetRenderFrameProxyHost(contents2->GetSiteInstance()));
2251 } 2282 }
2252 2283
2253 } // namespace content 2284 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/frame_host/render_frame_host_manager.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698