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 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
74 } | 74 } |
75 ~RenderFrameHostManagerTestWebUIControllerFactory() override {} | 75 ~RenderFrameHostManagerTestWebUIControllerFactory() override {} |
76 | 76 |
77 void set_should_create_webui(bool should_create_webui) { | 77 void set_should_create_webui(bool should_create_webui) { |
78 should_create_webui_ = should_create_webui; | 78 should_create_webui_ = should_create_webui; |
79 } | 79 } |
80 | 80 |
81 // WebUIFactory implementation. | 81 // WebUIFactory implementation. |
82 WebUIController* CreateWebUIControllerForURL(WebUI* web_ui, | 82 WebUIController* CreateWebUIControllerForURL(WebUI* web_ui, |
83 const GURL& url) const override { | 83 const GURL& url) const override { |
84 // If WebUI creation is enabled for the test and this is a WebUI URL, | 84 if (!(should_create_webui_ && HasWebUIScheme(url))) |
85 // returns a new instance. | 85 return NULL; |
86 if (should_create_webui_ && HasWebUIScheme(url)) | 86 return new WebUIController(web_ui); |
87 return new WebUIController(web_ui); | |
88 return nullptr; | |
89 } | 87 } |
90 | 88 |
91 WebUI::TypeID GetWebUIType(BrowserContext* browser_context, | 89 WebUI::TypeID GetWebUIType(BrowserContext* browser_context, |
92 const GURL& url) const override { | 90 const GURL& url) const override { |
93 // If WebUI creation is enabled for the test and this is a WebUI URL, | |
94 // returns a mock WebUI type. | |
95 if (should_create_webui_ && HasWebUIScheme(url)) { | |
96 return const_cast<RenderFrameHostManagerTestWebUIControllerFactory*>( | |
97 this); | |
98 } | |
99 return WebUI::kNoWebUI; | 91 return WebUI::kNoWebUI; |
100 } | 92 } |
101 | 93 |
102 bool UseWebUIForURL(BrowserContext* browser_context, | 94 bool UseWebUIForURL(BrowserContext* browser_context, |
103 const GURL& url) const override { | 95 const GURL& url) const override { |
104 return HasWebUIScheme(url); | 96 return HasWebUIScheme(url); |
105 } | 97 } |
106 | 98 |
107 bool UseWebUIBindingsForURL(BrowserContext* browser_context, | 99 bool UseWebUIBindingsForURL(BrowserContext* browser_context, |
108 const GURL& url) const override { | 100 const GURL& url) const override { |
(...skipping 1008 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1117 | 1109 |
1118 // It's important that the SiteInstance get set on the Web UI page as soon | 1110 // It's important that the SiteInstance get set on the Web UI page as soon |
1119 // as the navigation starts, rather than lazily after it commits, so we don't | 1111 // as the navigation starts, rather than lazily after it commits, so we don't |
1120 // try to re-use the SiteInstance/process for non Web UI things that may | 1112 // try to re-use the SiteInstance/process for non Web UI things that may |
1121 // get loaded in between. | 1113 // get loaded in between. |
1122 EXPECT_TRUE(host->GetSiteInstance()->HasSite()); | 1114 EXPECT_TRUE(host->GetSiteInstance()->HasSite()); |
1123 EXPECT_EQ(kUrl, host->GetSiteInstance()->GetSiteURL()); | 1115 EXPECT_EQ(kUrl, host->GetSiteInstance()->GetSiteURL()); |
1124 | 1116 |
1125 // The Web UI is committed immediately because the RenderViewHost has not been | 1117 // The Web UI is committed immediately because the RenderViewHost has not been |
1126 // used yet. UpdateStateForNavigate() took the short cut path. | 1118 // used yet. UpdateStateForNavigate() took the short cut path. |
1127 EXPECT_FALSE(manager->GetNavigatingWebUI()); | 1119 if (base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 1120 switches::kEnableBrowserSideNavigation)) { |
| 1121 EXPECT_FALSE(manager->speculative_web_ui()); |
| 1122 } else { |
| 1123 EXPECT_FALSE(manager->pending_web_ui()); |
| 1124 } |
1128 EXPECT_TRUE(manager->web_ui()); | 1125 EXPECT_TRUE(manager->web_ui()); |
1129 | 1126 |
1130 // Commit. | 1127 // Commit. |
1131 manager->DidNavigateFrame(host, true); | 1128 manager->DidNavigateFrame(host, true); |
1132 EXPECT_TRUE( | 1129 EXPECT_TRUE( |
1133 host->render_view_host()->GetEnabledBindings() & BINDINGS_POLICY_WEB_UI); | 1130 host->render_view_host()->GetEnabledBindings() & BINDINGS_POLICY_WEB_UI); |
1134 } | 1131 } |
1135 | 1132 |
1136 // Tests that we can open a WebUI link in a new tab from a WebUI page and still | 1133 // Tests that we can open a WebUI link in a new tab from a WebUI page and still |
1137 // grant the correct bindings. http://crbug.com/189101. | 1134 // grant the correct bindings. http://crbug.com/189101. |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1187 const GURL kUrl2("chrome://foo/bar"); | 1184 const GURL kUrl2("chrome://foo/bar"); |
1188 NavigationEntryImpl entry2(NULL /* instance */, -1 /* page_id */, kUrl2, | 1185 NavigationEntryImpl entry2(NULL /* instance */, -1 /* page_id */, kUrl2, |
1189 Referrer(), base::string16() /* title */, | 1186 Referrer(), base::string16() /* title */, |
1190 ui::PAGE_TRANSITION_LINK, | 1187 ui::PAGE_TRANSITION_LINK, |
1191 true /* is_renderer_init */); | 1188 true /* is_renderer_init */); |
1192 RenderFrameHostImpl* host2 = NavigateToEntry(manager2, entry2); | 1189 RenderFrameHostImpl* host2 = NavigateToEntry(manager2, entry2); |
1193 | 1190 |
1194 // No cross-process transition happens because we are already in the right | 1191 // No cross-process transition happens because we are already in the right |
1195 // SiteInstance. We should grant bindings immediately. | 1192 // SiteInstance. We should grant bindings immediately. |
1196 EXPECT_EQ(host2, manager2->current_frame_host()); | 1193 EXPECT_EQ(host2, manager2->current_frame_host()); |
1197 EXPECT_TRUE(manager2->GetNavigatingWebUI()); | 1194 if (base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 1195 switches::kEnableBrowserSideNavigation)) { |
| 1196 EXPECT_TRUE(manager2->speculative_web_ui()); |
| 1197 } else { |
| 1198 EXPECT_TRUE(manager2->pending_web_ui()); |
| 1199 } |
1198 EXPECT_TRUE( | 1200 EXPECT_TRUE( |
1199 host2->render_view_host()->GetEnabledBindings() & BINDINGS_POLICY_WEB_UI); | 1201 host2->render_view_host()->GetEnabledBindings() & BINDINGS_POLICY_WEB_UI); |
1200 | 1202 |
1201 manager2->DidNavigateFrame(host2, true); | 1203 manager2->DidNavigateFrame(host2, true); |
1202 } | 1204 } |
1203 | 1205 |
1204 // Tests that a WebUI is correctly reused between chrome:// pages. | 1206 // Tests that a WebUI is correctly reused between chrome:// pages. |
1205 TEST_F(RenderFrameHostManagerTest, WebUIWasReused) { | 1207 TEST_F(RenderFrameHostManagerTest, WebUIWasReused) { |
1206 set_should_create_webui(true); | 1208 set_should_create_webui(true); |
1207 | 1209 |
(...skipping 1446 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2654 root->render_manager()->GetRenderFrameProxyHost(hostC->GetSiteInstance()); | 2656 root->render_manager()->GetRenderFrameProxyHost(hostC->GetSiteInstance()); |
2655 EXPECT_TRUE(proxy); | 2657 EXPECT_TRUE(proxy); |
2656 | 2658 |
2657 // Since the B->C navigation happened while the current page was focused, | 2659 // Since the B->C navigation happened while the current page was focused, |
2658 // page focus should propagate to the new subframe process. Check that | 2660 // page focus should propagate to the new subframe process. Check that |
2659 // process C received the proper focus message. | 2661 // process C received the proper focus message. |
2660 VerifyPageFocusMessage(hostC->GetProcess(), true, proxy->GetRoutingID()); | 2662 VerifyPageFocusMessage(hostC->GetProcess(), true, proxy->GetRoutingID()); |
2661 } | 2663 } |
2662 | 2664 |
2663 } // namespace content | 2665 } // namespace content |
OLD | NEW |