Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(297)

Side by Side Diff: content/browser/site_per_process_browsertest.cc

Issue 743773003: OOPIF: Data URLs are now rendered in the renderer that initiated the navigation. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
158 SitePerProcessBrowserTest::SitePerProcessBrowserTest() { 159 SitePerProcessBrowserTest::SitePerProcessBrowserTest() {
159 }; 160 };
160 161
161 void SitePerProcessBrowserTest::StartFrameAtDataURL() { 162 void SitePerProcessBrowserTest::StartFrameAtDataURL() {
162 std::string data_url_script = 163 std::string data_url_script =
163 "var iframes = document.getElementById('test');iframes.src=" 164 "var iframes = document.getElementById('test');iframes.src="
164 "'data:text/html,dataurl';"; 165 "'data:text/html,dataurl';";
165 ASSERT_TRUE(ExecuteScript(shell()->web_contents(), data_url_script)); 166 ASSERT_TRUE(ExecuteScript(shell()->web_contents(), data_url_script));
166 } 167 }
167 168
168 bool SitePerProcessBrowserTest::NavigateIframeToURL(Shell* window, 169 void SitePerProcessBrowserTest::NavigateIframeToURL(Shell* window,
Charlie Reis 2014/12/06 00:18:51 Please don't change this. It's more useful to hav
lfg 2014/12/08 20:45:33 I agree it's more useful to see the test immediate
Charlie Reis 2014/12/09 19:14:37 Ah, good point. Instead, let's return false befor
169 const GURL& url, 170 const GURL& url,
170 std::string iframe_id) { 171 std::string iframe_id) {
171 // TODO(creis): This should wait for LOAD_STOP, but cross-site subframe 172 // TODO(creis): This should wait for LOAD_STOP, but cross-site subframe
172 // navigations generate extra DidStartLoading and DidStopLoading messages. 173 // navigations generate extra DidStartLoading and DidStopLoading messages.
173 // Until we replace swappedout:// with frame proxies, we need to listen for 174 // Until we replace swappedout:// with frame proxies, we need to listen for
174 // something else. For now, we trigger NEW_SUBFRAME navigations and listen 175 // something else. For now, we trigger NEW_SUBFRAME navigations and listen
175 // for commit. 176 // for commit.
176 std::string script = base::StringPrintf( 177 std::string script = base::StringPrintf(
177 "setTimeout(\"" 178 "setTimeout(\""
178 "var iframes = document.getElementById('%s');iframes.src='%s';" 179 "var iframes = document.getElementById('%s');iframes.src='%s';"
179 "\",0)", 180 "\",0)",
180 iframe_id.c_str(), url.spec().c_str()); 181 iframe_id.c_str(), url.spec().c_str());
181 WindowedNotificationObserver load_observer( 182 WindowedNotificationObserver load_observer(
182 NOTIFICATION_NAV_ENTRY_COMMITTED, 183 NOTIFICATION_NAV_ENTRY_COMMITTED,
183 Source<NavigationController>( 184 Source<NavigationController>(
184 &window->web_contents()->GetController())); 185 &window->web_contents()->GetController()));
185 bool result = ExecuteScript(window->web_contents(), script); 186 EXPECT_TRUE(ExecuteScript(window->web_contents(), script));
186 load_observer.Wait(); 187 load_observer.Wait();
187 return result;
188 } 188 }
189 189
190 void SitePerProcessBrowserTest::SetUpCommandLine(CommandLine* command_line) { 190 void SitePerProcessBrowserTest::SetUpCommandLine(CommandLine* command_line) {
191 command_line->AppendSwitch(switches::kSitePerProcess); 191 command_line->AppendSwitch(switches::kSitePerProcess);
192 }; 192 };
193 193
194 void SitePerProcessBrowserTest::SetUpOnMainThread() { 194 void SitePerProcessBrowserTest::SetUpOnMainThread() {
195 host_resolver()->AddRule("*", "127.0.0.1"); 195 host_resolver()->AddRule("*", "127.0.0.1");
196 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady()); 196 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady());
197 SetupCrossSiteRedirector(embedded_test_server()); 197 SetupCrossSiteRedirector(embedded_test_server());
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
354 GURL main_url(embedded_test_server()->GetURL("/site_per_process_main.html")); 354 GURL main_url(embedded_test_server()->GetURL("/site_per_process_main.html"));
355 NavigateToURL(shell(), main_url); 355 NavigateToURL(shell(), main_url);
356 356
357 StartFrameAtDataURL(); 357 StartFrameAtDataURL();
358 358
359 // These must stay in scope with replace_host. 359 // These must stay in scope with replace_host.
360 GURL::Replacements replace_host; 360 GURL::Replacements replace_host;
361 std::string foo_com("foo.com"); 361 std::string foo_com("foo.com");
362 362
363 // Load cross-site page into iframe. 363 // Load cross-site page into iframe.
364 EXPECT_TRUE(NavigateIframeToURL( 364 NavigateIframeToURL(shell(), embedded_test_server()->GetURL(
365 shell(), 365 "/cross-site/foo.com/title2.html"),
366 embedded_test_server()->GetURL("/cross-site/foo.com/title2.html"), 366 "test");
367 "test"));
368 367
369 // Check the subframe process. 368 // Check the subframe process.
370 FrameTreeNode* root = 369 FrameTreeNode* root =
371 static_cast<WebContentsImpl*>(shell()->web_contents())-> 370 static_cast<WebContentsImpl*>(shell()->web_contents())->
372 GetFrameTree()->root(); 371 GetFrameTree()->root();
373 ASSERT_EQ(1U, root->child_count()); 372 ASSERT_EQ(1U, root->child_count());
374 FrameTreeNode* child = root->child_at(0); 373 FrameTreeNode* child = root->child_at(0);
375 EXPECT_EQ(main_url, root->current_url()); 374 EXPECT_EQ(main_url, root->current_url());
376 EXPECT_EQ("foo.com", child->current_url().host()); 375 EXPECT_EQ("foo.com", child->current_url().host());
377 EXPECT_EQ("/title2.html", child->current_url().path()); 376 EXPECT_EQ("/title2.html", child->current_url().path());
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
431 GURL https_url(https_server.GetURL("files/title1.html")); 430 GURL https_url(https_server.GetURL("files/title1.html"));
432 431
433 NavigateToURL(shell(), main_url); 432 NavigateToURL(shell(), main_url);
434 433
435 SitePerProcessWebContentsObserver observer(shell()->web_contents()); 434 SitePerProcessWebContentsObserver observer(shell()->web_contents());
436 { 435 {
437 // Load cross-site client-redirect page into Iframe. 436 // Load cross-site client-redirect page into Iframe.
438 // Should be blocked. 437 // Should be blocked.
439 GURL client_redirect_https_url(https_server.GetURL( 438 GURL client_redirect_https_url(https_server.GetURL(
440 "client-redirect?files/title1.html")); 439 "client-redirect?files/title1.html"));
441 EXPECT_TRUE(NavigateIframeToURL(shell(), 440 NavigateIframeToURL(shell(), client_redirect_https_url, "test");
442 client_redirect_https_url, "test"));
443 // DidFailProvisionalLoad when navigating to client_redirect_https_url. 441 // DidFailProvisionalLoad when navigating to client_redirect_https_url.
444 EXPECT_EQ(observer.navigation_url(), client_redirect_https_url); 442 EXPECT_EQ(observer.navigation_url(), client_redirect_https_url);
445 EXPECT_FALSE(observer.navigation_succeeded()); 443 EXPECT_FALSE(observer.navigation_succeeded());
446 } 444 }
447 445
448 { 446 {
449 // Load cross-site server-redirect page into Iframe, 447 // Load cross-site server-redirect page into Iframe,
450 // which redirects to same-site page. 448 // which redirects to same-site page.
451 GURL server_redirect_http_url(https_server.GetURL( 449 GURL server_redirect_http_url(https_server.GetURL(
452 "server-redirect?" + http_url.spec())); 450 "server-redirect?" + http_url.spec()));
453 EXPECT_TRUE(NavigateIframeToURL(shell(), 451 NavigateIframeToURL(shell(), server_redirect_http_url, "test");
454 server_redirect_http_url, "test"));
455 EXPECT_EQ(observer.navigation_url(), http_url); 452 EXPECT_EQ(observer.navigation_url(), http_url);
456 EXPECT_TRUE(observer.navigation_succeeded()); 453 EXPECT_TRUE(observer.navigation_succeeded());
457 } 454 }
458 455
459 { 456 {
460 // Load cross-site server-redirect page into Iframe, 457 // Load cross-site server-redirect page into Iframe,
461 // which redirects to cross-site page. 458 // which redirects to cross-site page.
462 GURL server_redirect_http_url(https_server.GetURL( 459 GURL server_redirect_http_url(https_server.GetURL(
463 "server-redirect?files/title1.html")); 460 "server-redirect?files/title1.html"));
464 EXPECT_TRUE(NavigateIframeToURL(shell(), 461 NavigateIframeToURL(shell(), server_redirect_http_url, "test");
465 server_redirect_http_url, "test"));
466 // DidFailProvisionalLoad when navigating to https_url. 462 // DidFailProvisionalLoad when navigating to https_url.
467 EXPECT_EQ(observer.navigation_url(), https_url); 463 EXPECT_EQ(observer.navigation_url(), https_url);
468 EXPECT_FALSE(observer.navigation_succeeded()); 464 EXPECT_FALSE(observer.navigation_succeeded());
469 } 465 }
470 466
471 { 467 {
472 // Load same-site server-redirect page into Iframe, 468 // Load same-site server-redirect page into Iframe,
473 // which redirects to cross-site page. 469 // which redirects to cross-site page.
474 GURL server_redirect_http_url(test_server()->GetURL( 470 GURL server_redirect_http_url(test_server()->GetURL(
475 "server-redirect?" + https_url.spec())); 471 "server-redirect?" + https_url.spec()));
476 EXPECT_TRUE(NavigateIframeToURL(shell(), 472 NavigateIframeToURL(shell(), server_redirect_http_url, "test");
477 server_redirect_http_url, "test"));
478 473
479 EXPECT_EQ(observer.navigation_url(), https_url); 474 EXPECT_EQ(observer.navigation_url(), https_url);
480 EXPECT_FALSE(observer.navigation_succeeded()); 475 EXPECT_FALSE(observer.navigation_succeeded());
481 } 476 }
482 477
483 { 478 {
484 // Load same-site client-redirect page into Iframe, 479 // Load same-site client-redirect page into Iframe,
485 // which redirects to cross-site page. 480 // which redirects to cross-site page.
486 GURL client_redirect_http_url(test_server()->GetURL( 481 GURL client_redirect_http_url(test_server()->GetURL(
487 "client-redirect?" + https_url.spec())); 482 "client-redirect?" + https_url.spec()));
488 483
489 RedirectNotificationObserver load_observer2( 484 RedirectNotificationObserver load_observer2(
490 NOTIFICATION_LOAD_STOP, 485 NOTIFICATION_LOAD_STOP,
491 Source<NavigationController>( 486 Source<NavigationController>(
492 &shell()->web_contents()->GetController())); 487 &shell()->web_contents()->GetController()));
493 488
494 EXPECT_TRUE(NavigateIframeToURL(shell(), 489 NavigateIframeToURL(shell(), client_redirect_http_url, "test");
495 client_redirect_http_url, "test"));
496 490
497 // Same-site Client-Redirect Page should be loaded successfully. 491 // Same-site Client-Redirect Page should be loaded successfully.
498 EXPECT_EQ(observer.navigation_url(), client_redirect_http_url); 492 EXPECT_EQ(observer.navigation_url(), client_redirect_http_url);
499 EXPECT_TRUE(observer.navigation_succeeded()); 493 EXPECT_TRUE(observer.navigation_succeeded());
500 494
501 // Redirecting to Cross-site Page should be blocked. 495 // Redirecting to Cross-site Page should be blocked.
502 load_observer2.Wait(); 496 load_observer2.Wait();
503 EXPECT_EQ(observer.navigation_url(), https_url); 497 EXPECT_EQ(observer.navigation_url(), https_url);
504 EXPECT_FALSE(observer.navigation_succeeded()); 498 EXPECT_FALSE(observer.navigation_succeeded());
505 } 499 }
506 500
507 { 501 {
508 // Load same-site server-redirect page into Iframe, 502 // Load same-site server-redirect page into Iframe,
509 // which redirects to same-site page. 503 // which redirects to same-site page.
510 GURL server_redirect_http_url(test_server()->GetURL( 504 GURL server_redirect_http_url(
511 "server-redirect?files/title1.html")); 505 test_server()->GetURL("server-redirect?files/title1.html"));
512 EXPECT_TRUE(NavigateIframeToURL(shell(), 506 NavigateIframeToURL(shell(), server_redirect_http_url, "test");
513 server_redirect_http_url, "test"));
514 EXPECT_EQ(observer.navigation_url(), http_url); 507 EXPECT_EQ(observer.navigation_url(), http_url);
515 EXPECT_TRUE(observer.navigation_succeeded()); 508 EXPECT_TRUE(observer.navigation_succeeded());
516 } 509 }
517 510
518 { 511 {
519 // Load same-site client-redirect page into Iframe, 512 // Load same-site client-redirect page into Iframe,
520 // which redirects to same-site page. 513 // which redirects to same-site page.
521 GURL client_redirect_http_url(test_server()->GetURL( 514 GURL client_redirect_http_url(test_server()->GetURL(
522 "client-redirect?" + http_url.spec())); 515 "client-redirect?" + http_url.spec()));
523 RedirectNotificationObserver load_observer2( 516 RedirectNotificationObserver load_observer2(
524 NOTIFICATION_LOAD_STOP, 517 NOTIFICATION_LOAD_STOP,
525 Source<NavigationController>( 518 Source<NavigationController>(
526 &shell()->web_contents()->GetController())); 519 &shell()->web_contents()->GetController()));
527 520
528 EXPECT_TRUE(NavigateIframeToURL(shell(), 521 NavigateIframeToURL(shell(), client_redirect_http_url, "test");
529 client_redirect_http_url, "test"));
530 522
531 // Same-site Client-Redirect Page should be loaded successfully. 523 // Same-site Client-Redirect Page should be loaded successfully.
532 EXPECT_EQ(observer.navigation_url(), client_redirect_http_url); 524 EXPECT_EQ(observer.navigation_url(), client_redirect_http_url);
533 EXPECT_TRUE(observer.navigation_succeeded()); 525 EXPECT_TRUE(observer.navigation_succeeded());
534 526
535 // Redirecting to Same-site Page should be loaded successfully. 527 // Redirecting to Same-site Page should be loaded successfully.
536 load_observer2.Wait(); 528 load_observer2.Wait();
537 EXPECT_EQ(observer.navigation_url(), http_url); 529 EXPECT_EQ(observer.navigation_url(), http_url);
538 EXPECT_TRUE(observer.navigation_succeeded()); 530 EXPECT_TRUE(observer.navigation_succeeded());
539 } 531 }
(...skipping 26 matching lines...) Expand all
566 "client-redirect?" + http_url.spec())); 558 "client-redirect?" + http_url.spec()));
567 GURL client_redirect_http_url(test_server()->GetURL( 559 GURL client_redirect_http_url(test_server()->GetURL(
568 "client-redirect?" + client_redirect_https_url.spec())); 560 "client-redirect?" + client_redirect_https_url.spec()));
569 561
570 // We should wait until second client redirect get cancelled. 562 // We should wait until second client redirect get cancelled.
571 RedirectNotificationObserver load_observer2( 563 RedirectNotificationObserver load_observer2(
572 NOTIFICATION_LOAD_STOP, 564 NOTIFICATION_LOAD_STOP,
573 Source<NavigationController>( 565 Source<NavigationController>(
574 &shell()->web_contents()->GetController())); 566 &shell()->web_contents()->GetController()));
575 567
576 EXPECT_TRUE(NavigateIframeToURL(shell(), client_redirect_http_url, "test")); 568 NavigateIframeToURL(shell(), client_redirect_http_url, "test");
577 569
578 // DidFailProvisionalLoad when navigating to client_redirect_https_url. 570 // DidFailProvisionalLoad when navigating to client_redirect_https_url.
579 load_observer2.Wait(); 571 load_observer2.Wait();
580 EXPECT_EQ(observer.navigation_url(), client_redirect_https_url); 572 EXPECT_EQ(observer.navigation_url(), client_redirect_https_url);
581 EXPECT_FALSE(observer.navigation_succeeded()); 573 EXPECT_FALSE(observer.navigation_succeeded());
582 } 574 }
583 575
584 { 576 {
585 // Load server-redirect page pointing to a cross-site server-redirect page, 577 // Load server-redirect page pointing to a cross-site server-redirect page,
586 // which eventually redirect back to same-site page. 578 // which eventually redirect back to same-site page.
587 GURL server_redirect_https_url(https_server.GetURL( 579 GURL server_redirect_https_url(https_server.GetURL(
588 "server-redirect?" + http_url.spec())); 580 "server-redirect?" + http_url.spec()));
589 GURL server_redirect_http_url(test_server()->GetURL( 581 GURL server_redirect_http_url(test_server()->GetURL(
590 "server-redirect?" + server_redirect_https_url.spec())); 582 "server-redirect?" + server_redirect_https_url.spec()));
591 EXPECT_TRUE(NavigateIframeToURL(shell(), 583 NavigateIframeToURL(shell(), server_redirect_http_url, "test");
592 server_redirect_http_url, "test"));
593 EXPECT_EQ(observer.navigation_url(), http_url); 584 EXPECT_EQ(observer.navigation_url(), http_url);
594 EXPECT_TRUE(observer.navigation_succeeded()); 585 EXPECT_TRUE(observer.navigation_succeeded());
595 } 586 }
596 587
597 { 588 {
598 // Load server-redirect page pointing to a cross-site server-redirect page, 589 // Load server-redirect page pointing to a cross-site server-redirect page,
599 // which eventually redirects back to cross-site page. 590 // which eventually redirects back to cross-site page.
600 GURL server_redirect_https_url(https_server.GetURL( 591 GURL server_redirect_https_url(https_server.GetURL(
601 "server-redirect?" + https_url.spec())); 592 "server-redirect?" + https_url.spec()));
602 GURL server_redirect_http_url(test_server()->GetURL( 593 GURL server_redirect_http_url(test_server()->GetURL(
603 "server-redirect?" + server_redirect_https_url.spec())); 594 "server-redirect?" + server_redirect_https_url.spec()));
604 EXPECT_TRUE(NavigateIframeToURL(shell(), server_redirect_http_url, "test")); 595 NavigateIframeToURL(shell(), server_redirect_http_url, "test");
605 596
606 // DidFailProvisionalLoad when navigating to https_url. 597 // DidFailProvisionalLoad when navigating to https_url.
607 EXPECT_EQ(observer.navigation_url(), https_url); 598 EXPECT_EQ(observer.navigation_url(), https_url);
608 EXPECT_FALSE(observer.navigation_succeeded()); 599 EXPECT_FALSE(observer.navigation_succeeded());
609 } 600 }
610 601
611 { 602 {
612 // Load server-redirect page pointing to a cross-site client-redirect page, 603 // Load server-redirect page pointing to a cross-site client-redirect page,
613 // which eventually redirects back to same-site page. 604 // which eventually redirects back to same-site page.
614 GURL client_redirect_http_url(https_server.GetURL( 605 GURL client_redirect_http_url(https_server.GetURL(
615 "client-redirect?" + http_url.spec())); 606 "client-redirect?" + http_url.spec()));
616 GURL server_redirect_http_url(test_server()->GetURL( 607 GURL server_redirect_http_url(test_server()->GetURL(
617 "server-redirect?" + client_redirect_http_url.spec())); 608 "server-redirect?" + client_redirect_http_url.spec()));
618 EXPECT_TRUE(NavigateIframeToURL(shell(), server_redirect_http_url, "test")); 609 NavigateIframeToURL(shell(), server_redirect_http_url, "test");
619 610
620 // DidFailProvisionalLoad when navigating to client_redirect_http_url. 611 // DidFailProvisionalLoad when navigating to client_redirect_http_url.
621 EXPECT_EQ(observer.navigation_url(), client_redirect_http_url); 612 EXPECT_EQ(observer.navigation_url(), client_redirect_http_url);
622 EXPECT_FALSE(observer.navigation_succeeded()); 613 EXPECT_FALSE(observer.navigation_succeeded());
623 } 614 }
624 } 615 }
625 616
626 // Ensure that when navigating a frame cross-process RenderFrameProxyHosts are 617 // Ensure that when navigating a frame cross-process RenderFrameProxyHosts are
627 // created in the FrameTree skipping the subtree of the navigating frame. 618 // created in the FrameTree skipping the subtree of the navigating frame.
628 // 619 //
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
728 child->child_at(i)->render_manager()->GetRenderFrameProxyHost(site2)); 719 child->child_at(i)->render_manager()->GetRenderFrameProxyHost(site2));
729 } 720 }
730 721
731 navigation_observer.Wait(); 722 navigation_observer.Wait();
732 EXPECT_TRUE(observer.navigation_succeeded()); 723 EXPECT_TRUE(observer.navigation_succeeded());
733 EXPECT_EQ(cross_site_url, observer.navigation_url()); 724 EXPECT_EQ(cross_site_url, observer.navigation_url());
734 EXPECT_EQ(0U, child->child_count()); 725 EXPECT_EQ(0U, child->child_count());
735 } 726 }
736 } 727 }
737 728
729 // Disabled because of http://crbug.com/433012 .
Charlie Reis 2014/12/06 00:18:51 If we can avoid using script to check the title be
lfg 2014/12/08 20:45:33 Yes, it would. If we don't depend on the renderer
730 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest,
731 DISABLED_NavigateRemoteToDataURL) {
732 GURL main_url(embedded_test_server()->GetURL("/site_per_process_main.html"));
733 NavigateToURL(shell(), main_url);
734
735 // It is safe to obtain the root frame tree node here, as it doesn't change.
736 FrameTreeNode* root = static_cast<WebContentsImpl*>(shell()->web_contents())
737 ->GetFrameTree()
738 ->root();
739
740 SitePerProcessWebContentsObserver observer(shell()->web_contents());
741
742 // Load cross-site page into iframe.
743 GURL url = embedded_test_server()->GetURL("foo.com", "/title1.html");
744 NavigateFrameToURL(root->child_at(0), url);
745 EXPECT_TRUE(observer.navigation_succeeded());
746 EXPECT_EQ(url, observer.navigation_url());
747
748 // Ensure that we have created a new process for the subframe.
749 EXPECT_NE(shell()->web_contents()->GetSiteInstance(),
750 root->child_at(0)->current_frame_host()->GetSiteInstance());
751
752 // Navigate iframe to a data URL. The navigation happens from a script in the
753 // parent renderer, so the data URL should be rendered in the parent renderer.
754 GURL data_url("data:text/html,dataurl");
755 std::string script = base::StringPrintf(
756 "setTimeout(function() {"
757 "var iframe = document.getElementById('test');"
758 "iframe.onload = function() { document.title = 'LOADED'; };"
Charlie Reis 2014/12/06 00:18:51 Can we avoid using the title? I don't understand
lfg 2014/12/08 20:45:33 RenderFrameHostImpl::IsCrossProcessSubframe() retu
Charlie Reis 2014/12/09 19:14:37 Ah! Good find. We could try to revise that check
759 "iframe.src=\"%s\";"
760 "},0);",
761 data_url.spec().c_str());
762 base::string16 passed_string(base::UTF8ToUTF16("LOADED"));
763 TitleWatcher title_watcher(shell()->web_contents(), passed_string);
764 EXPECT_TRUE(ExecuteScript(shell()->web_contents(), script));
765 (void)title_watcher.WaitAndGetTitle();
766 EXPECT_TRUE(observer.navigation_succeeded());
767 EXPECT_EQ(data_url, observer.navigation_url());
768
769 // Ensure that we have navigated using the top level process.
770 EXPECT_EQ(shell()->web_contents()->GetSiteInstance(),
771 root->child_at(0)->current_frame_host()->GetSiteInstance());
772 }
773
774 // Disabled because of http://crbug.com/433012 .
775 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest,
776 DISABLED_NavigateRemoteBlankURL) {
Charlie Reis 2014/12/06 00:18:51 nit: NavigateRemoteToBlankURL
lfg 2014/12/08 20:45:33 Done.
777 GURL main_url(embedded_test_server()->GetURL("/site_per_process_main.html"));
778 NavigateToURL(shell(), main_url);
779
780 // It is safe to obtain the root frame tree node here, as it doesn't change.
781 FrameTreeNode* root = static_cast<WebContentsImpl*>(shell()->web_contents())
782 ->GetFrameTree()
783 ->root();
784
785 SitePerProcessWebContentsObserver observer(shell()->web_contents());
786
787 // Load cross-site page into iframe.
788 GURL url = embedded_test_server()->GetURL("foo.com", "/title1.html");
789 NavigateFrameToURL(root->child_at(0), url);
790 EXPECT_TRUE(observer.navigation_succeeded());
791 EXPECT_EQ(url, observer.navigation_url());
792
793 // Ensure that we have created a new process for the subframe.
794 EXPECT_NE(shell()->web_contents()->GetSiteInstance(),
795 root->child_at(0)->current_frame_host()->GetSiteInstance());
796
797 // Navigate iframe to a data URL. The navigation happens from a script in the
798 // parent renderer, so the data URL should be rendered in the parent renderer.
799 GURL data_url("about:blank");
800 std::string script = base::StringPrintf(
801 "setTimeout(function() {"
802 "var iframe = document.getElementById('test');"
803 "iframe.onload = function() { document.title = 'LOADED'; };"
804 "iframe.src=\"%s\";"
805 "},0);",
806 data_url.spec().c_str());
807 base::string16 passed_string(base::UTF8ToUTF16("LOADED"));
808 TitleWatcher title_watcher(shell()->web_contents(), passed_string);
809 EXPECT_TRUE(ExecuteScript(shell()->web_contents(), script));
810 (void)title_watcher.WaitAndGetTitle();
811 EXPECT_TRUE(observer.navigation_succeeded());
812 EXPECT_EQ(data_url, observer.navigation_url());
813
814 // Ensure that we have navigated using the top level process.
815 EXPECT_EQ(shell()->web_contents()->GetSiteInstance(),
816 root->child_at(0)->current_frame_host()->GetSiteInstance());
817 }
818
738 } // namespace content 819 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698