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 "content/browser/frame_host/cross_process_frame_connector.h" | 10 #include "content/browser/frame_host/cross_process_frame_connector.h" |
10 #include "content/browser/frame_host/frame_tree.h" | 11 #include "content/browser/frame_host/frame_tree.h" |
11 #include "content/browser/frame_host/navigator.h" | 12 #include "content/browser/frame_host/navigator.h" |
12 #include "content/browser/frame_host/render_frame_proxy_host.h" | 13 #include "content/browser/frame_host/render_frame_proxy_host.h" |
13 #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" |
14 #include "content/browser/renderer_host/render_view_host_impl.h" | 15 #include "content/browser/renderer_host/render_view_host_impl.h" |
15 #include "content/browser/web_contents/web_contents_impl.h" | 16 #include "content/browser/web_contents/web_contents_impl.h" |
16 #include "content/public/browser/notification_observer.h" | 17 #include "content/public/browser/notification_observer.h" |
17 #include "content/public/browser/notification_service.h" | 18 #include "content/public/browser/notification_service.h" |
18 #include "content/public/browser/notification_types.h" | 19 #include "content/public/browser/notification_types.h" |
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
207 SitePerProcessBrowserTest::SitePerProcessBrowserTest() { | 208 SitePerProcessBrowserTest::SitePerProcessBrowserTest() { |
208 }; | 209 }; |
209 | 210 |
210 void SitePerProcessBrowserTest::StartFrameAtDataURL() { | 211 void SitePerProcessBrowserTest::StartFrameAtDataURL() { |
211 std::string data_url_script = | 212 std::string data_url_script = |
212 "var iframes = document.getElementById('test');iframes.src=" | 213 "var iframes = document.getElementById('test');iframes.src=" |
213 "'data:text/html,dataurl';"; | 214 "'data:text/html,dataurl';"; |
214 ASSERT_TRUE(ExecuteScript(shell()->web_contents(), data_url_script)); | 215 ASSERT_TRUE(ExecuteScript(shell()->web_contents(), data_url_script)); |
215 } | 216 } |
216 | 217 |
217 bool SitePerProcessBrowserTest::NavigateIframeToURL(Shell* window, | 218 void SitePerProcessBrowserTest::NavigateIframeToURL(Shell* window, |
218 const GURL& url, | 219 const GURL& url, |
219 std::string iframe_id) { | 220 std::string iframe_id) { |
220 // TODO(creis): This should wait for LOAD_STOP, but cross-site subframe | 221 // TODO(creis): This should wait for LOAD_STOP, but cross-site subframe |
221 // navigations generate extra DidStartLoading and DidStopLoading messages. | 222 // navigations generate extra DidStartLoading and DidStopLoading messages. |
222 // Until we replace swappedout:// with frame proxies, we need to listen for | 223 // Until we replace swappedout:// with frame proxies, we need to listen for |
223 // something else. For now, we trigger NEW_SUBFRAME navigations and listen | 224 // something else. For now, we trigger NEW_SUBFRAME navigations and listen |
224 // for commit. | 225 // for commit. |
225 std::string script = base::StringPrintf( | 226 std::string script = base::StringPrintf( |
226 "setTimeout(\"" | 227 "setTimeout(\"" |
227 "var iframes = document.getElementById('%s');iframes.src='%s';" | 228 "var iframes = document.getElementById('%s');iframes.src='%s';" |
228 "\",0)", | 229 "\",0)", |
229 iframe_id.c_str(), url.spec().c_str()); | 230 iframe_id.c_str(), url.spec().c_str()); |
230 WindowedNotificationObserver load_observer( | 231 WindowedNotificationObserver load_observer( |
231 NOTIFICATION_NAV_ENTRY_COMMITTED, | 232 NOTIFICATION_NAV_ENTRY_COMMITTED, |
232 Source<NavigationController>( | 233 Source<NavigationController>( |
233 &window->web_contents()->GetController())); | 234 &window->web_contents()->GetController())); |
234 bool result = ExecuteScript(window->web_contents(), script); | 235 EXPECT_TRUE(ExecuteScript(window->web_contents(), script)); |
235 load_observer.Wait(); | 236 load_observer.Wait(); |
236 return result; | |
237 } | 237 } |
238 | 238 |
239 void SitePerProcessBrowserTest::SetUpCommandLine(CommandLine* command_line) { | 239 void SitePerProcessBrowserTest::SetUpCommandLine(CommandLine* command_line) { |
240 command_line->AppendSwitch(switches::kSitePerProcess); | 240 command_line->AppendSwitch(switches::kSitePerProcess); |
241 }; | 241 }; |
242 | 242 |
243 void SitePerProcessBrowserTest::SetUpOnMainThread() { | 243 void SitePerProcessBrowserTest::SetUpOnMainThread() { |
244 host_resolver()->AddRule("*", "127.0.0.1"); | 244 host_resolver()->AddRule("*", "127.0.0.1"); |
245 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady()); | 245 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady()); |
246 SetupCrossSiteRedirector(embedded_test_server()); | 246 SetupCrossSiteRedirector(embedded_test_server()); |
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
403 GURL main_url(embedded_test_server()->GetURL("/site_per_process_main.html")); | 403 GURL main_url(embedded_test_server()->GetURL("/site_per_process_main.html")); |
404 NavigateToURL(shell(), main_url); | 404 NavigateToURL(shell(), main_url); |
405 | 405 |
406 StartFrameAtDataURL(); | 406 StartFrameAtDataURL(); |
407 | 407 |
408 // These must stay in scope with replace_host. | 408 // These must stay in scope with replace_host. |
409 GURL::Replacements replace_host; | 409 GURL::Replacements replace_host; |
410 std::string foo_com("foo.com"); | 410 std::string foo_com("foo.com"); |
411 | 411 |
412 // Load cross-site page into iframe. | 412 // Load cross-site page into iframe. |
413 EXPECT_TRUE(NavigateIframeToURL( | 413 NavigateIframeToURL(shell(), embedded_test_server()->GetURL( |
414 shell(), | 414 "/cross-site/foo.com/title2.html"), |
415 embedded_test_server()->GetURL("/cross-site/foo.com/title2.html"), | 415 "test"); |
416 "test")); | |
417 | 416 |
418 // Check the subframe process. | 417 // Check the subframe process. |
419 FrameTreeNode* root = | 418 FrameTreeNode* root = |
420 static_cast<WebContentsImpl*>(shell()->web_contents())-> | 419 static_cast<WebContentsImpl*>(shell()->web_contents())-> |
421 GetFrameTree()->root(); | 420 GetFrameTree()->root(); |
422 ASSERT_EQ(1U, root->child_count()); | 421 ASSERT_EQ(1U, root->child_count()); |
423 FrameTreeNode* child = root->child_at(0); | 422 FrameTreeNode* child = root->child_at(0); |
424 EXPECT_EQ(main_url, root->current_url()); | 423 EXPECT_EQ(main_url, root->current_url()); |
425 EXPECT_EQ("foo.com", child->current_url().host()); | 424 EXPECT_EQ("foo.com", child->current_url().host()); |
426 EXPECT_EQ("/title2.html", child->current_url().path()); | 425 EXPECT_EQ("/title2.html", child->current_url().path()); |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
480 GURL https_url(https_server.GetURL("files/title1.html")); | 479 GURL https_url(https_server.GetURL("files/title1.html")); |
481 | 480 |
482 NavigateToURL(shell(), main_url); | 481 NavigateToURL(shell(), main_url); |
483 | 482 |
484 SitePerProcessWebContentsObserver observer(shell()->web_contents()); | 483 SitePerProcessWebContentsObserver observer(shell()->web_contents()); |
485 { | 484 { |
486 // Load cross-site client-redirect page into Iframe. | 485 // Load cross-site client-redirect page into Iframe. |
487 // Should be blocked. | 486 // Should be blocked. |
488 GURL client_redirect_https_url(https_server.GetURL( | 487 GURL client_redirect_https_url(https_server.GetURL( |
489 "client-redirect?files/title1.html")); | 488 "client-redirect?files/title1.html")); |
490 EXPECT_TRUE(NavigateIframeToURL(shell(), | 489 NavigateIframeToURL(shell(), client_redirect_https_url, "test"); |
491 client_redirect_https_url, "test")); | |
492 // DidFailProvisionalLoad when navigating to client_redirect_https_url. | 490 // DidFailProvisionalLoad when navigating to client_redirect_https_url. |
493 EXPECT_EQ(observer.navigation_url(), client_redirect_https_url); | 491 EXPECT_EQ(observer.navigation_url(), client_redirect_https_url); |
494 EXPECT_FALSE(observer.navigation_succeeded()); | 492 EXPECT_FALSE(observer.navigation_succeeded()); |
495 } | 493 } |
496 | 494 |
497 { | 495 { |
498 // Load cross-site server-redirect page into Iframe, | 496 // Load cross-site server-redirect page into Iframe, |
499 // which redirects to same-site page. | 497 // which redirects to same-site page. |
500 GURL server_redirect_http_url(https_server.GetURL( | 498 GURL server_redirect_http_url(https_server.GetURL( |
501 "server-redirect?" + http_url.spec())); | 499 "server-redirect?" + http_url.spec())); |
502 EXPECT_TRUE(NavigateIframeToURL(shell(), | 500 NavigateIframeToURL(shell(), server_redirect_http_url, "test"); |
503 server_redirect_http_url, "test")); | |
504 EXPECT_EQ(observer.navigation_url(), http_url); | 501 EXPECT_EQ(observer.navigation_url(), http_url); |
505 EXPECT_TRUE(observer.navigation_succeeded()); | 502 EXPECT_TRUE(observer.navigation_succeeded()); |
506 } | 503 } |
507 | 504 |
508 { | 505 { |
509 // Load cross-site server-redirect page into Iframe, | 506 // Load cross-site server-redirect page into Iframe, |
510 // which redirects to cross-site page. | 507 // which redirects to cross-site page. |
511 GURL server_redirect_http_url(https_server.GetURL( | 508 GURL server_redirect_http_url(https_server.GetURL( |
512 "server-redirect?files/title1.html")); | 509 "server-redirect?files/title1.html")); |
513 EXPECT_TRUE(NavigateIframeToURL(shell(), | 510 NavigateIframeToURL(shell(), server_redirect_http_url, "test"); |
514 server_redirect_http_url, "test")); | |
515 // DidFailProvisionalLoad when navigating to https_url. | 511 // DidFailProvisionalLoad when navigating to https_url. |
516 EXPECT_EQ(observer.navigation_url(), https_url); | 512 EXPECT_EQ(observer.navigation_url(), https_url); |
517 EXPECT_FALSE(observer.navigation_succeeded()); | 513 EXPECT_FALSE(observer.navigation_succeeded()); |
518 } | 514 } |
519 | 515 |
520 { | 516 { |
521 // Load same-site server-redirect page into Iframe, | 517 // Load same-site server-redirect page into Iframe, |
522 // which redirects to cross-site page. | 518 // which redirects to cross-site page. |
523 GURL server_redirect_http_url(test_server()->GetURL( | 519 GURL server_redirect_http_url(test_server()->GetURL( |
524 "server-redirect?" + https_url.spec())); | 520 "server-redirect?" + https_url.spec())); |
525 EXPECT_TRUE(NavigateIframeToURL(shell(), | 521 NavigateIframeToURL(shell(), server_redirect_http_url, "test"); |
526 server_redirect_http_url, "test")); | |
527 | 522 |
528 EXPECT_EQ(observer.navigation_url(), https_url); | 523 EXPECT_EQ(observer.navigation_url(), https_url); |
529 EXPECT_FALSE(observer.navigation_succeeded()); | 524 EXPECT_FALSE(observer.navigation_succeeded()); |
530 } | 525 } |
531 | 526 |
532 { | 527 { |
533 // Load same-site client-redirect page into Iframe, | 528 // Load same-site client-redirect page into Iframe, |
534 // which redirects to cross-site page. | 529 // which redirects to cross-site page. |
535 GURL client_redirect_http_url(test_server()->GetURL( | 530 GURL client_redirect_http_url(test_server()->GetURL( |
536 "client-redirect?" + https_url.spec())); | 531 "client-redirect?" + https_url.spec())); |
537 | 532 |
538 RedirectNotificationObserver load_observer2( | 533 RedirectNotificationObserver load_observer2( |
539 NOTIFICATION_LOAD_STOP, | 534 NOTIFICATION_LOAD_STOP, |
540 Source<NavigationController>( | 535 Source<NavigationController>( |
541 &shell()->web_contents()->GetController())); | 536 &shell()->web_contents()->GetController())); |
542 | 537 |
543 EXPECT_TRUE(NavigateIframeToURL(shell(), | 538 NavigateIframeToURL(shell(), client_redirect_http_url, "test"); |
544 client_redirect_http_url, "test")); | |
545 | 539 |
546 // Same-site Client-Redirect Page should be loaded successfully. | 540 // Same-site Client-Redirect Page should be loaded successfully. |
547 EXPECT_EQ(observer.navigation_url(), client_redirect_http_url); | 541 EXPECT_EQ(observer.navigation_url(), client_redirect_http_url); |
548 EXPECT_TRUE(observer.navigation_succeeded()); | 542 EXPECT_TRUE(observer.navigation_succeeded()); |
549 | 543 |
550 // Redirecting to Cross-site Page should be blocked. | 544 // Redirecting to Cross-site Page should be blocked. |
551 load_observer2.Wait(); | 545 load_observer2.Wait(); |
552 EXPECT_EQ(observer.navigation_url(), https_url); | 546 EXPECT_EQ(observer.navigation_url(), https_url); |
553 EXPECT_FALSE(observer.navigation_succeeded()); | 547 EXPECT_FALSE(observer.navigation_succeeded()); |
554 } | 548 } |
555 | 549 |
556 { | 550 { |
557 // Load same-site server-redirect page into Iframe, | 551 // Load same-site server-redirect page into Iframe, |
558 // which redirects to same-site page. | 552 // which redirects to same-site page. |
559 GURL server_redirect_http_url(test_server()->GetURL( | 553 GURL server_redirect_http_url( |
560 "server-redirect?files/title1.html")); | 554 test_server()->GetURL("server-redirect?files/title1.html")); |
561 EXPECT_TRUE(NavigateIframeToURL(shell(), | 555 NavigateIframeToURL(shell(), server_redirect_http_url, "test"); |
562 server_redirect_http_url, "test")); | |
563 EXPECT_EQ(observer.navigation_url(), http_url); | 556 EXPECT_EQ(observer.navigation_url(), http_url); |
564 EXPECT_TRUE(observer.navigation_succeeded()); | 557 EXPECT_TRUE(observer.navigation_succeeded()); |
565 } | 558 } |
566 | 559 |
567 { | 560 { |
568 // Load same-site client-redirect page into Iframe, | 561 // Load same-site client-redirect page into Iframe, |
569 // which redirects to same-site page. | 562 // which redirects to same-site page. |
570 GURL client_redirect_http_url(test_server()->GetURL( | 563 GURL client_redirect_http_url(test_server()->GetURL( |
571 "client-redirect?" + http_url.spec())); | 564 "client-redirect?" + http_url.spec())); |
572 RedirectNotificationObserver load_observer2( | 565 RedirectNotificationObserver load_observer2( |
573 NOTIFICATION_LOAD_STOP, | 566 NOTIFICATION_LOAD_STOP, |
574 Source<NavigationController>( | 567 Source<NavigationController>( |
575 &shell()->web_contents()->GetController())); | 568 &shell()->web_contents()->GetController())); |
576 | 569 |
577 EXPECT_TRUE(NavigateIframeToURL(shell(), | 570 NavigateIframeToURL(shell(), client_redirect_http_url, "test"); |
578 client_redirect_http_url, "test")); | |
579 | 571 |
580 // Same-site Client-Redirect Page should be loaded successfully. | 572 // Same-site Client-Redirect Page should be loaded successfully. |
581 EXPECT_EQ(observer.navigation_url(), client_redirect_http_url); | 573 EXPECT_EQ(observer.navigation_url(), client_redirect_http_url); |
582 EXPECT_TRUE(observer.navigation_succeeded()); | 574 EXPECT_TRUE(observer.navigation_succeeded()); |
583 | 575 |
584 // Redirecting to Same-site Page should be loaded successfully. | 576 // Redirecting to Same-site Page should be loaded successfully. |
585 load_observer2.Wait(); | 577 load_observer2.Wait(); |
586 EXPECT_EQ(observer.navigation_url(), http_url); | 578 EXPECT_EQ(observer.navigation_url(), http_url); |
587 EXPECT_TRUE(observer.navigation_succeeded()); | 579 EXPECT_TRUE(observer.navigation_succeeded()); |
588 } | 580 } |
(...skipping 26 matching lines...) Expand all Loading... |
615 "client-redirect?" + http_url.spec())); | 607 "client-redirect?" + http_url.spec())); |
616 GURL client_redirect_http_url(test_server()->GetURL( | 608 GURL client_redirect_http_url(test_server()->GetURL( |
617 "client-redirect?" + client_redirect_https_url.spec())); | 609 "client-redirect?" + client_redirect_https_url.spec())); |
618 | 610 |
619 // We should wait until second client redirect get cancelled. | 611 // We should wait until second client redirect get cancelled. |
620 RedirectNotificationObserver load_observer2( | 612 RedirectNotificationObserver load_observer2( |
621 NOTIFICATION_LOAD_STOP, | 613 NOTIFICATION_LOAD_STOP, |
622 Source<NavigationController>( | 614 Source<NavigationController>( |
623 &shell()->web_contents()->GetController())); | 615 &shell()->web_contents()->GetController())); |
624 | 616 |
625 EXPECT_TRUE(NavigateIframeToURL(shell(), client_redirect_http_url, "test")); | 617 NavigateIframeToURL(shell(), client_redirect_http_url, "test"); |
626 | 618 |
627 // DidFailProvisionalLoad when navigating to client_redirect_https_url. | 619 // DidFailProvisionalLoad when navigating to client_redirect_https_url. |
628 load_observer2.Wait(); | 620 load_observer2.Wait(); |
629 EXPECT_EQ(observer.navigation_url(), client_redirect_https_url); | 621 EXPECT_EQ(observer.navigation_url(), client_redirect_https_url); |
630 EXPECT_FALSE(observer.navigation_succeeded()); | 622 EXPECT_FALSE(observer.navigation_succeeded()); |
631 } | 623 } |
632 | 624 |
633 { | 625 { |
634 // Load server-redirect page pointing to a cross-site server-redirect page, | 626 // Load server-redirect page pointing to a cross-site server-redirect page, |
635 // which eventually redirect back to same-site page. | 627 // which eventually redirect back to same-site page. |
636 GURL server_redirect_https_url(https_server.GetURL( | 628 GURL server_redirect_https_url(https_server.GetURL( |
637 "server-redirect?" + http_url.spec())); | 629 "server-redirect?" + http_url.spec())); |
638 GURL server_redirect_http_url(test_server()->GetURL( | 630 GURL server_redirect_http_url(test_server()->GetURL( |
639 "server-redirect?" + server_redirect_https_url.spec())); | 631 "server-redirect?" + server_redirect_https_url.spec())); |
640 EXPECT_TRUE(NavigateIframeToURL(shell(), | 632 NavigateIframeToURL(shell(), server_redirect_http_url, "test"); |
641 server_redirect_http_url, "test")); | |
642 EXPECT_EQ(observer.navigation_url(), http_url); | 633 EXPECT_EQ(observer.navigation_url(), http_url); |
643 EXPECT_TRUE(observer.navigation_succeeded()); | 634 EXPECT_TRUE(observer.navigation_succeeded()); |
644 } | 635 } |
645 | 636 |
646 { | 637 { |
647 // Load server-redirect page pointing to a cross-site server-redirect page, | 638 // Load server-redirect page pointing to a cross-site server-redirect page, |
648 // which eventually redirects back to cross-site page. | 639 // which eventually redirects back to cross-site page. |
649 GURL server_redirect_https_url(https_server.GetURL( | 640 GURL server_redirect_https_url(https_server.GetURL( |
650 "server-redirect?" + https_url.spec())); | 641 "server-redirect?" + https_url.spec())); |
651 GURL server_redirect_http_url(test_server()->GetURL( | 642 GURL server_redirect_http_url(test_server()->GetURL( |
652 "server-redirect?" + server_redirect_https_url.spec())); | 643 "server-redirect?" + server_redirect_https_url.spec())); |
653 EXPECT_TRUE(NavigateIframeToURL(shell(), server_redirect_http_url, "test")); | 644 NavigateIframeToURL(shell(), server_redirect_http_url, "test"); |
654 | 645 |
655 // DidFailProvisionalLoad when navigating to https_url. | 646 // DidFailProvisionalLoad when navigating to https_url. |
656 EXPECT_EQ(observer.navigation_url(), https_url); | 647 EXPECT_EQ(observer.navigation_url(), https_url); |
657 EXPECT_FALSE(observer.navigation_succeeded()); | 648 EXPECT_FALSE(observer.navigation_succeeded()); |
658 } | 649 } |
659 | 650 |
660 { | 651 { |
661 // Load server-redirect page pointing to a cross-site client-redirect page, | 652 // Load server-redirect page pointing to a cross-site client-redirect page, |
662 // which eventually redirects back to same-site page. | 653 // which eventually redirects back to same-site page. |
663 GURL client_redirect_http_url(https_server.GetURL( | 654 GURL client_redirect_http_url(https_server.GetURL( |
664 "client-redirect?" + http_url.spec())); | 655 "client-redirect?" + http_url.spec())); |
665 GURL server_redirect_http_url(test_server()->GetURL( | 656 GURL server_redirect_http_url(test_server()->GetURL( |
666 "server-redirect?" + client_redirect_http_url.spec())); | 657 "server-redirect?" + client_redirect_http_url.spec())); |
667 EXPECT_TRUE(NavigateIframeToURL(shell(), server_redirect_http_url, "test")); | 658 NavigateIframeToURL(shell(), server_redirect_http_url, "test"); |
668 | 659 |
669 // DidFailProvisionalLoad when navigating to client_redirect_http_url. | 660 // DidFailProvisionalLoad when navigating to client_redirect_http_url. |
670 EXPECT_EQ(observer.navigation_url(), client_redirect_http_url); | 661 EXPECT_EQ(observer.navigation_url(), client_redirect_http_url); |
671 EXPECT_FALSE(observer.navigation_succeeded()); | 662 EXPECT_FALSE(observer.navigation_succeeded()); |
672 } | 663 } |
673 } | 664 } |
674 | 665 |
675 // Ensure that when navigating a frame cross-process RenderFrameProxyHosts are | 666 // Ensure that when navigating a frame cross-process RenderFrameProxyHosts are |
676 // created in the FrameTree skipping the subtree of the navigating frame. | 667 // created in the FrameTree skipping the subtree of the navigating frame. |
677 // | 668 // |
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
824 | 815 |
825 // Check that a new process is created and is different from the top one and | 816 // Check that a new process is created and is different from the top one and |
826 // the middle one. | 817 // the middle one. |
827 FrameTreeNode* bottom_child = root->child_at(0)->child_at(0); | 818 FrameTreeNode* bottom_child = root->child_at(0)->child_at(0); |
828 EXPECT_NE(shell()->web_contents()->GetSiteInstance(), | 819 EXPECT_NE(shell()->web_contents()->GetSiteInstance(), |
829 bottom_child->current_frame_host()->GetSiteInstance()); | 820 bottom_child->current_frame_host()->GetSiteInstance()); |
830 EXPECT_NE(root->child_at(0)->current_frame_host()->GetSiteInstance(), | 821 EXPECT_NE(root->child_at(0)->current_frame_host()->GetSiteInstance(), |
831 bottom_child->current_frame_host()->GetSiteInstance()); | 822 bottom_child->current_frame_host()->GetSiteInstance()); |
832 } | 823 } |
833 | 824 |
| 825 // Disabled because of http://crbug.com/433012 . |
| 826 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, |
| 827 DISABLED_NavigateRemoteToDataURL) { |
| 828 GURL main_url(embedded_test_server()->GetURL("/site_per_process_main.html")); |
| 829 NavigateToURL(shell(), main_url); |
| 830 |
| 831 // It is safe to obtain the root frame tree node here, as it doesn't change. |
| 832 FrameTreeNode* root = static_cast<WebContentsImpl*>(shell()->web_contents()) |
| 833 ->GetFrameTree() |
| 834 ->root(); |
| 835 |
| 836 SitePerProcessWebContentsObserver observer(shell()->web_contents()); |
| 837 |
| 838 // Load cross-site page into iframe. |
| 839 GURL url = embedded_test_server()->GetURL("foo.com", "/title1.html"); |
| 840 NavigateFrameToURL(root->child_at(0), url); |
| 841 EXPECT_TRUE(observer.navigation_succeeded()); |
| 842 EXPECT_EQ(url, observer.navigation_url()); |
| 843 |
| 844 // Ensure that we have created a new process for the subframe. |
| 845 EXPECT_NE(shell()->web_contents()->GetSiteInstance(), |
| 846 root->child_at(0)->current_frame_host()->GetSiteInstance()); |
| 847 |
| 848 // Navigate iframe to a data URL. The navigation happens from a script in the |
| 849 // parent renderer, so the data URL should be rendered in the parent renderer. |
| 850 GURL data_url("data:text/html,dataurl"); |
| 851 std::string script = base::StringPrintf( |
| 852 "setTimeout(function() {" |
| 853 "var iframe = document.getElementById('test');" |
| 854 "iframe.onload = function() { document.title = 'LOADED'; };" |
| 855 "iframe.src=\"%s\";" |
| 856 "},0);", |
| 857 data_url.spec().c_str()); |
| 858 base::string16 passed_string(base::UTF8ToUTF16("LOADED")); |
| 859 TitleWatcher title_watcher(shell()->web_contents(), passed_string); |
| 860 EXPECT_TRUE(ExecuteScript(shell()->web_contents(), script)); |
| 861 (void)title_watcher.WaitAndGetTitle(); |
| 862 EXPECT_TRUE(observer.navigation_succeeded()); |
| 863 EXPECT_EQ(data_url, observer.navigation_url()); |
| 864 |
| 865 // Ensure that we have navigated using the top level process. |
| 866 EXPECT_EQ(shell()->web_contents()->GetSiteInstance(), |
| 867 root->child_at(0)->current_frame_host()->GetSiteInstance()); |
| 868 } |
| 869 |
| 870 // Disabled because of http://crbug.com/433012 . |
| 871 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, |
| 872 DISABLED_NavigateRemoteToBlankURL) { |
| 873 GURL main_url(embedded_test_server()->GetURL("/site_per_process_main.html")); |
| 874 NavigateToURL(shell(), main_url); |
| 875 |
| 876 // It is safe to obtain the root frame tree node here, as it doesn't change. |
| 877 FrameTreeNode* root = static_cast<WebContentsImpl*>(shell()->web_contents()) |
| 878 ->GetFrameTree() |
| 879 ->root(); |
| 880 |
| 881 SitePerProcessWebContentsObserver observer(shell()->web_contents()); |
| 882 |
| 883 // Load cross-site page into iframe. |
| 884 GURL url = embedded_test_server()->GetURL("foo.com", "/title1.html"); |
| 885 NavigateFrameToURL(root->child_at(0), url); |
| 886 EXPECT_TRUE(observer.navigation_succeeded()); |
| 887 EXPECT_EQ(url, observer.navigation_url()); |
| 888 |
| 889 // Ensure that we have created a new process for the subframe. |
| 890 EXPECT_NE(shell()->web_contents()->GetSiteInstance(), |
| 891 root->child_at(0)->current_frame_host()->GetSiteInstance()); |
| 892 |
| 893 // Navigate iframe to a data URL. The navigation happens from a script in the |
| 894 // parent renderer, so the data URL should be rendered in the parent renderer. |
| 895 GURL data_url("about:blank"); |
| 896 std::string script = base::StringPrintf( |
| 897 "setTimeout(function() {" |
| 898 "var iframe = document.getElementById('test');" |
| 899 "iframe.onload = function() { document.title = 'LOADED'; };" |
| 900 "iframe.src=\"%s\";" |
| 901 "},0);", |
| 902 data_url.spec().c_str()); |
| 903 base::string16 passed_string(base::UTF8ToUTF16("LOADED")); |
| 904 TitleWatcher title_watcher(shell()->web_contents(), passed_string); |
| 905 EXPECT_TRUE(ExecuteScript(shell()->web_contents(), script)); |
| 906 (void)title_watcher.WaitAndGetTitle(); |
| 907 EXPECT_TRUE(observer.navigation_succeeded()); |
| 908 EXPECT_EQ(data_url, observer.navigation_url()); |
| 909 |
| 910 // Ensure that we have navigated using the top level process. |
| 911 EXPECT_EQ(shell()->web_contents()->GetSiteInstance(), |
| 912 root->child_at(0)->current_frame_host()->GetSiteInstance()); |
| 913 } |
| 914 |
834 } // namespace content | 915 } // namespace content |
OLD | NEW |