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

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

Issue 877343010: PlzNavigate: Fix WebUI creation logic for both cross and same site navigation. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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 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 955 matching lines...) Expand 10 before | Expand all | Expand 10 after
966 // as the navigation starts, rather than lazily after it commits, so we don't 966 // as the navigation starts, rather than lazily after it commits, so we don't
967 // try to re-use the SiteInstance/process for non Web UI things that may 967 // try to re-use the SiteInstance/process for non Web UI things that may
968 // get loaded in between. 968 // get loaded in between.
969 EXPECT_TRUE(host->GetSiteInstance()->HasSite()); 969 EXPECT_TRUE(host->GetSiteInstance()->HasSite());
970 EXPECT_EQ(kUrl, host->GetSiteInstance()->GetSiteURL()); 970 EXPECT_EQ(kUrl, host->GetSiteInstance()->GetSiteURL());
971 971
972 // The Web UI is committed immediately because the RenderViewHost has not been 972 // The Web UI is committed immediately because the RenderViewHost has not been
973 // used yet. UpdateStateForNavigate() took the short cut path. 973 // used yet. UpdateStateForNavigate() took the short cut path.
974 if (base::CommandLine::ForCurrentProcess()->HasSwitch( 974 if (base::CommandLine::ForCurrentProcess()->HasSwitch(
975 switches::kEnableBrowserSideNavigation)) { 975 switches::kEnableBrowserSideNavigation)) {
976 EXPECT_FALSE(manager->speculative_web_ui_for_testing()); 976 EXPECT_FALSE(manager->speculative_web_ui());
977 } else { 977 } else {
978 EXPECT_FALSE(manager->pending_web_ui()); 978 EXPECT_FALSE(manager->pending_web_ui());
979 } 979 }
980 EXPECT_TRUE(manager->web_ui()); 980 EXPECT_TRUE(manager->web_ui());
981 981
982 // Commit. 982 // Commit.
983 manager->DidNavigateFrame(host, true); 983 manager->DidNavigateFrame(host, true);
984 EXPECT_TRUE( 984 EXPECT_TRUE(
985 host->render_view_host()->GetEnabledBindings() & BINDINGS_POLICY_WEB_UI); 985 host->render_view_host()->GetEnabledBindings() & BINDINGS_POLICY_WEB_UI);
986 } 986 }
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
1026 1026
1027 // Now simulate clicking a link that opens in a new tab. 1027 // Now simulate clicking a link that opens in a new tab.
1028 scoped_ptr<TestWebContents> web_contents2( 1028 scoped_ptr<TestWebContents> web_contents2(
1029 TestWebContents::Create(browser_context(), webui_instance)); 1029 TestWebContents::Create(browser_context(), webui_instance));
1030 RenderFrameHostManager* manager2 = 1030 RenderFrameHostManager* manager2 =
1031 web_contents2->GetRenderManagerForTesting(); 1031 web_contents2->GetRenderManagerForTesting();
1032 // Make sure the new RVH is considered live. This is usually done in 1032 // Make sure the new RVH is considered live. This is usually done in
1033 // RenderWidgetHost::Init when opening a new tab from a link. 1033 // RenderWidgetHost::Init when opening a new tab from a link.
1034 manager2->current_host()->CreateRenderView( 1034 manager2->current_host()->CreateRenderView(
1035 base::string16(), -1, MSG_ROUTING_NONE, -1, false); 1035 base::string16(), -1, MSG_ROUTING_NONE, -1, false);
1036 EXPECT_TRUE(manager2->current_host()->IsRenderViewLive());
carlosk 2015/02/05 16:09:06 Added to actually check what's mentioned in the pr
1036 1037
1037 const GURL kUrl2("chrome://foo/bar"); 1038 const GURL kUrl2("chrome://foo/bar");
1038 NavigationEntryImpl entry2(NULL /* instance */, -1 /* page_id */, kUrl2, 1039 NavigationEntryImpl entry2(NULL /* instance */, -1 /* page_id */, kUrl2,
1039 Referrer(), base::string16() /* title */, 1040 Referrer(), base::string16() /* title */,
1040 ui::PAGE_TRANSITION_LINK, 1041 ui::PAGE_TRANSITION_LINK,
1041 true /* is_renderer_init */); 1042 true /* is_renderer_init */);
1042 RenderFrameHostImpl* host2 = GetFrameHostForNavigation(manager2, entry2); 1043 RenderFrameHostImpl* host2 = GetFrameHostForNavigation(manager2, entry2);
1043 1044
1044 // No cross-process transition happens because we are already in the right 1045 // No cross-process transition happens because we are already in the right
1045 // SiteInstance. We should grant bindings immediately. 1046 // SiteInstance. We should grant bindings immediately.
1046 EXPECT_EQ(host2, manager2->current_frame_host()); 1047 EXPECT_EQ(host2, manager2->current_frame_host());
1048 if (base::CommandLine::ForCurrentProcess()->HasSwitch(
1049 switches::kEnableBrowserSideNavigation)) {
1050 EXPECT_TRUE(manager2->speculative_web_ui());
1051 } else {
1052 EXPECT_TRUE(manager2->pending_web_ui());
1053 }
1047 EXPECT_TRUE( 1054 EXPECT_TRUE(
1048 host2->render_view_host()->GetEnabledBindings() & BINDINGS_POLICY_WEB_UI); 1055 host2->render_view_host()->GetEnabledBindings() & BINDINGS_POLICY_WEB_UI);
1049 1056
1050 manager2->DidNavigateFrame(host2, true); 1057 manager2->DidNavigateFrame(host2, true);
1051 } 1058 }
1052 1059
1053 // Tests that we don't end up in an inconsistent state if a page does a back and 1060 // Tests that we don't end up in an inconsistent state if a page does a back and
1054 // then reload. http://crbug.com/51680 1061 // then reload. http://crbug.com/51680
1055 // Also tests that only user-gesture navigations can interrupt cross-process 1062 // Also tests that only user-gesture navigations can interrupt cross-process
1056 // navigations. http://crbug.com/75195 1063 // navigations. http://crbug.com/75195
(...skipping 843 matching lines...) Expand 10 before | Expand all | Expand 10 after
1900 #if 0 1907 #if 0
1901 // TODO(nick): Currently a proxy to the removed frame lingers in the parent. 1908 // TODO(nick): Currently a proxy to the removed frame lingers in the parent.
1902 // Enable this assert below once the proxies to the subframe are correctly 1909 // Enable this assert below once the proxies to the subframe are correctly
1903 // cleaned up after detach. http://crbug.com/444955. 1910 // cleaned up after detach. http://crbug.com/444955.
1904 ASSERT_TRUE(site_instance->HasOneRef()) 1911 ASSERT_TRUE(site_instance->HasOneRef())
1905 << "This SiteInstance should be destroyable now."; 1912 << "This SiteInstance should be destroyable now.";
1906 #endif 1913 #endif
1907 } 1914 }
1908 1915
1909 } // namespace content 1916 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698