OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/strings/stringprintf.h" | 6 #include "base/strings/stringprintf.h" |
7 #include "content/browser/frame_host/frame_tree.h" | 7 #include "content/browser/frame_host/frame_tree.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_observer.h" | 10 #include "content/public/browser/notification_observer.h" |
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
209 static_cast<WebContentsImpl*>(shell()->web_contents())-> | 209 static_cast<WebContentsImpl*>(shell()->web_contents())-> |
210 GetFrameTree()->root(); | 210 GetFrameTree()->root(); |
211 | 211 |
212 SitePerProcessWebContentsObserver observer(shell()->web_contents()); | 212 SitePerProcessWebContentsObserver observer(shell()->web_contents()); |
213 | 213 |
214 // Load same-site page into iframe. | 214 // Load same-site page into iframe. |
215 GURL http_url(test_server()->GetURL("files/title1.html")); | 215 GURL http_url(test_server()->GetURL("files/title1.html")); |
216 NavigateFrameToURL(root->child_at(0), http_url); | 216 NavigateFrameToURL(root->child_at(0), http_url); |
217 EXPECT_EQ(http_url, observer.navigation_url()); | 217 EXPECT_EQ(http_url, observer.navigation_url()); |
218 EXPECT_TRUE(observer.navigation_succeeded()); | 218 EXPECT_TRUE(observer.navigation_succeeded()); |
| 219 { |
| 220 // There should be only one RenderWidgetHost when there are no |
| 221 // cross-process iframes. |
| 222 std::set<RenderWidgetHostImpl*> widgets_set = |
| 223 static_cast<WebContentsImpl*>(shell()->web_contents()) |
| 224 ->GetRenderWidgetHostsInTree(); |
| 225 EXPECT_EQ(1U, widgets_set.size()); |
| 226 } |
219 | 227 |
220 // These must stay in scope with replace_host. | 228 // These must stay in scope with replace_host. |
221 GURL::Replacements replace_host; | 229 GURL::Replacements replace_host; |
222 std::string foo_com("foo.com"); | 230 std::string foo_com("foo.com"); |
223 | 231 |
224 // Load cross-site page into iframe. | 232 // Load cross-site page into iframe. |
225 GURL cross_site_url(test_server()->GetURL("files/title2.html")); | 233 GURL cross_site_url(test_server()->GetURL("files/title2.html")); |
226 replace_host.SetHostStr(foo_com); | 234 replace_host.SetHostStr(foo_com); |
227 cross_site_url = cross_site_url.ReplaceComponents(replace_host); | 235 cross_site_url = cross_site_url.ReplaceComponents(replace_host); |
228 NavigateFrameToURL(root->child_at(0), cross_site_url); | 236 NavigateFrameToURL(root->child_at(0), cross_site_url); |
229 EXPECT_EQ(cross_site_url, observer.navigation_url()); | 237 EXPECT_EQ(cross_site_url, observer.navigation_url()); |
230 EXPECT_TRUE(observer.navigation_succeeded()); | 238 EXPECT_TRUE(observer.navigation_succeeded()); |
231 | 239 |
232 // Ensure that we have created a new process for the subframe. | 240 // Ensure that we have created a new process for the subframe. |
233 ASSERT_EQ(1U, root->child_count()); | 241 ASSERT_EQ(1U, root->child_count()); |
234 FrameTreeNode* child = root->child_at(0); | 242 FrameTreeNode* child = root->child_at(0); |
235 SiteInstance* site_instance = child->current_frame_host()->GetSiteInstance(); | 243 SiteInstance* site_instance = child->current_frame_host()->GetSiteInstance(); |
236 RenderViewHost* rvh = child->current_frame_host()->render_view_host(); | 244 RenderViewHost* rvh = child->current_frame_host()->render_view_host(); |
237 RenderProcessHost* rph = child->current_frame_host()->GetProcess(); | 245 RenderProcessHost* rph = child->current_frame_host()->GetProcess(); |
238 EXPECT_NE(shell()->web_contents()->GetRenderViewHost(), rvh); | 246 EXPECT_NE(shell()->web_contents()->GetRenderViewHost(), rvh); |
239 EXPECT_NE(shell()->web_contents()->GetSiteInstance(), site_instance); | 247 EXPECT_NE(shell()->web_contents()->GetSiteInstance(), site_instance); |
240 EXPECT_NE(shell()->web_contents()->GetRenderProcessHost(), rph); | 248 EXPECT_NE(shell()->web_contents()->GetRenderProcessHost(), rph); |
| 249 { |
| 250 // There should be now two RenderWidgetHosts, one for each process |
| 251 // rendering a frame. |
| 252 std::set<RenderWidgetHostImpl*> widgets_set = |
| 253 static_cast<WebContentsImpl*>(shell()->web_contents()) |
| 254 ->GetRenderWidgetHostsInTree(); |
| 255 EXPECT_EQ(2U, widgets_set.size()); |
| 256 } |
241 | 257 |
242 // Load another cross-site page into the same iframe. | 258 // Load another cross-site page into the same iframe. |
243 cross_site_url = test_server()->GetURL("files/title3.html"); | 259 cross_site_url = test_server()->GetURL("files/title3.html"); |
244 std::string bar_com("bar.com"); | 260 std::string bar_com("bar.com"); |
245 replace_host.SetHostStr(bar_com); | 261 replace_host.SetHostStr(bar_com); |
246 cross_site_url = cross_site_url.ReplaceComponents(replace_host); | 262 cross_site_url = cross_site_url.ReplaceComponents(replace_host); |
247 NavigateFrameToURL(root->child_at(0), cross_site_url); | 263 NavigateFrameToURL(root->child_at(0), cross_site_url); |
248 EXPECT_EQ(cross_site_url, observer.navigation_url()); | 264 EXPECT_EQ(cross_site_url, observer.navigation_url()); |
249 EXPECT_TRUE(observer.navigation_succeeded()); | 265 EXPECT_TRUE(observer.navigation_succeeded()); |
250 | 266 |
251 // Check again that a new process is created and is different from the | 267 // Check again that a new process is created and is different from the |
252 // top level one and the previous one. | 268 // top level one and the previous one. |
253 ASSERT_EQ(1U, root->child_count()); | 269 ASSERT_EQ(1U, root->child_count()); |
254 child = root->child_at(0); | 270 child = root->child_at(0); |
255 EXPECT_NE(shell()->web_contents()->GetRenderViewHost(), | 271 EXPECT_NE(shell()->web_contents()->GetRenderViewHost(), |
256 child->current_frame_host()->render_view_host()); | 272 child->current_frame_host()->render_view_host()); |
257 EXPECT_NE(rvh, child->current_frame_host()->render_view_host()); | 273 EXPECT_NE(rvh, child->current_frame_host()->render_view_host()); |
258 EXPECT_NE(shell()->web_contents()->GetSiteInstance(), | 274 EXPECT_NE(shell()->web_contents()->GetSiteInstance(), |
259 child->current_frame_host()->GetSiteInstance()); | 275 child->current_frame_host()->GetSiteInstance()); |
260 EXPECT_NE(site_instance, | 276 EXPECT_NE(site_instance, |
261 child->current_frame_host()->GetSiteInstance()); | 277 child->current_frame_host()->GetSiteInstance()); |
262 EXPECT_NE(shell()->web_contents()->GetRenderProcessHost(), | 278 EXPECT_NE(shell()->web_contents()->GetRenderProcessHost(), |
263 child->current_frame_host()->GetProcess()); | 279 child->current_frame_host()->GetProcess()); |
264 EXPECT_NE(rph, child->current_frame_host()->GetProcess()); | 280 EXPECT_NE(rph, child->current_frame_host()->GetProcess()); |
| 281 { |
| 282 std::set<RenderWidgetHostImpl*> widgets_set = |
| 283 static_cast<WebContentsImpl*>(shell()->web_contents()) |
| 284 ->GetRenderWidgetHostsInTree(); |
| 285 EXPECT_EQ(2U, widgets_set.size()); |
| 286 } |
265 } | 287 } |
266 | 288 |
267 // Crash a subframe and ensures its children are cleared from the FrameTree. | 289 // Crash a subframe and ensures its children are cleared from the FrameTree. |
268 // See http://crbug.com/338508. | 290 // See http://crbug.com/338508. |
269 // TODO(creis): Enable this on Android when we can kill the process there. | 291 // TODO(creis): Enable this on Android when we can kill the process there. |
270 #if defined(OS_ANDROID) | 292 #if defined(OS_ANDROID) |
271 #define MAYBE_CrashSubframe DISABLED_CrashSubframe | 293 #define MAYBE_CrashSubframe DISABLED_CrashSubframe |
272 #else | 294 #else |
273 #define MAYBE_CrashSubframe CrashSubframe | 295 #define MAYBE_CrashSubframe CrashSubframe |
274 #endif | 296 #endif |
(...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
531 "server-redirect?" + client_redirect_http_url.spec())); | 553 "server-redirect?" + client_redirect_http_url.spec())); |
532 EXPECT_TRUE(NavigateIframeToURL(shell(), server_redirect_http_url, "test")); | 554 EXPECT_TRUE(NavigateIframeToURL(shell(), server_redirect_http_url, "test")); |
533 | 555 |
534 // DidFailProvisionalLoad when navigating to client_redirect_http_url. | 556 // DidFailProvisionalLoad when navigating to client_redirect_http_url. |
535 EXPECT_EQ(observer.navigation_url(), client_redirect_http_url); | 557 EXPECT_EQ(observer.navigation_url(), client_redirect_http_url); |
536 EXPECT_FALSE(observer.navigation_succeeded()); | 558 EXPECT_FALSE(observer.navigation_succeeded()); |
537 } | 559 } |
538 } | 560 } |
539 | 561 |
540 } // namespace content | 562 } // namespace content |
OLD | NEW |