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 "content/browser/site_per_process_browsertest.h" | 5 #include "content/browser/site_per_process_browsertest.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/strings/stringprintf.h" | 8 #include "base/strings/stringprintf.h" |
9 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
10 #include "content/browser/frame_host/cross_process_frame_connector.h" | 10 #include "content/browser/frame_host/cross_process_frame_connector.h" |
11 #include "content/browser/frame_host/frame_tree.h" | 11 #include "content/browser/frame_host/frame_tree.h" |
12 #include "content/browser/frame_host/navigator.h" | 12 #include "content/browser/frame_host/navigator.h" |
13 #include "content/browser/frame_host/render_frame_proxy_host.h" | 13 #include "content/browser/frame_host/render_frame_proxy_host.h" |
14 #include "content/browser/frame_host/render_widget_host_view_child_frame.h" | 14 #include "content/browser/frame_host/render_widget_host_view_child_frame.h" |
15 #include "content/browser/renderer_host/render_view_host_impl.h" | 15 #include "content/browser/renderer_host/render_view_host_impl.h" |
16 #include "content/browser/web_contents/web_contents_impl.h" | 16 #include "content/browser/web_contents/web_contents_impl.h" |
17 #include "content/public/browser/notification_observer.h" | 17 #include "content/public/browser/notification_observer.h" |
18 #include "content/public/browser/notification_service.h" | 18 #include "content/public/browser/notification_service.h" |
19 #include "content/public/browser/notification_types.h" | 19 #include "content/public/browser/notification_types.h" |
20 #include "content/public/browser/web_contents_observer.h" | |
21 #include "content/public/common/content_switches.h" | 20 #include "content/public/common/content_switches.h" |
22 #include "content/public/test/browser_test_utils.h" | 21 #include "content/public/test/browser_test_utils.h" |
23 #include "content/public/test/content_browser_test_utils.h" | 22 #include "content/public/test/content_browser_test_utils.h" |
24 #include "content/public/test/test_navigation_observer.h" | 23 #include "content/public/test/test_navigation_observer.h" |
25 #include "content/public/test/test_utils.h" | 24 #include "content/public/test/test_utils.h" |
26 #include "content/shell/browser/shell.h" | 25 #include "content/shell/browser/shell.h" |
27 #include "content/test/content_browser_test_utils_internal.h" | 26 #include "content/test/content_browser_test_utils_internal.h" |
28 #include "content/test/test_frame_navigation_observer.h" | 27 #include "content/test/test_frame_navigation_observer.h" |
29 #include "net/dns/mock_host_resolver.h" | 28 #include "net/dns/mock_host_resolver.h" |
30 #include "net/test/embedded_test_server/embedded_test_server.h" | 29 #include "net/test/embedded_test_server/embedded_test_server.h" |
31 | 30 |
32 namespace content { | 31 namespace content { |
33 | 32 |
34 class SitePerProcessWebContentsObserver: public WebContentsObserver { | |
35 public: | |
36 explicit SitePerProcessWebContentsObserver(WebContents* web_contents) | |
37 : WebContentsObserver(web_contents), | |
38 navigation_succeeded_(false) {} | |
39 ~SitePerProcessWebContentsObserver() override {} | |
40 | |
41 void DidStartProvisionalLoadForFrame(RenderFrameHost* render_frame_host, | |
42 const GURL& validated_url, | |
43 bool is_error_page, | |
44 bool is_iframe_srcdoc) override { | |
45 navigation_succeeded_ = false; | |
46 } | |
47 | |
48 void DidFailProvisionalLoad( | |
49 RenderFrameHost* render_frame_host, | |
50 const GURL& validated_url, | |
51 int error_code, | |
52 const base::string16& error_description) override { | |
53 navigation_url_ = validated_url; | |
54 navigation_succeeded_ = false; | |
55 } | |
56 | |
57 void DidCommitProvisionalLoadForFrame( | |
58 RenderFrameHost* render_frame_host, | |
59 const GURL& url, | |
60 ui::PageTransition transition_type) override { | |
61 navigation_url_ = url; | |
62 navigation_succeeded_ = true; | |
63 } | |
64 | |
65 const GURL& navigation_url() const { | |
66 return navigation_url_; | |
67 } | |
68 | |
69 int navigation_succeeded() const { return navigation_succeeded_; } | |
70 | |
71 private: | |
72 GURL navigation_url_; | |
73 bool navigation_succeeded_; | |
74 | |
75 DISALLOW_COPY_AND_ASSIGN(SitePerProcessWebContentsObserver); | |
76 }; | |
77 | |
78 class RedirectNotificationObserver : public NotificationObserver { | 33 class RedirectNotificationObserver : public NotificationObserver { |
79 public: | 34 public: |
80 // Register to listen for notifications of the given type from either a | 35 // Register to listen for notifications of the given type from either a |
81 // specific source, or from all sources if |source| is | 36 // specific source, or from all sources if |source| is |
82 // NotificationService::AllSources(). | 37 // NotificationService::AllSources(). |
83 RedirectNotificationObserver(int notification_type, | 38 RedirectNotificationObserver(int notification_type, |
84 const NotificationSource& source); | 39 const NotificationSource& source); |
85 ~RedirectNotificationObserver() override; | 40 ~RedirectNotificationObserver() override; |
86 | 41 |
87 // Wait until the specified notification occurs. If the notification was | 42 // Wait until the specified notification occurs. If the notification was |
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
231 // correct documents are committed. | 186 // correct documents are committed. |
232 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, CrossSiteIframe) { | 187 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, CrossSiteIframe) { |
233 GURL main_url(embedded_test_server()->GetURL("/site_per_process_main.html")); | 188 GURL main_url(embedded_test_server()->GetURL("/site_per_process_main.html")); |
234 NavigateToURL(shell(), main_url); | 189 NavigateToURL(shell(), main_url); |
235 | 190 |
236 // It is safe to obtain the root frame tree node here, as it doesn't change. | 191 // It is safe to obtain the root frame tree node here, as it doesn't change. |
237 FrameTreeNode* root = | 192 FrameTreeNode* root = |
238 static_cast<WebContentsImpl*>(shell()->web_contents())-> | 193 static_cast<WebContentsImpl*>(shell()->web_contents())-> |
239 GetFrameTree()->root(); | 194 GetFrameTree()->root(); |
240 | 195 |
241 SitePerProcessWebContentsObserver observer(shell()->web_contents()); | 196 TestNavigationObserver observer(shell()->web_contents()); |
242 | 197 |
243 // Load same-site page into iframe. | 198 // Load same-site page into iframe. |
244 FrameTreeNode* child = root->child_at(0); | 199 FrameTreeNode* child = root->child_at(0); |
245 GURL http_url(embedded_test_server()->GetURL("/title1.html")); | 200 GURL http_url(embedded_test_server()->GetURL("/title1.html")); |
246 NavigateFrameToURL(child, http_url); | 201 NavigateFrameToURL(child, http_url); |
247 EXPECT_EQ(http_url, observer.navigation_url()); | 202 EXPECT_EQ(http_url, observer.last_navigation_url()); |
248 EXPECT_TRUE(observer.navigation_succeeded()); | 203 EXPECT_TRUE(observer.last_navigation_succeeded()); |
249 { | 204 { |
250 // There should be only one RenderWidgetHost when there are no | 205 // There should be only one RenderWidgetHost when there are no |
251 // cross-process iframes. | 206 // cross-process iframes. |
252 std::set<RenderWidgetHostView*> views_set = | 207 std::set<RenderWidgetHostView*> views_set = |
253 static_cast<WebContentsImpl*>(shell()->web_contents()) | 208 static_cast<WebContentsImpl*>(shell()->web_contents()) |
254 ->GetRenderWidgetHostViewsInTree(); | 209 ->GetRenderWidgetHostViewsInTree(); |
255 EXPECT_EQ(1U, views_set.size()); | 210 EXPECT_EQ(1U, views_set.size()); |
256 } | 211 } |
257 RenderFrameProxyHost* proxy_to_parent = | 212 RenderFrameProxyHost* proxy_to_parent = |
258 child->render_manager()->GetRenderFrameProxyHost( | 213 child->render_manager()->GetRenderFrameProxyHost( |
259 shell()->web_contents()->GetSiteInstance()); | 214 shell()->web_contents()->GetSiteInstance()); |
260 EXPECT_FALSE(proxy_to_parent); | 215 EXPECT_FALSE(proxy_to_parent); |
261 | 216 |
262 // Load cross-site page into iframe. | 217 // Load cross-site page into iframe. |
263 GURL url = embedded_test_server()->GetURL("foo.com", "/title2.html"); | 218 GURL url = embedded_test_server()->GetURL("foo.com", "/title2.html"); |
264 NavigateFrameToURL(root->child_at(0), url); | 219 NavigateFrameToURL(root->child_at(0), url); |
265 // Verify that the navigation succeeded and the expected URL was loaded. | 220 // Verify that the navigation succeeded and the expected URL was loaded. |
266 EXPECT_TRUE(observer.navigation_succeeded()); | 221 EXPECT_TRUE(observer.last_navigation_succeeded()); |
267 EXPECT_EQ(url, observer.navigation_url()); | 222 EXPECT_EQ(url, observer.last_navigation_url()); |
268 | 223 |
269 // Ensure that we have created a new process for the subframe. | 224 // Ensure that we have created a new process for the subframe. |
270 ASSERT_EQ(2U, root->child_count()); | 225 ASSERT_EQ(2U, root->child_count()); |
271 SiteInstance* site_instance = child->current_frame_host()->GetSiteInstance(); | 226 SiteInstance* site_instance = child->current_frame_host()->GetSiteInstance(); |
272 RenderViewHost* rvh = child->current_frame_host()->render_view_host(); | 227 RenderViewHost* rvh = child->current_frame_host()->render_view_host(); |
273 RenderProcessHost* rph = child->current_frame_host()->GetProcess(); | 228 RenderProcessHost* rph = child->current_frame_host()->GetProcess(); |
274 EXPECT_NE(shell()->web_contents()->GetRenderViewHost(), rvh); | 229 EXPECT_NE(shell()->web_contents()->GetRenderViewHost(), rvh); |
275 EXPECT_NE(shell()->web_contents()->GetSiteInstance(), site_instance); | 230 EXPECT_NE(shell()->web_contents()->GetSiteInstance(), site_instance); |
276 EXPECT_NE(shell()->web_contents()->GetRenderProcessHost(), rph); | 231 EXPECT_NE(shell()->web_contents()->GetRenderProcessHost(), rph); |
277 { | 232 { |
(...skipping 10 matching lines...) Expand all Loading... | |
288 // The out-of-process iframe should have its own RenderWidgetHost, | 243 // The out-of-process iframe should have its own RenderWidgetHost, |
289 // independent of any RenderViewHost. | 244 // independent of any RenderViewHost. |
290 EXPECT_NE( | 245 EXPECT_NE( |
291 rvh->GetView(), | 246 rvh->GetView(), |
292 proxy_to_parent->cross_process_frame_connector()->get_view_for_testing()); | 247 proxy_to_parent->cross_process_frame_connector()->get_view_for_testing()); |
293 EXPECT_TRUE(child->current_frame_host()->GetRenderWidgetHost()); | 248 EXPECT_TRUE(child->current_frame_host()->GetRenderWidgetHost()); |
294 | 249 |
295 // Load another cross-site page into the same iframe. | 250 // Load another cross-site page into the same iframe. |
296 url = embedded_test_server()->GetURL("bar.com", "/title3.html"); | 251 url = embedded_test_server()->GetURL("bar.com", "/title3.html"); |
297 NavigateFrameToURL(root->child_at(0), url); | 252 NavigateFrameToURL(root->child_at(0), url); |
298 EXPECT_TRUE(observer.navigation_succeeded()); | 253 EXPECT_TRUE(observer.last_navigation_succeeded()); |
299 EXPECT_EQ(url, observer.navigation_url()); | 254 EXPECT_EQ(url, observer.last_navigation_url()); |
300 | 255 |
301 // Check again that a new process is created and is different from the | 256 // Check again that a new process is created and is different from the |
302 // top level one and the previous one. | 257 // top level one and the previous one. |
303 ASSERT_EQ(2U, root->child_count()); | 258 ASSERT_EQ(2U, root->child_count()); |
304 child = root->child_at(0); | 259 child = root->child_at(0); |
305 EXPECT_NE(shell()->web_contents()->GetRenderViewHost(), | 260 EXPECT_NE(shell()->web_contents()->GetRenderViewHost(), |
306 child->current_frame_host()->render_view_host()); | 261 child->current_frame_host()->render_view_host()); |
307 EXPECT_NE(rvh, child->current_frame_host()->render_view_host()); | 262 EXPECT_NE(rvh, child->current_frame_host()->render_view_host()); |
308 EXPECT_NE(shell()->web_contents()->GetSiteInstance(), | 263 EXPECT_NE(shell()->web_contents()->GetSiteInstance(), |
309 child->current_frame_host()->GetSiteInstance()); | 264 child->current_frame_host()->GetSiteInstance()); |
(...skipping 20 matching lines...) Expand all Loading... | |
330 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, | 285 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, |
331 DISABLED_NavigateRemoteFrame) { | 286 DISABLED_NavigateRemoteFrame) { |
332 GURL main_url(embedded_test_server()->GetURL("/site_per_process_main.html")); | 287 GURL main_url(embedded_test_server()->GetURL("/site_per_process_main.html")); |
333 NavigateToURL(shell(), main_url); | 288 NavigateToURL(shell(), main_url); |
334 | 289 |
335 // It is safe to obtain the root frame tree node here, as it doesn't change. | 290 // It is safe to obtain the root frame tree node here, as it doesn't change. |
336 FrameTreeNode* root = | 291 FrameTreeNode* root = |
337 static_cast<WebContentsImpl*>(shell()->web_contents())-> | 292 static_cast<WebContentsImpl*>(shell()->web_contents())-> |
338 GetFrameTree()->root(); | 293 GetFrameTree()->root(); |
339 | 294 |
340 SitePerProcessWebContentsObserver observer(shell()->web_contents()); | 295 TestNavigationObserver observer(shell()->web_contents()); |
341 | 296 |
342 // Load same-site page into iframe. | 297 // Load same-site page into iframe. |
343 FrameTreeNode* child = root->child_at(0); | 298 FrameTreeNode* child = root->child_at(0); |
344 GURL http_url(embedded_test_server()->GetURL("/title1.html")); | 299 GURL http_url(embedded_test_server()->GetURL("/title1.html")); |
345 NavigateFrameToURL(child, http_url); | 300 NavigateFrameToURL(child, http_url); |
346 EXPECT_EQ(http_url, observer.navigation_url()); | 301 EXPECT_EQ(http_url, observer.last_navigation_url()); |
347 EXPECT_TRUE(observer.navigation_succeeded()); | 302 EXPECT_TRUE(observer.last_navigation_succeeded()); |
348 | 303 |
349 // Load cross-site page into iframe. | 304 // Load cross-site page into iframe. |
350 GURL url = embedded_test_server()->GetURL("foo.com", "/title2.html"); | 305 GURL url = embedded_test_server()->GetURL("foo.com", "/title2.html"); |
351 NavigateFrameToURL(root->child_at(0), url); | 306 NavigateFrameToURL(root->child_at(0), url); |
352 EXPECT_TRUE(observer.navigation_succeeded()); | 307 EXPECT_TRUE(observer.last_navigation_succeeded()); |
353 EXPECT_EQ(url, observer.navigation_url()); | 308 EXPECT_EQ(url, observer.last_navigation_url()); |
354 | 309 |
355 // Ensure that we have created a new process for the subframe. | 310 // Ensure that we have created a new process for the subframe. |
356 ASSERT_EQ(2U, root->child_count()); | 311 ASSERT_EQ(2U, root->child_count()); |
357 SiteInstance* site_instance = child->current_frame_host()->GetSiteInstance(); | 312 SiteInstance* site_instance = child->current_frame_host()->GetSiteInstance(); |
358 EXPECT_NE(shell()->web_contents()->GetSiteInstance(), site_instance); | 313 EXPECT_NE(shell()->web_contents()->GetSiteInstance(), site_instance); |
359 | 314 |
360 // Emulate the main frame changing the src of the iframe such that it | 315 // Emulate the main frame changing the src of the iframe such that it |
361 // navigates cross-site. | 316 // navigates cross-site. |
362 url = embedded_test_server()->GetURL("bar.com", "/title3.html"); | 317 url = embedded_test_server()->GetURL("bar.com", "/title3.html"); |
363 NavigateIframeToURL(shell()->web_contents(), "test", url); | 318 NavigateIframeToURL(shell()->web_contents(), "test", url); |
364 EXPECT_TRUE(observer.navigation_succeeded()); | 319 EXPECT_TRUE(observer.last_navigation_succeeded()); |
365 EXPECT_EQ(url, observer.navigation_url()); | 320 EXPECT_EQ(url, observer.last_navigation_url()); |
366 | 321 |
367 // Check again that a new process is created and is different from the | 322 // Check again that a new process is created and is different from the |
368 // top level one and the previous one. | 323 // top level one and the previous one. |
369 ASSERT_EQ(2U, root->child_count()); | 324 ASSERT_EQ(2U, root->child_count()); |
370 child = root->child_at(0); | 325 child = root->child_at(0); |
371 EXPECT_NE(shell()->web_contents()->GetSiteInstance(), | 326 EXPECT_NE(shell()->web_contents()->GetSiteInstance(), |
372 child->current_frame_host()->GetSiteInstance()); | 327 child->current_frame_host()->GetSiteInstance()); |
373 EXPECT_NE(site_instance, | 328 EXPECT_NE(site_instance, |
374 child->current_frame_host()->GetSiteInstance()); | 329 child->current_frame_host()->GetSiteInstance()); |
375 | 330 |
376 // Navigate back to the parent's origin and ensure we return to the | 331 // Navigate back to the parent's origin and ensure we return to the |
377 // parent's process. | 332 // parent's process. |
378 NavigateFrameToURL(child, http_url); | 333 NavigateFrameToURL(child, http_url); |
379 EXPECT_EQ(http_url, observer.navigation_url()); | 334 EXPECT_EQ(http_url, observer.last_navigation_url()); |
380 EXPECT_TRUE(observer.navigation_succeeded()); | 335 EXPECT_TRUE(observer.last_navigation_succeeded()); |
381 EXPECT_EQ(shell()->web_contents()->GetSiteInstance(), | 336 EXPECT_EQ(shell()->web_contents()->GetSiteInstance(), |
382 child->current_frame_host()->GetSiteInstance()); | 337 child->current_frame_host()->GetSiteInstance()); |
383 } | 338 } |
384 | 339 |
385 // In A-embed-B-embed-C scenario, verify that killing process B clears proxies | 340 // In A-embed-B-embed-C scenario, verify that killing process B clears proxies |
386 // of C from the tree. | 341 // of C from the tree. |
387 // | 342 // |
388 // 1 A A | 343 // 1 A A |
389 // / \ / \ / \ . | 344 // / \ / \ / \ . |
390 // 2 3 -> B A -> Kill B -> B* A | 345 // 2 3 -> B A -> Kill B -> B* A |
391 // / / | 346 // / / |
392 // 4 C | 347 // 4 C |
393 // | 348 // |
394 // node1 is the root. | 349 // node1 is the root. |
395 // Initially, both node1.proxy_hosts_ and node3.proxy_hosts_ contain C. | 350 // Initially, both node1.proxy_hosts_ and node3.proxy_hosts_ contain C. |
396 // After we kill B, make sure proxies for C are cleared. | 351 // After we kill B, make sure proxies for C are cleared. |
397 // | 352 // |
398 // TODO(lazyboy): Once http://crbug.com/432107 is fixed, we should also make | 353 // TODO(lazyboy): Once http://crbug.com/432107 is fixed, we should also make |
399 // sure that proxies for B are not cleared when we kill B. | 354 // sure that proxies for B are not cleared when we kill B. |
400 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, | 355 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, |
401 KillingRendererClearsDescendantProxies) { | 356 KillingRendererClearsDescendantProxies) { |
402 GURL main_url( | 357 GURL main_url( |
403 embedded_test_server()->GetURL("/frame_tree/page_with_two_frames.html")); | 358 embedded_test_server()->GetURL("/frame_tree/page_with_two_frames.html")); |
404 NavigateToURL(shell(), main_url); | 359 NavigateToURL(shell(), main_url); |
405 | 360 |
406 // It is safe to obtain the root frame tree node here, as it doesn't change. | 361 // It is safe to obtain the root frame tree node here, as it doesn't change. |
407 FrameTreeNode* root = | 362 FrameTreeNode* root = |
408 static_cast<WebContentsImpl*>(shell()->web_contents())-> | 363 static_cast<WebContentsImpl*>(shell()->web_contents())-> |
409 GetFrameTree()->root(); | 364 GetFrameTree()->root(); |
410 SitePerProcessWebContentsObserver observer(shell()->web_contents()); | 365 TestNavigationObserver observer(shell()->web_contents()); |
411 | 366 |
412 ASSERT_EQ(2U, root->child_count()); | 367 ASSERT_EQ(2U, root->child_count()); |
413 | 368 |
414 // Navigate the second subframe (node3) to a local frame. | 369 // Navigate the second subframe (node3) to a local frame. |
415 GURL site_a_url(embedded_test_server()->GetURL("/title1.html")); | 370 GURL site_a_url(embedded_test_server()->GetURL("/title1.html")); |
416 NavigateFrameToURL(root->child_at(1), site_a_url); | 371 NavigateFrameToURL(root->child_at(1), site_a_url); |
417 | 372 |
418 // Navigate the first subframe (node2) to a cross-site page with two | 373 // Navigate the first subframe (node2) to a cross-site page with two |
419 // subframes. | 374 // subframes. |
420 // NavigateFrameToURL can't be used here because it doesn't guarantee that | 375 // NavigateFrameToURL can't be used here because it doesn't guarantee that |
421 // FrameTreeNodes will have been created for child frames when it returns. | 376 // FrameTreeNodes will have been created for child frames when it returns. |
422 RenderFrameHostCreatedObserver frame_observer(shell()->web_contents(), 3); | 377 RenderFrameHostCreatedObserver frame_observer(shell()->web_contents(), 3); |
423 GURL site_b_url( | 378 GURL site_b_url( |
424 embedded_test_server()->GetURL( | 379 embedded_test_server()->GetURL( |
425 "bar.com", "/frame_tree/page_with_one_frame.html")); | 380 "bar.com", "/frame_tree/page_with_one_frame.html")); |
426 NavigationController::LoadURLParams params_b(site_b_url); | 381 NavigationController::LoadURLParams params_b(site_b_url); |
427 params_b.transition_type = ui::PAGE_TRANSITION_LINK; | 382 params_b.transition_type = ui::PAGE_TRANSITION_LINK; |
428 params_b.frame_tree_node_id = root->child_at(0)->frame_tree_node_id(); | 383 params_b.frame_tree_node_id = root->child_at(0)->frame_tree_node_id(); |
429 root->child_at(0)->navigator()->GetController()->LoadURLWithParams(params_b); | 384 root->child_at(0)->navigator()->GetController()->LoadURLWithParams(params_b); |
430 frame_observer.Wait(); | 385 frame_observer.Wait(); |
431 | 386 |
432 // We can't use a SitePerProcessWebContentsObserver to verify the URL here, | 387 // We can't use a SitePerProcessWebContentsObserver to verify the URL here, |
Mostyn Bramley-Moore
2015/01/28 11:56:17
Stray reference to SitePerProcessWebContentsObserv
| |
433 // since the frame has children that may have clobbered it in the observer. | 388 // since the frame has children that may have clobbered it in the observer. |
434 EXPECT_EQ(site_b_url, root->child_at(0)->current_url()); | 389 EXPECT_EQ(site_b_url, root->child_at(0)->current_url()); |
435 | 390 |
436 // Ensure that a new process is created for node2. | 391 // Ensure that a new process is created for node2. |
437 EXPECT_NE(shell()->web_contents()->GetSiteInstance(), | 392 EXPECT_NE(shell()->web_contents()->GetSiteInstance(), |
438 root->child_at(0)->current_frame_host()->GetSiteInstance()); | 393 root->child_at(0)->current_frame_host()->GetSiteInstance()); |
439 // Ensure that a new process is *not* created for node3. | 394 // Ensure that a new process is *not* created for node3. |
440 EXPECT_EQ(shell()->web_contents()->GetSiteInstance(), | 395 EXPECT_EQ(shell()->web_contents()->GetSiteInstance(), |
441 root->child_at(1)->current_frame_host()->GetSiteInstance()); | 396 root->child_at(1)->current_frame_host()->GetSiteInstance()); |
442 | 397 |
443 ASSERT_EQ(1U, root->child_at(0)->child_count()); | 398 ASSERT_EQ(1U, root->child_at(0)->child_count()); |
444 | 399 |
445 // Navigate node4 to cross-site-page. | 400 // Navigate node4 to cross-site-page. |
446 FrameTreeNode* node4 = root->child_at(0)->child_at(0); | 401 FrameTreeNode* node4 = root->child_at(0)->child_at(0); |
447 GURL site_c_url(embedded_test_server()->GetURL("baz.com", "/title2.html")); | 402 GURL site_c_url(embedded_test_server()->GetURL("baz.com", "/title2.html")); |
448 NavigateFrameToURL(node4, site_c_url); | 403 NavigateFrameToURL(node4, site_c_url); |
449 EXPECT_TRUE(observer.navigation_succeeded()); | 404 EXPECT_TRUE(observer.last_navigation_succeeded()); |
450 EXPECT_EQ(site_c_url, observer.navigation_url()); | 405 EXPECT_EQ(site_c_url, observer.last_navigation_url()); |
451 | 406 |
452 // |site_instance_c| is expected to go away once we kill |child_process_b| | 407 // |site_instance_c| is expected to go away once we kill |child_process_b| |
453 // below, so create a local scope so we can extend the lifetime of | 408 // below, so create a local scope so we can extend the lifetime of |
454 // |site_instance_c| with a refptr. | 409 // |site_instance_c| with a refptr. |
455 { | 410 { |
456 SiteInstance* site_instance_b = | 411 SiteInstance* site_instance_b = |
457 root->child_at(0)->current_frame_host()->GetSiteInstance(); | 412 root->child_at(0)->current_frame_host()->GetSiteInstance(); |
458 scoped_refptr<SiteInstanceImpl> site_instance_c = | 413 scoped_refptr<SiteInstanceImpl> site_instance_c = |
459 node4->current_frame_host()->GetSiteInstance(); | 414 node4->current_frame_host()->GetSiteInstance(); |
460 | 415 |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
559 net::SpawnedTestServer::kLocalhost, | 514 net::SpawnedTestServer::kLocalhost, |
560 base::FilePath(FILE_PATH_LITERAL("content/test/data"))); | 515 base::FilePath(FILE_PATH_LITERAL("content/test/data"))); |
561 ASSERT_TRUE(https_server.Start()); | 516 ASSERT_TRUE(https_server.Start()); |
562 | 517 |
563 GURL main_url(test_server()->GetURL("files/site_per_process_main.html")); | 518 GURL main_url(test_server()->GetURL("files/site_per_process_main.html")); |
564 GURL http_url(test_server()->GetURL("files/title1.html")); | 519 GURL http_url(test_server()->GetURL("files/title1.html")); |
565 GURL https_url(https_server.GetURL("files/title1.html")); | 520 GURL https_url(https_server.GetURL("files/title1.html")); |
566 | 521 |
567 NavigateToURL(shell(), main_url); | 522 NavigateToURL(shell(), main_url); |
568 | 523 |
569 SitePerProcessWebContentsObserver observer(shell()->web_contents()); | 524 TestNavigationObserver observer(shell()->web_contents()); |
570 { | 525 { |
571 // Load cross-site client-redirect page into Iframe. | 526 // Load cross-site client-redirect page into Iframe. |
572 // Should be blocked. | 527 // Should be blocked. |
573 GURL client_redirect_https_url(https_server.GetURL( | 528 GURL client_redirect_https_url(https_server.GetURL( |
574 "client-redirect?files/title1.html")); | 529 "client-redirect?files/title1.html")); |
575 EXPECT_TRUE(NavigateIframeToURL(shell()->web_contents(), "test", | 530 EXPECT_TRUE(NavigateIframeToURL(shell()->web_contents(), "test", |
576 client_redirect_https_url)); | 531 client_redirect_https_url)); |
577 // DidFailProvisionalLoad when navigating to client_redirect_https_url. | 532 // DidFailProvisionalLoad when navigating to client_redirect_https_url. |
578 EXPECT_EQ(observer.navigation_url(), client_redirect_https_url); | 533 EXPECT_EQ(observer.last_navigation_url(), client_redirect_https_url); |
579 EXPECT_FALSE(observer.navigation_succeeded()); | 534 EXPECT_FALSE(observer.last_navigation_succeeded()); |
580 } | 535 } |
581 | 536 |
582 { | 537 { |
583 // Load cross-site server-redirect page into Iframe, | 538 // Load cross-site server-redirect page into Iframe, |
584 // which redirects to same-site page. | 539 // which redirects to same-site page. |
585 GURL server_redirect_http_url(https_server.GetURL( | 540 GURL server_redirect_http_url(https_server.GetURL( |
586 "server-redirect?" + http_url.spec())); | 541 "server-redirect?" + http_url.spec())); |
587 EXPECT_TRUE(NavigateIframeToURL(shell()->web_contents(), "test", | 542 EXPECT_TRUE(NavigateIframeToURL(shell()->web_contents(), "test", |
588 server_redirect_http_url)); | 543 server_redirect_http_url)); |
589 EXPECT_EQ(observer.navigation_url(), http_url); | 544 EXPECT_EQ(observer.last_navigation_url(), http_url); |
590 EXPECT_TRUE(observer.navigation_succeeded()); | 545 EXPECT_TRUE(observer.last_navigation_succeeded()); |
591 } | 546 } |
592 | 547 |
593 { | 548 { |
594 // Load cross-site server-redirect page into Iframe, | 549 // Load cross-site server-redirect page into Iframe, |
595 // which redirects to cross-site page. | 550 // which redirects to cross-site page. |
596 GURL server_redirect_http_url(https_server.GetURL( | 551 GURL server_redirect_http_url(https_server.GetURL( |
597 "server-redirect?files/title1.html")); | 552 "server-redirect?files/title1.html")); |
598 EXPECT_TRUE(NavigateIframeToURL(shell()->web_contents(), "test", | 553 EXPECT_TRUE(NavigateIframeToURL(shell()->web_contents(), "test", |
599 server_redirect_http_url)); | 554 server_redirect_http_url)); |
600 // DidFailProvisionalLoad when navigating to https_url. | 555 // DidFailProvisionalLoad when navigating to https_url. |
601 EXPECT_EQ(observer.navigation_url(), https_url); | 556 EXPECT_EQ(observer.last_navigation_url(), https_url); |
602 EXPECT_FALSE(observer.navigation_succeeded()); | 557 EXPECT_FALSE(observer.last_navigation_succeeded()); |
603 } | 558 } |
604 | 559 |
605 { | 560 { |
606 // Load same-site server-redirect page into Iframe, | 561 // Load same-site server-redirect page into Iframe, |
607 // which redirects to cross-site page. | 562 // which redirects to cross-site page. |
608 GURL server_redirect_http_url(test_server()->GetURL( | 563 GURL server_redirect_http_url(test_server()->GetURL( |
609 "server-redirect?" + https_url.spec())); | 564 "server-redirect?" + https_url.spec())); |
610 EXPECT_TRUE(NavigateIframeToURL(shell()->web_contents(), "test", | 565 EXPECT_TRUE(NavigateIframeToURL(shell()->web_contents(), "test", |
611 server_redirect_http_url)); | 566 server_redirect_http_url)); |
612 | 567 |
613 EXPECT_EQ(observer.navigation_url(), https_url); | 568 EXPECT_EQ(observer.last_navigation_url(), https_url); |
614 EXPECT_FALSE(observer.navigation_succeeded()); | 569 EXPECT_FALSE(observer.last_navigation_succeeded()); |
615 } | 570 } |
616 | 571 |
617 { | 572 { |
618 // Load same-site client-redirect page into Iframe, | 573 // Load same-site client-redirect page into Iframe, |
619 // which redirects to cross-site page. | 574 // which redirects to cross-site page. |
620 GURL client_redirect_http_url(test_server()->GetURL( | 575 GURL client_redirect_http_url(test_server()->GetURL( |
621 "client-redirect?" + https_url.spec())); | 576 "client-redirect?" + https_url.spec())); |
622 | 577 |
623 RedirectNotificationObserver load_observer2( | 578 RedirectNotificationObserver load_observer2( |
624 NOTIFICATION_LOAD_STOP, | 579 NOTIFICATION_LOAD_STOP, |
625 Source<NavigationController>( | 580 Source<NavigationController>( |
626 &shell()->web_contents()->GetController())); | 581 &shell()->web_contents()->GetController())); |
627 | 582 |
628 EXPECT_TRUE(NavigateIframeToURL(shell()->web_contents(), "test", | 583 EXPECT_TRUE(NavigateIframeToURL(shell()->web_contents(), "test", |
629 client_redirect_http_url)); | 584 client_redirect_http_url)); |
630 | 585 |
631 // Same-site Client-Redirect Page should be loaded successfully. | 586 // Same-site Client-Redirect Page should be loaded successfully. |
632 EXPECT_EQ(observer.navigation_url(), client_redirect_http_url); | 587 EXPECT_EQ(observer.last_navigation_url(), client_redirect_http_url); |
633 EXPECT_TRUE(observer.navigation_succeeded()); | 588 EXPECT_TRUE(observer.last_navigation_succeeded()); |
634 | 589 |
635 // Redirecting to Cross-site Page should be blocked. | 590 // Redirecting to Cross-site Page should be blocked. |
636 load_observer2.Wait(); | 591 load_observer2.Wait(); |
637 EXPECT_EQ(observer.navigation_url(), https_url); | 592 EXPECT_EQ(observer.last_navigation_url(), https_url); |
638 EXPECT_FALSE(observer.navigation_succeeded()); | 593 EXPECT_FALSE(observer.last_navigation_succeeded()); |
639 } | 594 } |
640 | 595 |
641 { | 596 { |
642 // Load same-site server-redirect page into Iframe, | 597 // Load same-site server-redirect page into Iframe, |
643 // which redirects to same-site page. | 598 // which redirects to same-site page. |
644 GURL server_redirect_http_url(test_server()->GetURL( | 599 GURL server_redirect_http_url(test_server()->GetURL( |
645 "server-redirect?files/title1.html")); | 600 "server-redirect?files/title1.html")); |
646 EXPECT_TRUE(NavigateIframeToURL(shell()->web_contents(), "test", | 601 EXPECT_TRUE(NavigateIframeToURL(shell()->web_contents(), "test", |
647 server_redirect_http_url)); | 602 server_redirect_http_url)); |
648 EXPECT_EQ(observer.navigation_url(), http_url); | 603 EXPECT_EQ(observer.last_navigation_url(), http_url); |
649 EXPECT_TRUE(observer.navigation_succeeded()); | 604 EXPECT_TRUE(observer.last_navigation_succeeded()); |
650 } | 605 } |
651 | 606 |
652 { | 607 { |
653 // Load same-site client-redirect page into Iframe, | 608 // Load same-site client-redirect page into Iframe, |
654 // which redirects to same-site page. | 609 // which redirects to same-site page. |
655 GURL client_redirect_http_url(test_server()->GetURL( | 610 GURL client_redirect_http_url(test_server()->GetURL( |
656 "client-redirect?" + http_url.spec())); | 611 "client-redirect?" + http_url.spec())); |
657 RedirectNotificationObserver load_observer2( | 612 RedirectNotificationObserver load_observer2( |
658 NOTIFICATION_LOAD_STOP, | 613 NOTIFICATION_LOAD_STOP, |
659 Source<NavigationController>( | 614 Source<NavigationController>( |
660 &shell()->web_contents()->GetController())); | 615 &shell()->web_contents()->GetController())); |
661 | 616 |
662 EXPECT_TRUE(NavigateIframeToURL(shell()->web_contents(), "test", | 617 EXPECT_TRUE(NavigateIframeToURL(shell()->web_contents(), "test", |
663 client_redirect_http_url)); | 618 client_redirect_http_url)); |
664 | 619 |
665 // Same-site Client-Redirect Page should be loaded successfully. | 620 // Same-site Client-Redirect Page should be loaded successfully. |
666 EXPECT_EQ(observer.navigation_url(), client_redirect_http_url); | 621 EXPECT_EQ(observer.last_navigation_url(), client_redirect_http_url); |
667 EXPECT_TRUE(observer.navigation_succeeded()); | 622 EXPECT_TRUE(observer.last_navigation_succeeded()); |
668 | 623 |
669 // Redirecting to Same-site Page should be loaded successfully. | 624 // Redirecting to Same-site Page should be loaded successfully. |
670 load_observer2.Wait(); | 625 load_observer2.Wait(); |
671 EXPECT_EQ(observer.navigation_url(), http_url); | 626 EXPECT_EQ(observer.last_navigation_url(), http_url); |
672 EXPECT_TRUE(observer.navigation_succeeded()); | 627 EXPECT_TRUE(observer.last_navigation_succeeded()); |
673 } | 628 } |
674 } | 629 } |
675 | 630 |
676 // TODO(nasko): Disable this test until out-of-process iframes is ready and the | 631 // TODO(nasko): Disable this test until out-of-process iframes is ready and the |
677 // security checks are back in place. | 632 // security checks are back in place. |
678 // TODO(creis): Replace SpawnedTestServer with host_resolver to get test to run | 633 // TODO(creis): Replace SpawnedTestServer with host_resolver to get test to run |
679 // on Android (http://crbug.com/187570). | 634 // on Android (http://crbug.com/187570). |
680 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, | 635 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, |
681 DISABLED_CrossSiteIframeRedirectTwice) { | 636 DISABLED_CrossSiteIframeRedirectTwice) { |
682 ASSERT_TRUE(test_server()->Start()); | 637 ASSERT_TRUE(test_server()->Start()); |
683 net::SpawnedTestServer https_server( | 638 net::SpawnedTestServer https_server( |
684 net::SpawnedTestServer::TYPE_HTTPS, | 639 net::SpawnedTestServer::TYPE_HTTPS, |
685 net::SpawnedTestServer::kLocalhost, | 640 net::SpawnedTestServer::kLocalhost, |
686 base::FilePath(FILE_PATH_LITERAL("content/test/data"))); | 641 base::FilePath(FILE_PATH_LITERAL("content/test/data"))); |
687 ASSERT_TRUE(https_server.Start()); | 642 ASSERT_TRUE(https_server.Start()); |
688 | 643 |
689 GURL main_url(test_server()->GetURL("files/site_per_process_main.html")); | 644 GURL main_url(test_server()->GetURL("files/site_per_process_main.html")); |
690 GURL http_url(test_server()->GetURL("files/title1.html")); | 645 GURL http_url(test_server()->GetURL("files/title1.html")); |
691 GURL https_url(https_server.GetURL("files/title1.html")); | 646 GURL https_url(https_server.GetURL("files/title1.html")); |
692 | 647 |
693 NavigateToURL(shell(), main_url); | 648 NavigateToURL(shell(), main_url); |
694 | 649 |
695 SitePerProcessWebContentsObserver observer(shell()->web_contents()); | 650 TestNavigationObserver observer(shell()->web_contents()); |
696 { | 651 { |
697 // Load client-redirect page pointing to a cross-site client-redirect page, | 652 // Load client-redirect page pointing to a cross-site client-redirect page, |
698 // which eventually redirects back to same-site page. | 653 // which eventually redirects back to same-site page. |
699 GURL client_redirect_https_url(https_server.GetURL( | 654 GURL client_redirect_https_url(https_server.GetURL( |
700 "client-redirect?" + http_url.spec())); | 655 "client-redirect?" + http_url.spec())); |
701 GURL client_redirect_http_url(test_server()->GetURL( | 656 GURL client_redirect_http_url(test_server()->GetURL( |
702 "client-redirect?" + client_redirect_https_url.spec())); | 657 "client-redirect?" + client_redirect_https_url.spec())); |
703 | 658 |
704 // We should wait until second client redirect get cancelled. | 659 // We should wait until second client redirect get cancelled. |
705 RedirectNotificationObserver load_observer2( | 660 RedirectNotificationObserver load_observer2( |
706 NOTIFICATION_LOAD_STOP, | 661 NOTIFICATION_LOAD_STOP, |
707 Source<NavigationController>( | 662 Source<NavigationController>( |
708 &shell()->web_contents()->GetController())); | 663 &shell()->web_contents()->GetController())); |
709 | 664 |
710 EXPECT_TRUE(NavigateIframeToURL(shell()->web_contents(), "test", | 665 EXPECT_TRUE(NavigateIframeToURL(shell()->web_contents(), "test", |
711 client_redirect_http_url)); | 666 client_redirect_http_url)); |
712 | 667 |
713 // DidFailProvisionalLoad when navigating to client_redirect_https_url. | 668 // DidFailProvisionalLoad when navigating to client_redirect_https_url. |
714 load_observer2.Wait(); | 669 load_observer2.Wait(); |
715 EXPECT_EQ(observer.navigation_url(), client_redirect_https_url); | 670 EXPECT_EQ(observer.last_navigation_url(), client_redirect_https_url); |
716 EXPECT_FALSE(observer.navigation_succeeded()); | 671 EXPECT_FALSE(observer.last_navigation_succeeded()); |
717 } | 672 } |
718 | 673 |
719 { | 674 { |
720 // Load server-redirect page pointing to a cross-site server-redirect page, | 675 // Load server-redirect page pointing to a cross-site server-redirect page, |
721 // which eventually redirect back to same-site page. | 676 // which eventually redirect back to same-site page. |
722 GURL server_redirect_https_url(https_server.GetURL( | 677 GURL server_redirect_https_url(https_server.GetURL( |
723 "server-redirect?" + http_url.spec())); | 678 "server-redirect?" + http_url.spec())); |
724 GURL server_redirect_http_url(test_server()->GetURL( | 679 GURL server_redirect_http_url(test_server()->GetURL( |
725 "server-redirect?" + server_redirect_https_url.spec())); | 680 "server-redirect?" + server_redirect_https_url.spec())); |
726 EXPECT_TRUE(NavigateIframeToURL(shell()->web_contents(), "test", | 681 EXPECT_TRUE(NavigateIframeToURL(shell()->web_contents(), "test", |
727 server_redirect_http_url)); | 682 server_redirect_http_url)); |
728 EXPECT_EQ(observer.navigation_url(), http_url); | 683 EXPECT_EQ(observer.last_navigation_url(), http_url); |
729 EXPECT_TRUE(observer.navigation_succeeded()); | 684 EXPECT_TRUE(observer.last_navigation_succeeded()); |
730 } | 685 } |
731 | 686 |
732 { | 687 { |
733 // Load server-redirect page pointing to a cross-site server-redirect page, | 688 // Load server-redirect page pointing to a cross-site server-redirect page, |
734 // which eventually redirects back to cross-site page. | 689 // which eventually redirects back to cross-site page. |
735 GURL server_redirect_https_url(https_server.GetURL( | 690 GURL server_redirect_https_url(https_server.GetURL( |
736 "server-redirect?" + https_url.spec())); | 691 "server-redirect?" + https_url.spec())); |
737 GURL server_redirect_http_url(test_server()->GetURL( | 692 GURL server_redirect_http_url(test_server()->GetURL( |
738 "server-redirect?" + server_redirect_https_url.spec())); | 693 "server-redirect?" + server_redirect_https_url.spec())); |
739 EXPECT_TRUE(NavigateIframeToURL(shell()->web_contents(), "test", | 694 EXPECT_TRUE(NavigateIframeToURL(shell()->web_contents(), "test", |
740 server_redirect_http_url)); | 695 server_redirect_http_url)); |
741 | 696 |
742 // DidFailProvisionalLoad when navigating to https_url. | 697 // DidFailProvisionalLoad when navigating to https_url. |
743 EXPECT_EQ(observer.navigation_url(), https_url); | 698 EXPECT_EQ(observer.last_navigation_url(), https_url); |
744 EXPECT_FALSE(observer.navigation_succeeded()); | 699 EXPECT_FALSE(observer.last_navigation_succeeded()); |
745 } | 700 } |
746 | 701 |
747 { | 702 { |
748 // Load server-redirect page pointing to a cross-site client-redirect page, | 703 // Load server-redirect page pointing to a cross-site client-redirect page, |
749 // which eventually redirects back to same-site page. | 704 // which eventually redirects back to same-site page. |
750 GURL client_redirect_http_url(https_server.GetURL( | 705 GURL client_redirect_http_url(https_server.GetURL( |
751 "client-redirect?" + http_url.spec())); | 706 "client-redirect?" + http_url.spec())); |
752 GURL server_redirect_http_url(test_server()->GetURL( | 707 GURL server_redirect_http_url(test_server()->GetURL( |
753 "server-redirect?" + client_redirect_http_url.spec())); | 708 "server-redirect?" + client_redirect_http_url.spec())); |
754 EXPECT_TRUE(NavigateIframeToURL(shell()->web_contents(), "test", | 709 EXPECT_TRUE(NavigateIframeToURL(shell()->web_contents(), "test", |
755 server_redirect_http_url)); | 710 server_redirect_http_url)); |
756 | 711 |
757 // DidFailProvisionalLoad when navigating to client_redirect_http_url. | 712 // DidFailProvisionalLoad when navigating to client_redirect_http_url. |
758 EXPECT_EQ(observer.navigation_url(), client_redirect_http_url); | 713 EXPECT_EQ(observer.last_navigation_url(), client_redirect_http_url); |
759 EXPECT_FALSE(observer.navigation_succeeded()); | 714 EXPECT_FALSE(observer.last_navigation_succeeded()); |
760 } | 715 } |
761 } | 716 } |
762 | 717 |
763 // Ensure that when navigating a frame cross-process RenderFrameProxyHosts are | 718 // Ensure that when navigating a frame cross-process RenderFrameProxyHosts are |
764 // created in the FrameTree skipping the subtree of the navigating frame. | 719 // created in the FrameTree skipping the subtree of the navigating frame. |
765 // | 720 // |
766 // Disabled on Mac due to flakiness on ASAN. http://crbug.com/425248 | 721 // Disabled on Mac due to flakiness on ASAN. http://crbug.com/425248 |
767 // Disabled on Windows due to flakiness on Win 7 bot. http://crbug.com/444563 | 722 // Disabled on Windows due to flakiness on Win 7 bot. http://crbug.com/444563 |
768 #if defined(OS_MACOSX) || defined(OS_WIN) | 723 #if defined(OS_MACOSX) || defined(OS_WIN) |
769 #define MAYBE_ProxyCreationSkipsSubtree DISABLED_ProxyCreationSkipsSubtree | 724 #define MAYBE_ProxyCreationSkipsSubtree DISABLED_ProxyCreationSkipsSubtree |
770 #else | 725 #else |
771 #define MAYBE_ProxyCreationSkipsSubtree ProxyCreationSkipsSubtree | 726 #define MAYBE_ProxyCreationSkipsSubtree ProxyCreationSkipsSubtree |
772 #endif | 727 #endif |
773 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, | 728 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, |
774 MAYBE_ProxyCreationSkipsSubtree) { | 729 MAYBE_ProxyCreationSkipsSubtree) { |
775 GURL main_url(embedded_test_server()->GetURL("/site_per_process_main.html")); | 730 GURL main_url(embedded_test_server()->GetURL("/site_per_process_main.html")); |
776 NavigateToURL(shell(), main_url); | 731 NavigateToURL(shell(), main_url); |
777 | 732 |
778 // It is safe to obtain the root frame tree node here, as it doesn't change. | 733 // It is safe to obtain the root frame tree node here, as it doesn't change. |
779 FrameTreeNode* root = | 734 FrameTreeNode* root = |
780 static_cast<WebContentsImpl*>(shell()->web_contents())-> | 735 static_cast<WebContentsImpl*>(shell()->web_contents())-> |
781 GetFrameTree()->root(); | 736 GetFrameTree()->root(); |
782 | 737 |
783 EXPECT_TRUE(root->child_at(1) != NULL); | 738 EXPECT_TRUE(root->child_at(1) != NULL); |
784 EXPECT_EQ(2U, root->child_at(1)->child_count()); | 739 EXPECT_EQ(2U, root->child_at(1)->child_count()); |
785 | 740 |
786 { | 741 { |
787 // Load same-site page into iframe. | 742 // Load same-site page into iframe. |
788 SitePerProcessWebContentsObserver observer(shell()->web_contents()); | 743 TestNavigationObserver observer(shell()->web_contents()); |
789 GURL http_url(embedded_test_server()->GetURL("/title1.html")); | 744 GURL http_url(embedded_test_server()->GetURL("/title1.html")); |
790 NavigateFrameToURL(root->child_at(0), http_url); | 745 NavigateFrameToURL(root->child_at(0), http_url); |
791 EXPECT_EQ(http_url, observer.navigation_url()); | 746 EXPECT_EQ(http_url, observer.last_navigation_url()); |
792 EXPECT_TRUE(observer.navigation_succeeded()); | 747 EXPECT_TRUE(observer.last_navigation_succeeded()); |
793 RenderFrameProxyHost* proxy_to_parent = | 748 RenderFrameProxyHost* proxy_to_parent = |
794 root->child_at(0)->render_manager()->GetRenderFrameProxyHost( | 749 root->child_at(0)->render_manager()->GetRenderFrameProxyHost( |
795 shell()->web_contents()->GetSiteInstance()); | 750 shell()->web_contents()->GetSiteInstance()); |
796 EXPECT_FALSE(proxy_to_parent); | 751 EXPECT_FALSE(proxy_to_parent); |
797 } | 752 } |
798 | 753 |
799 // Create the cross-site URL to navigate to. | 754 // Create the cross-site URL to navigate to. |
800 GURL cross_site_url = | 755 GURL cross_site_url = |
801 embedded_test_server()->GetURL("foo.com", "/frame_tree/1-1.html"); | 756 embedded_test_server()->GetURL("foo.com", "/frame_tree/1-1.html"); |
802 | 757 |
803 // Load cross-site page into the second iframe without waiting for the | 758 // Load cross-site page into the second iframe without waiting for the |
804 // navigation to complete. Once LoadURLWithParams returns, we would expect | 759 // navigation to complete. Once LoadURLWithParams returns, we would expect |
805 // proxies to have been created in the frame tree, but children of the | 760 // proxies to have been created in the frame tree, but children of the |
806 // navigating frame to still be present. The reason is that we don't run the | 761 // navigating frame to still be present. The reason is that we don't run the |
807 // message loop, so no IPCs that alter the frame tree can be processed. | 762 // message loop, so no IPCs that alter the frame tree can be processed. |
808 FrameTreeNode* child = root->child_at(1); | 763 FrameTreeNode* child = root->child_at(1); |
809 SiteInstance* site = NULL; | 764 SiteInstance* site = NULL; |
810 { | 765 { |
811 SitePerProcessWebContentsObserver observer(shell()->web_contents()); | 766 TestNavigationObserver observer(shell()->web_contents()); |
812 TestFrameNavigationObserver navigation_observer(child); | 767 TestFrameNavigationObserver navigation_observer(child); |
813 NavigationController::LoadURLParams params(cross_site_url); | 768 NavigationController::LoadURLParams params(cross_site_url); |
814 params.transition_type = PageTransitionFromInt(ui::PAGE_TRANSITION_LINK); | 769 params.transition_type = PageTransitionFromInt(ui::PAGE_TRANSITION_LINK); |
815 params.frame_tree_node_id = child->frame_tree_node_id(); | 770 params.frame_tree_node_id = child->frame_tree_node_id(); |
816 child->navigator()->GetController()->LoadURLWithParams(params); | 771 child->navigator()->GetController()->LoadURLWithParams(params); |
817 EXPECT_TRUE(child->render_manager()->pending_frame_host()); | 772 EXPECT_TRUE(child->render_manager()->pending_frame_host()); |
818 | 773 |
819 site = child->render_manager()->pending_frame_host()->GetSiteInstance(); | 774 site = child->render_manager()->pending_frame_host()->GetSiteInstance(); |
820 EXPECT_NE(shell()->web_contents()->GetSiteInstance(), site); | 775 EXPECT_NE(shell()->web_contents()->GetSiteInstance(), site); |
821 | 776 |
822 EXPECT_TRUE(root->render_manager()->GetRenderFrameProxyHost(site)); | 777 EXPECT_TRUE(root->render_manager()->GetRenderFrameProxyHost(site)); |
823 EXPECT_TRUE( | 778 EXPECT_TRUE( |
824 root->child_at(0)->render_manager()->GetRenderFrameProxyHost(site)); | 779 root->child_at(0)->render_manager()->GetRenderFrameProxyHost(site)); |
825 EXPECT_FALSE(child->render_manager()->GetRenderFrameProxyHost(site)); | 780 EXPECT_FALSE(child->render_manager()->GetRenderFrameProxyHost(site)); |
826 for (size_t i = 0; i < child->child_count(); ++i) { | 781 for (size_t i = 0; i < child->child_count(); ++i) { |
827 EXPECT_FALSE( | 782 EXPECT_FALSE( |
828 child->child_at(i)->render_manager()->GetRenderFrameProxyHost(site)); | 783 child->child_at(i)->render_manager()->GetRenderFrameProxyHost(site)); |
829 } | 784 } |
830 // Now that the verification is done, run the message loop and wait for the | 785 // Now that the verification is done, run the message loop and wait for the |
831 // navigation to complete. | 786 // navigation to complete. |
832 navigation_observer.Wait(); | 787 navigation_observer.Wait(); |
833 EXPECT_FALSE(child->render_manager()->pending_frame_host()); | 788 EXPECT_FALSE(child->render_manager()->pending_frame_host()); |
834 EXPECT_TRUE(observer.navigation_succeeded()); | 789 EXPECT_TRUE(observer.last_navigation_succeeded()); |
835 EXPECT_EQ(cross_site_url, observer.navigation_url()); | 790 EXPECT_EQ(cross_site_url, observer.last_navigation_url()); |
836 } | 791 } |
837 | 792 |
838 // Load another cross-site page into the same iframe. | 793 // Load another cross-site page into the same iframe. |
839 cross_site_url = embedded_test_server()->GetURL("bar.com", "/title2.html"); | 794 cross_site_url = embedded_test_server()->GetURL("bar.com", "/title2.html"); |
840 { | 795 { |
841 // Perform the same checks as the first cross-site navigation, since | 796 // Perform the same checks as the first cross-site navigation, since |
842 // there have been issues in subsequent cross-site navigations. Also ensure | 797 // there have been issues in subsequent cross-site navigations. Also ensure |
843 // that the SiteInstance has properly changed. | 798 // that the SiteInstance has properly changed. |
844 // TODO(nasko): Once we have proper cleanup of resources, add code to | 799 // TODO(nasko): Once we have proper cleanup of resources, add code to |
845 // verify that the intermediate SiteInstance/RenderFrameHost have been | 800 // verify that the intermediate SiteInstance/RenderFrameHost have been |
846 // properly cleaned up. | 801 // properly cleaned up. |
847 SitePerProcessWebContentsObserver observer(shell()->web_contents()); | 802 TestNavigationObserver observer(shell()->web_contents()); |
848 TestFrameNavigationObserver navigation_observer(child); | 803 TestFrameNavigationObserver navigation_observer(child); |
849 NavigationController::LoadURLParams params(cross_site_url); | 804 NavigationController::LoadURLParams params(cross_site_url); |
850 params.transition_type = PageTransitionFromInt(ui::PAGE_TRANSITION_LINK); | 805 params.transition_type = PageTransitionFromInt(ui::PAGE_TRANSITION_LINK); |
851 params.frame_tree_node_id = child->frame_tree_node_id(); | 806 params.frame_tree_node_id = child->frame_tree_node_id(); |
852 child->navigator()->GetController()->LoadURLWithParams(params); | 807 child->navigator()->GetController()->LoadURLWithParams(params); |
853 EXPECT_TRUE(child->render_manager()->pending_frame_host() != NULL); | 808 EXPECT_TRUE(child->render_manager()->pending_frame_host() != NULL); |
854 | 809 |
855 SiteInstance* site2 = | 810 SiteInstance* site2 = |
856 child->render_manager()->pending_frame_host()->GetSiteInstance(); | 811 child->render_manager()->pending_frame_host()->GetSiteInstance(); |
857 EXPECT_NE(shell()->web_contents()->GetSiteInstance(), site2); | 812 EXPECT_NE(shell()->web_contents()->GetSiteInstance(), site2); |
858 EXPECT_NE(site, site2); | 813 EXPECT_NE(site, site2); |
859 | 814 |
860 EXPECT_TRUE(root->render_manager()->GetRenderFrameProxyHost(site2)); | 815 EXPECT_TRUE(root->render_manager()->GetRenderFrameProxyHost(site2)); |
861 EXPECT_TRUE( | 816 EXPECT_TRUE( |
862 root->child_at(0)->render_manager()->GetRenderFrameProxyHost(site2)); | 817 root->child_at(0)->render_manager()->GetRenderFrameProxyHost(site2)); |
863 EXPECT_FALSE(child->render_manager()->GetRenderFrameProxyHost(site2)); | 818 EXPECT_FALSE(child->render_manager()->GetRenderFrameProxyHost(site2)); |
864 for (size_t i = 0; i < child->child_count(); ++i) { | 819 for (size_t i = 0; i < child->child_count(); ++i) { |
865 EXPECT_FALSE( | 820 EXPECT_FALSE( |
866 child->child_at(i)->render_manager()->GetRenderFrameProxyHost(site2)); | 821 child->child_at(i)->render_manager()->GetRenderFrameProxyHost(site2)); |
867 } | 822 } |
868 | 823 |
869 navigation_observer.Wait(); | 824 navigation_observer.Wait(); |
870 EXPECT_TRUE(observer.navigation_succeeded()); | 825 EXPECT_TRUE(observer.last_navigation_succeeded()); |
871 EXPECT_EQ(cross_site_url, observer.navigation_url()); | 826 EXPECT_EQ(cross_site_url, observer.last_navigation_url()); |
872 EXPECT_EQ(0U, child->child_count()); | 827 EXPECT_EQ(0U, child->child_count()); |
873 } | 828 } |
874 } | 829 } |
875 | 830 |
876 // Verify that origin replication works for an A-embed-B-embed-C hierarchy. | 831 // Verify that origin replication works for an A-embed-B-embed-C hierarchy. |
877 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, OriginReplication) { | 832 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, OriginReplication) { |
878 GURL main_url(embedded_test_server()->GetURL("/site_per_process_main.html")); | 833 GURL main_url(embedded_test_server()->GetURL("/site_per_process_main.html")); |
879 EXPECT_TRUE(NavigateToURL(shell(), main_url)); | 834 EXPECT_TRUE(NavigateToURL(shell(), main_url)); |
880 | 835 |
881 // It is safe to obtain the root frame tree node here, as it doesn't change. | 836 // It is safe to obtain the root frame tree node here, as it doesn't change. |
882 FrameTreeNode* root = static_cast<WebContentsImpl*>(shell()->web_contents()) | 837 FrameTreeNode* root = static_cast<WebContentsImpl*>(shell()->web_contents()) |
883 ->GetFrameTree() | 838 ->GetFrameTree() |
884 ->root(); | 839 ->root(); |
885 | 840 |
886 SitePerProcessWebContentsObserver observer(shell()->web_contents()); | 841 TestNavigationObserver observer(shell()->web_contents()); |
887 | 842 |
888 // Navigate the first subframe to a cross-site page with two subframes. | 843 // Navigate the first subframe to a cross-site page with two subframes. |
889 // NavigateFrameToURL can't be used here because it doesn't guarantee that | 844 // NavigateFrameToURL can't be used here because it doesn't guarantee that |
890 // FrameTreeNodes will have been created for child frames when it returns. | 845 // FrameTreeNodes will have been created for child frames when it returns. |
891 RenderFrameHostCreatedObserver frame_observer(shell()->web_contents(), 4); | 846 RenderFrameHostCreatedObserver frame_observer(shell()->web_contents(), 4); |
892 GURL foo_url( | 847 GURL foo_url( |
893 embedded_test_server()->GetURL("foo.com", "/frame_tree/1-1.html")); | 848 embedded_test_server()->GetURL("foo.com", "/frame_tree/1-1.html")); |
894 NavigationController::LoadURLParams params(foo_url); | 849 NavigationController::LoadURLParams params(foo_url); |
895 params.transition_type = ui::PAGE_TRANSITION_LINK; | 850 params.transition_type = ui::PAGE_TRANSITION_LINK; |
896 params.frame_tree_node_id = root->child_at(0)->frame_tree_node_id(); | 851 params.frame_tree_node_id = root->child_at(0)->frame_tree_node_id(); |
897 root->child_at(0)->navigator()->GetController()->LoadURLWithParams(params); | 852 root->child_at(0)->navigator()->GetController()->LoadURLWithParams(params); |
898 frame_observer.Wait(); | 853 frame_observer.Wait(); |
899 | 854 |
900 // We can't use a SitePerProcessWebContentsObserver to verify the URL here, | 855 // We can't use a SitePerProcessWebContentsObserver to verify the URL here, |
Mostyn Bramley-Moore
2015/01/28 11:56:17
Stray reference to SitePerProcessWebContentsObserv
| |
901 // since the frame has children that may have clobbered it in the observer. | 856 // since the frame has children that may have clobbered it in the observer. |
902 EXPECT_EQ(foo_url, root->child_at(0)->current_url()); | 857 EXPECT_EQ(foo_url, root->child_at(0)->current_url()); |
903 | 858 |
904 // Ensure that a new process is created for the subframe. | 859 // Ensure that a new process is created for the subframe. |
905 EXPECT_NE(shell()->web_contents()->GetSiteInstance(), | 860 EXPECT_NE(shell()->web_contents()->GetSiteInstance(), |
906 root->child_at(0)->current_frame_host()->GetSiteInstance()); | 861 root->child_at(0)->current_frame_host()->GetSiteInstance()); |
907 | 862 |
908 // Load cross-site page into subframe's subframe. | 863 // Load cross-site page into subframe's subframe. |
909 ASSERT_EQ(2U, root->child_at(0)->child_count()); | 864 ASSERT_EQ(2U, root->child_at(0)->child_count()); |
910 GURL bar_url(embedded_test_server()->GetURL("bar.com", "/title1.html")); | 865 GURL bar_url(embedded_test_server()->GetURL("bar.com", "/title1.html")); |
911 NavigateFrameToURL(root->child_at(0)->child_at(0), bar_url); | 866 NavigateFrameToURL(root->child_at(0)->child_at(0), bar_url); |
912 EXPECT_TRUE(observer.navigation_succeeded()); | 867 EXPECT_TRUE(observer.last_navigation_succeeded()); |
913 EXPECT_EQ(bar_url, observer.navigation_url()); | 868 EXPECT_EQ(bar_url, observer.last_navigation_url()); |
914 | 869 |
915 // Check that a new process is created and is different from the top one and | 870 // Check that a new process is created and is different from the top one and |
916 // the middle one. | 871 // the middle one. |
917 FrameTreeNode* bottom_child = root->child_at(0)->child_at(0); | 872 FrameTreeNode* bottom_child = root->child_at(0)->child_at(0); |
918 EXPECT_NE(shell()->web_contents()->GetSiteInstance(), | 873 EXPECT_NE(shell()->web_contents()->GetSiteInstance(), |
919 bottom_child->current_frame_host()->GetSiteInstance()); | 874 bottom_child->current_frame_host()->GetSiteInstance()); |
920 EXPECT_NE(root->child_at(0)->current_frame_host()->GetSiteInstance(), | 875 EXPECT_NE(root->child_at(0)->current_frame_host()->GetSiteInstance(), |
921 bottom_child->current_frame_host()->GetSiteInstance()); | 876 bottom_child->current_frame_host()->GetSiteInstance()); |
922 | 877 |
923 // Check that foo.com frame's location.ancestorOrigins contains the correct | 878 // Check that foo.com frame's location.ancestorOrigins contains the correct |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
962 // Verify that a child frame can retrieve the name property set by its parent. | 917 // Verify that a child frame can retrieve the name property set by its parent. |
963 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, WindowNameReplication) { | 918 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, WindowNameReplication) { |
964 GURL main_url(embedded_test_server()->GetURL("/frame_tree/2-4.html")); | 919 GURL main_url(embedded_test_server()->GetURL("/frame_tree/2-4.html")); |
965 EXPECT_TRUE(NavigateToURL(shell(), main_url)); | 920 EXPECT_TRUE(NavigateToURL(shell(), main_url)); |
966 | 921 |
967 // It is safe to obtain the root frame tree node here, as it doesn't change. | 922 // It is safe to obtain the root frame tree node here, as it doesn't change. |
968 FrameTreeNode* root = static_cast<WebContentsImpl*>(shell()->web_contents()) | 923 FrameTreeNode* root = static_cast<WebContentsImpl*>(shell()->web_contents()) |
969 ->GetFrameTree() | 924 ->GetFrameTree() |
970 ->root(); | 925 ->root(); |
971 | 926 |
972 SitePerProcessWebContentsObserver observer(shell()->web_contents()); | 927 TestNavigationObserver observer(shell()->web_contents()); |
973 | 928 |
974 // Load cross-site page into iframe. | 929 // Load cross-site page into iframe. |
975 GURL frame_url = | 930 GURL frame_url = |
976 embedded_test_server()->GetURL("foo.com", "/frame_tree/3-1.html"); | 931 embedded_test_server()->GetURL("foo.com", "/frame_tree/3-1.html"); |
977 NavigateFrameToURL(root->child_at(0), frame_url); | 932 NavigateFrameToURL(root->child_at(0), frame_url); |
978 EXPECT_TRUE(observer.navigation_succeeded()); | 933 EXPECT_TRUE(observer.last_navigation_succeeded()); |
979 EXPECT_EQ(frame_url, observer.navigation_url()); | 934 EXPECT_EQ(frame_url, observer.last_navigation_url()); |
980 | 935 |
981 // Ensure that a new process is created for the subframe. | 936 // Ensure that a new process is created for the subframe. |
982 EXPECT_NE(shell()->web_contents()->GetSiteInstance(), | 937 EXPECT_NE(shell()->web_contents()->GetSiteInstance(), |
983 root->child_at(0)->current_frame_host()->GetSiteInstance()); | 938 root->child_at(0)->current_frame_host()->GetSiteInstance()); |
984 | 939 |
985 // Check that the window.name seen by the frame matches the name attribute | 940 // Check that the window.name seen by the frame matches the name attribute |
986 // specified by its parent in the iframe tag. | 941 // specified by its parent in the iframe tag. |
987 std::string result; | 942 std::string result; |
988 EXPECT_TRUE(ExecuteScriptAndExtractString( | 943 EXPECT_TRUE(ExecuteScriptAndExtractString( |
989 root->child_at(0)->current_frame_host(), | 944 root->child_at(0)->current_frame_host(), |
(...skipping 11 matching lines...) Expand all Loading... | |
1001 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, | 956 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, |
1002 DISABLED_NavigateRemoteToDataURL) { | 957 DISABLED_NavigateRemoteToDataURL) { |
1003 GURL main_url(embedded_test_server()->GetURL("/site_per_process_main.html")); | 958 GURL main_url(embedded_test_server()->GetURL("/site_per_process_main.html")); |
1004 NavigateToURL(shell(), main_url); | 959 NavigateToURL(shell(), main_url); |
1005 | 960 |
1006 // It is safe to obtain the root frame tree node here, as it doesn't change. | 961 // It is safe to obtain the root frame tree node here, as it doesn't change. |
1007 FrameTreeNode* root = static_cast<WebContentsImpl*>(shell()->web_contents()) | 962 FrameTreeNode* root = static_cast<WebContentsImpl*>(shell()->web_contents()) |
1008 ->GetFrameTree() | 963 ->GetFrameTree() |
1009 ->root(); | 964 ->root(); |
1010 | 965 |
1011 SitePerProcessWebContentsObserver observer(shell()->web_contents()); | 966 TestNavigationObserver observer(shell()->web_contents()); |
1012 | 967 |
1013 // Load cross-site page into iframe. | 968 // Load cross-site page into iframe. |
1014 GURL url = embedded_test_server()->GetURL("foo.com", "/title1.html"); | 969 GURL url = embedded_test_server()->GetURL("foo.com", "/title1.html"); |
1015 NavigateFrameToURL(root->child_at(0), url); | 970 NavigateFrameToURL(root->child_at(0), url); |
1016 EXPECT_TRUE(observer.navigation_succeeded()); | 971 EXPECT_TRUE(observer.last_navigation_succeeded()); |
1017 EXPECT_EQ(url, observer.navigation_url()); | 972 EXPECT_EQ(url, observer.last_navigation_url()); |
1018 | 973 |
1019 // Ensure that we have created a new process for the subframe. | 974 // Ensure that we have created a new process for the subframe. |
1020 EXPECT_NE(shell()->web_contents()->GetSiteInstance(), | 975 EXPECT_NE(shell()->web_contents()->GetSiteInstance(), |
1021 root->child_at(0)->current_frame_host()->GetSiteInstance()); | 976 root->child_at(0)->current_frame_host()->GetSiteInstance()); |
1022 | 977 |
1023 // Navigate iframe to a data URL. The navigation happens from a script in the | 978 // Navigate iframe to a data URL. The navigation happens from a script in the |
1024 // parent frame, so the data URL should be committed in the same SiteInstance | 979 // parent frame, so the data URL should be committed in the same SiteInstance |
1025 // as the parent frame. | 980 // as the parent frame. |
1026 GURL data_url("data:text/html,dataurl"); | 981 GURL data_url("data:text/html,dataurl"); |
1027 std::string script = base::StringPrintf( | 982 std::string script = base::StringPrintf( |
1028 "setTimeout(function() {" | 983 "setTimeout(function() {" |
1029 "var iframe = document.getElementById('test');" | 984 "var iframe = document.getElementById('test');" |
1030 "iframe.onload = function() { document.title = 'LOADED'; };" | 985 "iframe.onload = function() { document.title = 'LOADED'; };" |
1031 "iframe.src=\"%s\";" | 986 "iframe.src=\"%s\";" |
1032 "},0);", | 987 "},0);", |
1033 data_url.spec().c_str()); | 988 data_url.spec().c_str()); |
1034 base::string16 passed_string(base::UTF8ToUTF16("LOADED")); | 989 base::string16 passed_string(base::UTF8ToUTF16("LOADED")); |
1035 TitleWatcher title_watcher(shell()->web_contents(), passed_string); | 990 TitleWatcher title_watcher(shell()->web_contents(), passed_string); |
1036 EXPECT_TRUE(ExecuteScript(shell()->web_contents(), script)); | 991 EXPECT_TRUE(ExecuteScript(shell()->web_contents(), script)); |
1037 EXPECT_EQ(title_watcher.WaitAndGetTitle(), passed_string); | 992 EXPECT_EQ(title_watcher.WaitAndGetTitle(), passed_string); |
1038 EXPECT_TRUE(observer.navigation_succeeded()); | 993 EXPECT_TRUE(observer.last_navigation_succeeded()); |
1039 EXPECT_EQ(data_url, observer.navigation_url()); | 994 EXPECT_EQ(data_url, observer.last_navigation_url()); |
1040 | 995 |
1041 // Ensure that we have navigated using the top level process. | 996 // Ensure that we have navigated using the top level process. |
1042 EXPECT_EQ(shell()->web_contents()->GetSiteInstance(), | 997 EXPECT_EQ(shell()->web_contents()->GetSiteInstance(), |
1043 root->child_at(0)->current_frame_host()->GetSiteInstance()); | 998 root->child_at(0)->current_frame_host()->GetSiteInstance()); |
1044 } | 999 } |
1045 | 1000 |
1046 // TODO(lfg): Merge the test below with NavigateRemoteFrame test. | 1001 // TODO(lfg): Merge the test below with NavigateRemoteFrame test. |
1047 // Disabled due to the same reason as NavigateRemoteToDataURL. | 1002 // Disabled due to the same reason as NavigateRemoteToDataURL. |
1048 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, | 1003 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, |
1049 DISABLED_NavigateRemoteToBlankURL) { | 1004 DISABLED_NavigateRemoteToBlankURL) { |
1050 GURL main_url(embedded_test_server()->GetURL("/site_per_process_main.html")); | 1005 GURL main_url(embedded_test_server()->GetURL("/site_per_process_main.html")); |
1051 NavigateToURL(shell(), main_url); | 1006 NavigateToURL(shell(), main_url); |
1052 | 1007 |
1053 // It is safe to obtain the root frame tree node here, as it doesn't change. | 1008 // It is safe to obtain the root frame tree node here, as it doesn't change. |
1054 FrameTreeNode* root = static_cast<WebContentsImpl*>(shell()->web_contents()) | 1009 FrameTreeNode* root = static_cast<WebContentsImpl*>(shell()->web_contents()) |
1055 ->GetFrameTree() | 1010 ->GetFrameTree() |
1056 ->root(); | 1011 ->root(); |
1057 | 1012 |
1058 SitePerProcessWebContentsObserver observer(shell()->web_contents()); | 1013 TestNavigationObserver observer(shell()->web_contents()); |
1059 | 1014 |
1060 // Load cross-site page into iframe. | 1015 // Load cross-site page into iframe. |
1061 GURL url = embedded_test_server()->GetURL("foo.com", "/title1.html"); | 1016 GURL url = embedded_test_server()->GetURL("foo.com", "/title1.html"); |
1062 NavigateFrameToURL(root->child_at(0), url); | 1017 NavigateFrameToURL(root->child_at(0), url); |
1063 EXPECT_TRUE(observer.navigation_succeeded()); | 1018 EXPECT_TRUE(observer.last_navigation_succeeded()); |
1064 EXPECT_EQ(url, observer.navigation_url()); | 1019 EXPECT_EQ(url, observer.last_navigation_url()); |
1065 | 1020 |
1066 // Ensure that we have created a new process for the subframe. | 1021 // Ensure that we have created a new process for the subframe. |
1067 EXPECT_NE(shell()->web_contents()->GetSiteInstance(), | 1022 EXPECT_NE(shell()->web_contents()->GetSiteInstance(), |
1068 root->child_at(0)->current_frame_host()->GetSiteInstance()); | 1023 root->child_at(0)->current_frame_host()->GetSiteInstance()); |
1069 | 1024 |
1070 // Navigate iframe to about:blank. The navigation happens from a script in the | 1025 // Navigate iframe to about:blank. The navigation happens from a script in the |
1071 // parent frame, so it should be committed in the same SiteInstance as the | 1026 // parent frame, so it should be committed in the same SiteInstance as the |
1072 // parent frame. | 1027 // parent frame. |
1073 GURL about_blank_url("about:blank"); | 1028 GURL about_blank_url("about:blank"); |
1074 std::string script = base::StringPrintf( | 1029 std::string script = base::StringPrintf( |
1075 "setTimeout(function() {" | 1030 "setTimeout(function() {" |
1076 "var iframe = document.getElementById('test');" | 1031 "var iframe = document.getElementById('test');" |
1077 "iframe.onload = function() { document.title = 'LOADED'; };" | 1032 "iframe.onload = function() { document.title = 'LOADED'; };" |
1078 "iframe.src=\"%s\";" | 1033 "iframe.src=\"%s\";" |
1079 "},0);", | 1034 "},0);", |
1080 about_blank_url.spec().c_str()); | 1035 about_blank_url.spec().c_str()); |
1081 base::string16 passed_string(base::UTF8ToUTF16("LOADED")); | 1036 base::string16 passed_string(base::UTF8ToUTF16("LOADED")); |
1082 TitleWatcher title_watcher(shell()->web_contents(), passed_string); | 1037 TitleWatcher title_watcher(shell()->web_contents(), passed_string); |
1083 EXPECT_TRUE(ExecuteScript(shell()->web_contents(), script)); | 1038 EXPECT_TRUE(ExecuteScript(shell()->web_contents(), script)); |
1084 EXPECT_EQ(title_watcher.WaitAndGetTitle(), passed_string); | 1039 EXPECT_EQ(title_watcher.WaitAndGetTitle(), passed_string); |
1085 EXPECT_TRUE(observer.navigation_succeeded()); | 1040 EXPECT_TRUE(observer.last_navigation_succeeded()); |
1086 EXPECT_EQ(about_blank_url, observer.navigation_url()); | 1041 EXPECT_EQ(about_blank_url, observer.last_navigation_url()); |
1087 | 1042 |
1088 // Ensure that we have navigated using the top level process. | 1043 // Ensure that we have navigated using the top level process. |
1089 EXPECT_EQ(shell()->web_contents()->GetSiteInstance(), | 1044 EXPECT_EQ(shell()->web_contents()->GetSiteInstance(), |
1090 root->child_at(0)->current_frame_host()->GetSiteInstance()); | 1045 root->child_at(0)->current_frame_host()->GetSiteInstance()); |
1091 } | 1046 } |
1092 | 1047 |
1093 // Ensure that navigating subframes in --site-per-process mode properly fires | 1048 // Ensure that navigating subframes in --site-per-process mode properly fires |
1094 // the DidStopLoading event on WebContentsObserver. | 1049 // the DidStopLoading event on WebContentsObserver. |
1095 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, CrossSiteDidStopLoading) { | 1050 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, CrossSiteDidStopLoading) { |
1096 GURL main_url(embedded_test_server()->GetURL("/site_per_process_main.html")); | 1051 GURL main_url(embedded_test_server()->GetURL("/site_per_process_main.html")); |
1097 NavigateToURL(shell(), main_url); | 1052 NavigateToURL(shell(), main_url); |
1098 | 1053 |
1099 // It is safe to obtain the root frame tree node here, as it doesn't change. | 1054 // It is safe to obtain the root frame tree node here, as it doesn't change. |
1100 FrameTreeNode* root = | 1055 FrameTreeNode* root = |
1101 static_cast<WebContentsImpl*>(shell()->web_contents())-> | 1056 static_cast<WebContentsImpl*>(shell()->web_contents())-> |
1102 GetFrameTree()->root(); | 1057 GetFrameTree()->root(); |
1103 | 1058 |
1104 SitePerProcessWebContentsObserver observer(shell()->web_contents()); | 1059 TestNavigationObserver observer(shell()->web_contents()); |
1105 | 1060 |
1106 // Load same-site page into iframe. | 1061 // Load same-site page into iframe. |
1107 FrameTreeNode* child = root->child_at(0); | 1062 FrameTreeNode* child = root->child_at(0); |
1108 GURL http_url(embedded_test_server()->GetURL("/title1.html")); | 1063 GURL http_url(embedded_test_server()->GetURL("/title1.html")); |
1109 NavigateFrameToURL(child, http_url); | 1064 NavigateFrameToURL(child, http_url); |
1110 EXPECT_EQ(http_url, observer.navigation_url()); | 1065 EXPECT_EQ(http_url, observer.last_navigation_url()); |
1111 EXPECT_TRUE(observer.navigation_succeeded()); | 1066 EXPECT_TRUE(observer.last_navigation_succeeded()); |
1112 | 1067 |
1113 // Load cross-site page into iframe. | 1068 // Load cross-site page into iframe. |
1114 TestNavigationObserver nav_observer(shell()->web_contents(), 1); | 1069 TestNavigationObserver nav_observer(shell()->web_contents(), 1); |
1115 GURL url = embedded_test_server()->GetURL("foo.com", "/title2.html"); | 1070 GURL url = embedded_test_server()->GetURL("foo.com", "/title2.html"); |
1116 NavigationController::LoadURLParams params(url); | 1071 NavigationController::LoadURLParams params(url); |
1117 params.transition_type = ui::PAGE_TRANSITION_LINK; | 1072 params.transition_type = ui::PAGE_TRANSITION_LINK; |
1118 params.frame_tree_node_id = child->frame_tree_node_id(); | 1073 params.frame_tree_node_id = child->frame_tree_node_id(); |
1119 child->navigator()->GetController()->LoadURLWithParams(params); | 1074 child->navigator()->GetController()->LoadURLWithParams(params); |
1120 nav_observer.Wait(); | 1075 nav_observer.Wait(); |
1121 | 1076 |
1122 // Verify that the navigation succeeded and the expected URL was loaded. | 1077 // Verify that the navigation succeeded and the expected URL was loaded. |
1123 EXPECT_TRUE(observer.navigation_succeeded()); | 1078 EXPECT_TRUE(observer.last_navigation_succeeded()); |
1124 EXPECT_EQ(url, observer.navigation_url()); | 1079 EXPECT_EQ(url, observer.last_navigation_url()); |
1125 } | 1080 } |
1126 | 1081 |
1127 } // namespace content | 1082 } // namespace content |
OLD | NEW |