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" | 5 #include "base/command_line.h" |
6 #include "content/browser/frame_host/frame_tree.h" | 6 #include "content/browser/frame_host/frame_tree.h" |
7 #include "content/browser/frame_host/frame_tree_node.h" | 7 #include "content/browser/frame_host/frame_tree_node.h" |
8 #include "content/browser/renderer_host/render_view_host_impl.h" | 8 #include "content/browser/renderer_host/render_view_host_impl.h" |
9 #include "content/browser/web_contents/web_contents_impl.h" | 9 #include "content/browser/web_contents/web_contents_impl.h" |
10 #include "content/public/browser/notification_service.h" | 10 #include "content/public/browser/notification_service.h" |
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
180 MAYBE_CreateCrossProcessSubframeProxies) { | 180 MAYBE_CreateCrossProcessSubframeProxies) { |
181 host_resolver()->AddRule("*", "127.0.0.1"); | 181 host_resolver()->AddRule("*", "127.0.0.1"); |
182 ASSERT_TRUE(test_server()->Start()); | 182 ASSERT_TRUE(test_server()->Start()); |
183 GURL main_url(test_server()->GetURL("files/site_per_process_main.html")); | 183 GURL main_url(test_server()->GetURL("files/site_per_process_main.html")); |
184 NavigateToURL(shell(), main_url); | 184 NavigateToURL(shell(), main_url); |
185 | 185 |
186 // It is safe to obtain the root frame tree node here, as it doesn't change. | 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()) | 187 FrameTreeNode* root = static_cast<WebContentsImpl*>(shell()->web_contents()) |
188 ->GetFrameTree()->root(); | 188 ->GetFrameTree()->root(); |
189 | 189 |
190 // There should not be a proxy for the root's own SiteInstance. | |
191 SiteInstance* root_instance = root->current_frame_host()->GetSiteInstance(); | |
192 EXPECT_FALSE(root->render_manager()->GetRenderFrameProxyHost(root_instance)); | |
Charlie Reis
2014/08/08 17:19:39
Note: This used to fail because we tried to swap f
| |
193 | |
190 // Load same-site page into iframe. | 194 // Load same-site page into iframe. |
191 GURL http_url(test_server()->GetURL("files/title1.html")); | 195 GURL http_url(test_server()->GetURL("files/title1.html")); |
192 NavigateFrameToURL(root->child_at(0), http_url); | 196 NavigateFrameToURL(root->child_at(0), http_url); |
193 | 197 |
194 // These must stay in scope with replace_host. | 198 // These must stay in scope with replace_host. |
195 GURL::Replacements replace_host; | 199 GURL::Replacements replace_host; |
196 std::string foo_com("foo.com"); | 200 std::string foo_com("foo.com"); |
197 | 201 |
198 // Load cross-site page into iframe. | 202 // Load cross-site page into iframe. |
199 GURL cross_site_url(test_server()->GetURL("files/title2.html")); | 203 GURL cross_site_url(test_server()->GetURL("files/title2.html")); |
200 replace_host.SetHostStr(foo_com); | 204 replace_host.SetHostStr(foo_com); |
201 cross_site_url = cross_site_url.ReplaceComponents(replace_host); | 205 cross_site_url = cross_site_url.ReplaceComponents(replace_host); |
202 NavigateFrameToURL(root->child_at(0), cross_site_url); | 206 NavigateFrameToURL(root->child_at(0), cross_site_url); |
203 | 207 |
204 // Ensure that we have created a new process for the subframe. | 208 // Ensure that we have created a new process for the subframe. |
205 ASSERT_EQ(1U, root->child_count()); | 209 ASSERT_EQ(1U, root->child_count()); |
206 FrameTreeNode* child = root->child_at(0); | 210 FrameTreeNode* child = root->child_at(0); |
207 SiteInstance* site_instance = child->current_frame_host()->GetSiteInstance(); | 211 SiteInstance* child_instance = child->current_frame_host()->GetSiteInstance(); |
208 RenderViewHost* rvh = child->current_frame_host()->render_view_host(); | 212 RenderViewHost* rvh = child->current_frame_host()->render_view_host(); |
209 RenderProcessHost* rph = child->current_frame_host()->GetProcess(); | 213 RenderProcessHost* rph = child->current_frame_host()->GetProcess(); |
210 | 214 |
211 EXPECT_NE(shell()->web_contents()->GetRenderViewHost(), rvh); | 215 EXPECT_NE(shell()->web_contents()->GetRenderViewHost(), rvh); |
212 EXPECT_NE(shell()->web_contents()->GetSiteInstance(), site_instance); | 216 EXPECT_NE(shell()->web_contents()->GetSiteInstance(), child_instance); |
213 EXPECT_NE(shell()->web_contents()->GetRenderProcessHost(), rph); | 217 EXPECT_NE(shell()->web_contents()->GetRenderProcessHost(), rph); |
214 | 218 |
215 // Ensure that the root node has a proxy for the child node's SiteInstance. | 219 // 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()]); | 220 EXPECT_TRUE(root->render_manager()->GetRenderFrameProxyHost(child_instance)); |
217 | 221 |
218 // Also ensure that the child has a proxy for the root node's SiteInstance. | 222 // Also ensure that the child has a proxy for the root node's SiteInstance. |
219 EXPECT_TRUE(child->render_manager()->proxy_hosts_[ | 223 EXPECT_TRUE(child->render_manager()->GetRenderFrameProxyHost(root_instance)); |
220 root->current_frame_host()->GetSiteInstance()->GetId()]); | 224 |
225 // The nodes should not have proxies for their own SiteInstance. | |
226 EXPECT_FALSE(root->render_manager()->GetRenderFrameProxyHost(root_instance)); | |
227 EXPECT_FALSE( | |
228 child->render_manager()->GetRenderFrameProxyHost(child_instance)); | |
221 } | 229 } |
222 | 230 |
223 } // namespace content | 231 } // namespace content |
OLD | NEW |