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

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

Issue 298133002: Don't ensure, in single-process mode, that WebUI render views are the only ones in the process, as … (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Set --single-process flag too in order to make sure correct scenario is trigerred Created 6 years, 2 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 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/time/time.h" 8 #include "base/time/time.h"
9 #include "content/browser/frame_host/cross_site_transferring_request.h" 9 #include "content/browser/frame_host/cross_site_transferring_request.h"
10 #include "content/browser/frame_host/navigation_before_commit_info.h" 10 #include "content/browser/frame_host/navigation_before_commit_info.h"
(...skipping 975 matching lines...) Expand 10 before | Expand all | Expand 10 after
986 986
987 // No cross-process transition happens because we are already in the right 987 // No cross-process transition happens because we are already in the right
988 // SiteInstance. We should grant bindings immediately. 988 // SiteInstance. We should grant bindings immediately.
989 EXPECT_EQ(host2, manager2->current_frame_host()); 989 EXPECT_EQ(host2, manager2->current_frame_host());
990 EXPECT_TRUE( 990 EXPECT_TRUE(
991 host2->render_view_host()->GetEnabledBindings() & BINDINGS_POLICY_WEB_UI); 991 host2->render_view_host()->GetEnabledBindings() & BINDINGS_POLICY_WEB_UI);
992 992
993 manager2->DidNavigateFrame(host2); 993 manager2->DidNavigateFrame(host2);
994 } 994 }
995 995
996 // Test that WebUI can be navigated to in single-process mode.
997 TEST_F(RenderFrameHostManagerTest,
998 CanNavigateBetweenNormalPagesAndWebUIInSingleProcess) {
999 const GURL kNormalUrl1("http://chromium.org");
1000 const GURL kNormalUrl2("http://example.com");
1001 const GURL kWebUIUrl("chrome://foo");
1002
1003 // We both set flag on RenderProcesHost and append the switch due to the fact
1004 // that some code checks the switch directly instead of relying
1005 // on RenderProcessHost
nasko 2014/09/29 22:21:48 sidenote: It is best to have one source of truth i
Krzysztof Olczyk 2014/10/01 10:17:47 Done: https://code.google.com/p/chromium/issues/de
1006 RenderProcessHost::SetRunRendererInProcess(true);
1007 CommandLine::ForCurrentProcess()->AppendSwitch(switches::kSingleProcess);
1008 set_should_create_webui(true);
1009
1010 RenderFrameHostManager* manager =
1011 static_cast<TestWebContents*>(
nasko 2014/09/29 22:21:48 nit: this line should be able to fit on the previo
Krzysztof Olczyk 2014/10/01 10:17:47 Done
1012 web_contents())->GetRenderManagerForTesting();
1013
1014 NavigateAndCommit(kNormalUrl1);
1015 EXPECT_EQ(kNormalUrl1,
1016 manager->current_frame_host()->GetSiteInstance()->GetSiteURL());
1017 EXPECT_FALSE(manager->web_ui());
1018 NavigateAndCommit(kWebUIUrl);
1019 EXPECT_EQ(kWebUIUrl,
1020 manager->current_frame_host()->GetSiteInstance()->GetSiteURL());
1021 EXPECT_TRUE(manager->web_ui());
1022 NavigateAndCommit(kNormalUrl2);
1023 EXPECT_EQ(kNormalUrl2,
1024 manager->current_frame_host()->GetSiteInstance()->GetSiteURL());
1025 EXPECT_FALSE(manager->web_ui());
1026 }
1027
996 // Tests that we don't end up in an inconsistent state if a page does a back and 1028 // Tests that we don't end up in an inconsistent state if a page does a back and
997 // then reload. http://crbug.com/51680 1029 // then reload. http://crbug.com/51680
998 TEST_F(RenderFrameHostManagerTest, PageDoesBackAndReload) { 1030 TEST_F(RenderFrameHostManagerTest, PageDoesBackAndReload) {
999 const GURL kUrl1("http://www.google.com/"); 1031 const GURL kUrl1("http://www.google.com/");
1000 const GURL kUrl2("http://www.evil-site.com/"); 1032 const GURL kUrl2("http://www.evil-site.com/");
1001 1033
1002 // Navigate to a safe site, then an evil site. 1034 // Navigate to a safe site, then an evil site.
1003 // This will switch RenderFrameHosts. We cannot assert that the first and 1035 // This will switch RenderFrameHosts. We cannot assert that the first and
1004 // second RFHs are different, though, because the first one may be promptly 1036 // second RFHs are different, though, because the first one may be promptly
1005 // deleted. 1037 // deleted.
(...skipping 848 matching lines...) Expand 10 before | Expand all | Expand 10 after
1854 EXPECT_EQ(kUrl0_site, main_test_rfh()->GetSiteInstance()->GetSiteURL()); 1886 EXPECT_EQ(kUrl0_site, main_test_rfh()->GetSiteInstance()->GetSiteURL());
1855 1887
1856 // Confirms that a valid, request-matching commit is correctly processed. 1888 // Confirms that a valid, request-matching commit is correctly processed.
1857 nbc_info.navigation_url = kUrl2; 1889 nbc_info.navigation_url = kUrl2;
1858 nbc_info.navigation_request_id = request_id2; 1890 nbc_info.navigation_request_id = request_id2;
1859 render_manager->CommitNavigation(nbc_info); 1891 render_manager->CommitNavigation(nbc_info);
1860 EXPECT_EQ(kUrl2_site, main_test_rfh()->GetSiteInstance()->GetSiteURL()); 1892 EXPECT_EQ(kUrl2_site, main_test_rfh()->GetSiteInstance()->GetSiteURL());
1861 } 1893 }
1862 1894
1863 } // namespace content 1895 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698