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/compositor/test/no_transport_image_transport_factory.h " | 10 #include "content/browser/compositor/test/no_transport_image_transport_factory.h " |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
59 } | 59 } |
60 ~RenderFrameHostManagerTestWebUIControllerFactory() override {} | 60 ~RenderFrameHostManagerTestWebUIControllerFactory() override {} |
61 | 61 |
62 void set_should_create_webui(bool should_create_webui) { | 62 void set_should_create_webui(bool should_create_webui) { |
63 should_create_webui_ = should_create_webui; | 63 should_create_webui_ = should_create_webui; |
64 } | 64 } |
65 | 65 |
66 // WebUIFactory implementation. | 66 // WebUIFactory implementation. |
67 WebUIController* CreateWebUIControllerForURL(WebUI* web_ui, | 67 WebUIController* CreateWebUIControllerForURL(WebUI* web_ui, |
68 const GURL& url) const override { | 68 const GURL& url) const override { |
69 if (!(should_create_webui_ && HasWebUIScheme(url))) | 69 // If WebUI creation is enabled for the test and this is a WebUI URL, |
70 return NULL; | 70 // returns a new instance. |
71 return new WebUIController(web_ui); | 71 if (should_create_webui_ && HasWebUIScheme(url)) |
72 return new WebUIController(web_ui); | |
73 return nullptr; | |
72 } | 74 } |
73 | 75 |
74 WebUI::TypeID GetWebUIType(BrowserContext* browser_context, | 76 WebUI::TypeID GetWebUIType(BrowserContext* browser_context, |
75 const GURL& url) const override { | 77 const GURL& url) const override { |
78 // If WebUI creation is enabled for the test and this is a WebUI URL, | |
79 // returns a mock WebUI type. | |
80 if (should_create_webui_ && HasWebUIScheme(url)) { | |
81 return const_cast<RenderFrameHostManagerTestWebUIControllerFactory*>( | |
82 this); | |
83 } | |
76 return WebUI::kNoWebUI; | 84 return WebUI::kNoWebUI; |
77 } | 85 } |
78 | 86 |
79 bool UseWebUIForURL(BrowserContext* browser_context, | 87 bool UseWebUIForURL(BrowserContext* browser_context, |
80 const GURL& url) const override { | 88 const GURL& url) const override { |
81 return HasWebUIScheme(url); | 89 return HasWebUIScheme(url); |
82 } | 90 } |
83 | 91 |
84 bool UseWebUIBindingsForURL(BrowserContext* browser_context, | 92 bool UseWebUIBindingsForURL(BrowserContext* browser_context, |
85 const GURL& url) const override { | 93 const GURL& url) const override { |
(...skipping 1008 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1094 | 1102 |
1095 // It's important that the SiteInstance get set on the Web UI page as soon | 1103 // It's important that the SiteInstance get set on the Web UI page as soon |
1096 // as the navigation starts, rather than lazily after it commits, so we don't | 1104 // as the navigation starts, rather than lazily after it commits, so we don't |
1097 // try to re-use the SiteInstance/process for non Web UI things that may | 1105 // try to re-use the SiteInstance/process for non Web UI things that may |
1098 // get loaded in between. | 1106 // get loaded in between. |
1099 EXPECT_TRUE(host->GetSiteInstance()->HasSite()); | 1107 EXPECT_TRUE(host->GetSiteInstance()->HasSite()); |
1100 EXPECT_EQ(kUrl, host->GetSiteInstance()->GetSiteURL()); | 1108 EXPECT_EQ(kUrl, host->GetSiteInstance()->GetSiteURL()); |
1101 | 1109 |
1102 // The Web UI is committed immediately because the RenderViewHost has not been | 1110 // The Web UI is committed immediately because the RenderViewHost has not been |
1103 // used yet. UpdateStateForNavigate() took the short cut path. | 1111 // used yet. UpdateStateForNavigate() took the short cut path. |
1104 if (base::CommandLine::ForCurrentProcess()->HasSwitch( | 1112 EXPECT_FALSE(manager->pending_web_ui()); |
1105 switches::kEnableBrowserSideNavigation)) { | |
1106 EXPECT_FALSE(manager->speculative_web_ui()); | |
1107 } else { | |
1108 EXPECT_FALSE(manager->pending_web_ui()); | |
1109 } | |
1110 EXPECT_TRUE(manager->web_ui()); | 1113 EXPECT_TRUE(manager->web_ui()); |
1111 | 1114 |
1112 // Commit. | 1115 // Commit. |
1113 manager->DidNavigateFrame(host, true); | 1116 manager->DidNavigateFrame(host, true); |
1114 EXPECT_TRUE( | 1117 EXPECT_TRUE( |
1115 host->render_view_host()->GetEnabledBindings() & BINDINGS_POLICY_WEB_UI); | 1118 host->render_view_host()->GetEnabledBindings() & BINDINGS_POLICY_WEB_UI); |
1116 } | 1119 } |
1117 | 1120 |
1118 // Tests that we can open a WebUI link in a new tab from a WebUI page and still | 1121 // Tests that we can open a WebUI link in a new tab from a WebUI page and still |
1119 // grant the correct bindings. http://crbug.com/189101. | 1122 // grant the correct bindings. http://crbug.com/189101. |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1169 const GURL kUrl2("chrome://foo/bar"); | 1172 const GURL kUrl2("chrome://foo/bar"); |
1170 NavigationEntryImpl entry2(NULL /* instance */, -1 /* page_id */, kUrl2, | 1173 NavigationEntryImpl entry2(NULL /* instance */, -1 /* page_id */, kUrl2, |
1171 Referrer(), base::string16() /* title */, | 1174 Referrer(), base::string16() /* title */, |
1172 ui::PAGE_TRANSITION_LINK, | 1175 ui::PAGE_TRANSITION_LINK, |
1173 true /* is_renderer_init */); | 1176 true /* is_renderer_init */); |
1174 RenderFrameHostImpl* host2 = NavigateToEntry(manager2, entry2); | 1177 RenderFrameHostImpl* host2 = NavigateToEntry(manager2, entry2); |
1175 | 1178 |
1176 // No cross-process transition happens because we are already in the right | 1179 // No cross-process transition happens because we are already in the right |
1177 // SiteInstance. We should grant bindings immediately. | 1180 // SiteInstance. We should grant bindings immediately. |
1178 EXPECT_EQ(host2, manager2->current_frame_host()); | 1181 EXPECT_EQ(host2, manager2->current_frame_host()); |
1179 if (base::CommandLine::ForCurrentProcess()->HasSwitch( | 1182 EXPECT_TRUE(manager2->pending_web_ui()); |
nasko
2015/10/29 22:13:15
This should be manager2->current_frame_host()->web
carlosk
2015/10/30 10:35:23
Once I eliminate pending_web_ui() then that will b
| |
1180 switches::kEnableBrowserSideNavigation)) { | |
1181 EXPECT_TRUE(manager2->speculative_web_ui()); | |
1182 } else { | |
1183 EXPECT_TRUE(manager2->pending_web_ui()); | |
1184 } | |
1185 EXPECT_TRUE( | 1183 EXPECT_TRUE( |
1186 host2->render_view_host()->GetEnabledBindings() & BINDINGS_POLICY_WEB_UI); | 1184 host2->render_view_host()->GetEnabledBindings() & BINDINGS_POLICY_WEB_UI); |
1187 | 1185 |
1188 manager2->DidNavigateFrame(host2, true); | 1186 manager2->DidNavigateFrame(host2, true); |
1189 } | 1187 } |
1190 | 1188 |
1191 // Tests that a WebUI is correctly reused between chrome:// pages. | 1189 // Tests that a WebUI is correctly reused between chrome:// pages. |
1192 TEST_F(RenderFrameHostManagerTest, WebUIWasReused) { | 1190 TEST_F(RenderFrameHostManagerTest, WebUIWasReused) { |
1193 set_should_create_webui(true); | 1191 set_should_create_webui(true); |
1194 | 1192 |
(...skipping 1394 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2589 host1->GetProcess()->sink().ClearMessages(); | 2587 host1->GetProcess()->sink().ClearMessages(); |
2590 host3->GetProcess()->sink().ClearMessages(); | 2588 host3->GetProcess()->sink().ClearMessages(); |
2591 main_test_rfh()->GetRenderWidgetHost()->Blur(); | 2589 main_test_rfh()->GetRenderWidgetHost()->Blur(); |
2592 verify_focus_message(main_test_rfh()->GetProcess(), false, | 2590 verify_focus_message(main_test_rfh()->GetProcess(), false, |
2593 main_test_rfh()->GetRenderViewHost()->GetRoutingID()); | 2591 main_test_rfh()->GetRenderViewHost()->GetRoutingID()); |
2594 verify_focus_message(host1->GetProcess(), false, proxyB->GetRoutingID()); | 2592 verify_focus_message(host1->GetProcess(), false, proxyB->GetRoutingID()); |
2595 verify_focus_message(host3->GetProcess(), false, proxyC->GetRoutingID()); | 2593 verify_focus_message(host3->GetProcess(), false, proxyC->GetRoutingID()); |
2596 } | 2594 } |
2597 | 2595 |
2598 } // namespace content | 2596 } // namespace content |
OLD | NEW |