OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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" | |
6 #include "content/browser/frame_host/frame_tree.h" | 5 #include "content/browser/frame_host/frame_tree.h" |
7 #include "content/browser/frame_host/frame_tree_node.h" | 6 #include "content/browser/frame_host/frame_tree_node.h" |
8 #include "content/browser/renderer_host/render_view_host_impl.h" | 7 #include "content/browser/renderer_host/render_view_host_impl.h" |
9 #include "content/browser/web_contents/web_contents_impl.h" | 8 #include "content/browser/web_contents/web_contents_impl.h" |
10 #include "content/public/browser/notification_service.h" | 9 #include "content/public/browser/notification_service.h" |
11 #include "content/public/browser/notification_types.h" | 10 #include "content/public/browser/notification_types.h" |
12 #include "content/public/common/content_switches.h" | |
13 #include "content/public/common/url_constants.h" | 11 #include "content/public/common/url_constants.h" |
14 #include "content/public/test/browser_test_utils.h" | 12 #include "content/public/test/browser_test_utils.h" |
15 #include "content/public/test/content_browser_test.h" | 13 #include "content/public/test/content_browser_test.h" |
16 #include "content/public/test/content_browser_test_utils.h" | 14 #include "content/public/test/content_browser_test_utils.h" |
17 #include "content/public/test/test_navigation_observer.h" | 15 #include "content/public/test/test_navigation_observer.h" |
18 #include "content/public/test/test_utils.h" | 16 #include "content/public/test/test_utils.h" |
19 #include "content/shell/browser/shell.h" | 17 #include "content/shell/browser/shell.h" |
20 #include "content/test/content_browser_test_utils_internal.h" | |
21 #include "net/dns/mock_host_resolver.h" | 18 #include "net/dns/mock_host_resolver.h" |
22 | 19 |
23 namespace content { | 20 namespace content { |
24 | 21 |
25 class FrameTreeBrowserTest : public ContentBrowserTest { | 22 class FrameTreeBrowserTest : public ContentBrowserTest { |
26 public: | 23 public: |
27 FrameTreeBrowserTest() {} | 24 FrameTreeBrowserTest() {} |
28 | 25 |
29 private: | 26 private: |
30 DISALLOW_COPY_AND_ASSIGN(FrameTreeBrowserTest); | 27 DISALLOW_COPY_AND_ASSIGN(FrameTreeBrowserTest); |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
151 // Navigate to a new URL. We use LoadURL because NavigateToURL will try to | 148 // Navigate to a new URL. We use LoadURL because NavigateToURL will try to |
152 // wait for the previous navigation to stop. | 149 // wait for the previous navigation to stop. |
153 TestNavigationObserver tab_observer(wc, 1); | 150 TestNavigationObserver tab_observer(wc, 1); |
154 shell()->LoadURL(base_url.Resolve("blank.html")); | 151 shell()->LoadURL(base_url.Resolve("blank.html")); |
155 tab_observer.Wait(); | 152 tab_observer.Wait(); |
156 | 153 |
157 // The frame tree should now be cleared. | 154 // The frame tree should now be cleared. |
158 EXPECT_EQ(0UL, root->child_count()); | 155 EXPECT_EQ(0UL, root->child_count()); |
159 } | 156 } |
160 | 157 |
161 class CrossProcessFrameTreeBrowserTest : public ContentBrowserTest { | |
162 public: | |
163 CrossProcessFrameTreeBrowserTest() {} | |
164 | |
165 virtual void SetUpCommandLine(base::CommandLine* command_line) OVERRIDE { | |
166 command_line->AppendSwitch(switches::kSitePerProcess); | |
167 } | |
168 | |
169 private: | |
170 DISALLOW_COPY_AND_ASSIGN(CrossProcessFrameTreeBrowserTest); | |
171 }; | |
172 | |
173 // Ensure that we can complete a cross-process subframe navigation. | |
174 #if defined(OS_ANDROID) | |
175 #define MAYBE_CreateCrossProcessSubframeProxies DISABLED_CreateCrossProcessSubfr
ameProxies | |
176 #else | |
177 #define MAYBE_CreateCrossProcessSubframeProxies CreateCrossProcessSubframeProxie
s | |
178 #endif | |
179 IN_PROC_BROWSER_TEST_F(CrossProcessFrameTreeBrowserTest, | |
180 MAYBE_CreateCrossProcessSubframeProxies) { | |
181 host_resolver()->AddRule("*", "127.0.0.1"); | |
182 ASSERT_TRUE(test_server()->Start()); | |
183 GURL main_url(test_server()->GetURL("files/site_per_process_main.html")); | |
184 NavigateToURL(shell(), main_url); | |
185 | |
186 // It is safe to obtain the root frame tree node here, as it doesn't change. | |
187 FrameTreeNode* root = static_cast<WebContentsImpl*>(shell()->web_contents()) | |
188 ->GetFrameTree()->root(); | |
189 | |
190 // Load same-site page into iframe. | |
191 GURL http_url(test_server()->GetURL("files/title1.html")); | |
192 NavigateFrameToURL(root->child_at(0), http_url); | |
193 | |
194 // These must stay in scope with replace_host. | |
195 GURL::Replacements replace_host; | |
196 std::string foo_com("foo.com"); | |
197 | |
198 // Load cross-site page into iframe. | |
199 GURL cross_site_url(test_server()->GetURL("files/title2.html")); | |
200 replace_host.SetHostStr(foo_com); | |
201 cross_site_url = cross_site_url.ReplaceComponents(replace_host); | |
202 NavigateFrameToURL(root->child_at(0), cross_site_url); | |
203 | |
204 // Ensure that we have created a new process for the subframe. | |
205 ASSERT_EQ(1U, root->child_count()); | |
206 FrameTreeNode* child = root->child_at(0); | |
207 SiteInstance* site_instance = child->current_frame_host()->GetSiteInstance(); | |
208 RenderViewHost* rvh = child->current_frame_host()->render_view_host(); | |
209 RenderProcessHost* rph = child->current_frame_host()->GetProcess(); | |
210 | |
211 EXPECT_NE(shell()->web_contents()->GetRenderViewHost(), rvh); | |
212 EXPECT_NE(shell()->web_contents()->GetSiteInstance(), site_instance); | |
213 EXPECT_NE(shell()->web_contents()->GetRenderProcessHost(), rph); | |
214 | |
215 // Ensure that the root node has a proxy for the child node's SiteInstance. | |
216 EXPECT_TRUE(root->render_manager()->proxy_hosts_[site_instance->GetId()]); | |
217 | |
218 // Also ensure that the child has a proxy for the root node's SiteInstance. | |
219 EXPECT_TRUE(child->render_manager()->proxy_hosts_[ | |
220 root->current_frame_host()->GetSiteInstance()->GetId()]); | |
221 } | |
222 | |
223 } // namespace content | 158 } // namespace content |
OLD | NEW |