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 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 { | 219 { |
220 // There should be only one RenderWidgetHost when there are no | 220 // There should be only one RenderWidgetHost when there are no |
221 // cross-process iframes. | 221 // cross-process iframes. |
222 std::set<RenderWidgetHostImpl*> widgets_set = | 222 std::set<RenderWidgetHostView*> views_set = |
223 static_cast<WebContentsImpl*>(shell()->web_contents()) | 223 static_cast<WebContentsImpl*>(shell()->web_contents()) |
224 ->GetRenderWidgetHostsInTree(); | 224 ->GetRenderWidgetHostViewsInTree(); |
225 EXPECT_EQ(1U, widgets_set.size()); | 225 EXPECT_EQ(1U, views_set.size()); |
226 } | 226 } |
227 | 227 |
228 // These must stay in scope with replace_host. | 228 // These must stay in scope with replace_host. |
229 GURL::Replacements replace_host; | 229 GURL::Replacements replace_host; |
230 std::string foo_com("foo.com"); | 230 std::string foo_com("foo.com"); |
231 | 231 |
232 // Load cross-site page into iframe. | 232 // Load cross-site page into iframe. |
233 GURL cross_site_url(test_server()->GetURL("files/title2.html")); | 233 GURL cross_site_url(test_server()->GetURL("files/title2.html")); |
234 replace_host.SetHostStr(foo_com); | 234 replace_host.SetHostStr(foo_com); |
235 cross_site_url = cross_site_url.ReplaceComponents(replace_host); | 235 cross_site_url = cross_site_url.ReplaceComponents(replace_host); |
236 NavigateFrameToURL(root->child_at(0), cross_site_url); | 236 NavigateFrameToURL(root->child_at(0), cross_site_url); |
237 EXPECT_EQ(cross_site_url, observer.navigation_url()); | 237 EXPECT_EQ(cross_site_url, observer.navigation_url()); |
238 EXPECT_TRUE(observer.navigation_succeeded()); | 238 EXPECT_TRUE(observer.navigation_succeeded()); |
239 | 239 |
240 // Ensure that we have created a new process for the subframe. | 240 // Ensure that we have created a new process for the subframe. |
241 ASSERT_EQ(1U, root->child_count()); | 241 ASSERT_EQ(1U, root->child_count()); |
242 FrameTreeNode* child = root->child_at(0); | 242 FrameTreeNode* child = root->child_at(0); |
243 SiteInstance* site_instance = child->current_frame_host()->GetSiteInstance(); | 243 SiteInstance* site_instance = child->current_frame_host()->GetSiteInstance(); |
244 RenderViewHost* rvh = child->current_frame_host()->render_view_host(); | 244 RenderViewHost* rvh = child->current_frame_host()->render_view_host(); |
245 RenderProcessHost* rph = child->current_frame_host()->GetProcess(); | 245 RenderProcessHost* rph = child->current_frame_host()->GetProcess(); |
246 EXPECT_NE(shell()->web_contents()->GetRenderViewHost(), rvh); | 246 EXPECT_NE(shell()->web_contents()->GetRenderViewHost(), rvh); |
247 EXPECT_NE(shell()->web_contents()->GetSiteInstance(), site_instance); | 247 EXPECT_NE(shell()->web_contents()->GetSiteInstance(), site_instance); |
248 EXPECT_NE(shell()->web_contents()->GetRenderProcessHost(), rph); | 248 EXPECT_NE(shell()->web_contents()->GetRenderProcessHost(), rph); |
249 { | 249 { |
250 // There should be now two RenderWidgetHosts, one for each process | 250 // There should be now two RenderWidgetHosts, one for each process |
251 // rendering a frame. | 251 // rendering a frame. |
252 std::set<RenderWidgetHostImpl*> widgets_set = | 252 std::set<RenderWidgetHostView*> views_set = |
253 static_cast<WebContentsImpl*>(shell()->web_contents()) | 253 static_cast<WebContentsImpl*>(shell()->web_contents()) |
254 ->GetRenderWidgetHostsInTree(); | 254 ->GetRenderWidgetHostViewsInTree(); |
255 EXPECT_EQ(2U, widgets_set.size()); | 255 EXPECT_EQ(2U, views_set.size()); |
256 } | 256 } |
257 | 257 |
258 // Load another cross-site page into the same iframe. | 258 // Load another cross-site page into the same iframe. |
259 cross_site_url = test_server()->GetURL("files/title3.html"); | 259 cross_site_url = test_server()->GetURL("files/title3.html"); |
260 std::string bar_com("bar.com"); | 260 std::string bar_com("bar.com"); |
261 replace_host.SetHostStr(bar_com); | 261 replace_host.SetHostStr(bar_com); |
262 cross_site_url = cross_site_url.ReplaceComponents(replace_host); | 262 cross_site_url = cross_site_url.ReplaceComponents(replace_host); |
263 NavigateFrameToURL(root->child_at(0), cross_site_url); | 263 NavigateFrameToURL(root->child_at(0), cross_site_url); |
264 EXPECT_EQ(cross_site_url, observer.navigation_url()); | 264 EXPECT_EQ(cross_site_url, observer.navigation_url()); |
265 EXPECT_TRUE(observer.navigation_succeeded()); | 265 EXPECT_TRUE(observer.navigation_succeeded()); |
266 | 266 |
267 // 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 |
268 // top level one and the previous one. | 268 // top level one and the previous one. |
269 ASSERT_EQ(1U, root->child_count()); | 269 ASSERT_EQ(1U, root->child_count()); |
270 child = root->child_at(0); | 270 child = root->child_at(0); |
271 EXPECT_NE(shell()->web_contents()->GetRenderViewHost(), | 271 EXPECT_NE(shell()->web_contents()->GetRenderViewHost(), |
272 child->current_frame_host()->render_view_host()); | 272 child->current_frame_host()->render_view_host()); |
273 EXPECT_NE(rvh, child->current_frame_host()->render_view_host()); | 273 EXPECT_NE(rvh, child->current_frame_host()->render_view_host()); |
274 EXPECT_NE(shell()->web_contents()->GetSiteInstance(), | 274 EXPECT_NE(shell()->web_contents()->GetSiteInstance(), |
275 child->current_frame_host()->GetSiteInstance()); | 275 child->current_frame_host()->GetSiteInstance()); |
276 EXPECT_NE(site_instance, | 276 EXPECT_NE(site_instance, |
277 child->current_frame_host()->GetSiteInstance()); | 277 child->current_frame_host()->GetSiteInstance()); |
278 EXPECT_NE(shell()->web_contents()->GetRenderProcessHost(), | 278 EXPECT_NE(shell()->web_contents()->GetRenderProcessHost(), |
279 child->current_frame_host()->GetProcess()); | 279 child->current_frame_host()->GetProcess()); |
280 EXPECT_NE(rph, child->current_frame_host()->GetProcess()); | 280 EXPECT_NE(rph, child->current_frame_host()->GetProcess()); |
281 { | 281 { |
282 std::set<RenderWidgetHostImpl*> widgets_set = | 282 std::set<RenderWidgetHostView*> views_set = |
283 static_cast<WebContentsImpl*>(shell()->web_contents()) | 283 static_cast<WebContentsImpl*>(shell()->web_contents()) |
284 ->GetRenderWidgetHostsInTree(); | 284 ->GetRenderWidgetHostViewsInTree(); |
285 EXPECT_EQ(2U, widgets_set.size()); | 285 EXPECT_EQ(2U, views_set.size()); |
286 } | 286 } |
287 } | 287 } |
288 | 288 |
289 // 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. |
290 // See http://crbug.com/338508. | 290 // See http://crbug.com/338508. |
291 // 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. |
292 #if defined(OS_ANDROID) | 292 #if defined(OS_ANDROID) |
293 #define MAYBE_CrashSubframe DISABLED_CrashSubframe | 293 #define MAYBE_CrashSubframe DISABLED_CrashSubframe |
294 #else | 294 #else |
295 #define MAYBE_CrashSubframe CrashSubframe | 295 #define MAYBE_CrashSubframe CrashSubframe |
(...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
553 "server-redirect?" + client_redirect_http_url.spec())); | 553 "server-redirect?" + client_redirect_http_url.spec())); |
554 EXPECT_TRUE(NavigateIframeToURL(shell(), server_redirect_http_url, "test")); | 554 EXPECT_TRUE(NavigateIframeToURL(shell(), server_redirect_http_url, "test")); |
555 | 555 |
556 // DidFailProvisionalLoad when navigating to client_redirect_http_url. | 556 // DidFailProvisionalLoad when navigating to client_redirect_http_url. |
557 EXPECT_EQ(observer.navigation_url(), client_redirect_http_url); | 557 EXPECT_EQ(observer.navigation_url(), client_redirect_http_url); |
558 EXPECT_FALSE(observer.navigation_succeeded()); | 558 EXPECT_FALSE(observer.navigation_succeeded()); |
559 } | 559 } |
560 } | 560 } |
561 | 561 |
562 } // namespace content | 562 } // namespace content |
OLD | NEW |