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

Side by Side Diff: chrome/browser/extensions/process_manager_browsertest.cc

Issue 2850793005: Remove command line/field trial support and configs for Isolate Extensions. (Closed)
Patch Set: Rebase. Created 3 years, 7 months 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 <stddef.h> 5 #include <stddef.h>
6 6
7 #include <memory> 7 #include <memory>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/callback.h" 10 #include "base/callback.h"
(...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after
245 NavigationCompletedObserver observer( 245 NavigationCompletedObserver observer(
246 browser()->tab_strip_model()->GetActiveWebContents()); 246 browser()->tab_strip_model()->GetActiveWebContents());
247 247
248 ui_test_utils::NavigateToURL(browser(), url); 248 ui_test_utils::NavigateToURL(browser(), url);
249 249
250 // Wait until the last RenderFrameHosts are deleted. This wait doesn't take 250 // Wait until the last RenderFrameHosts are deleted. This wait doesn't take
251 // long. 251 // long.
252 observer.Wait(); 252 observer.Wait();
253 } 253 }
254 254
255 size_t IfExtensionsIsolated(size_t if_enabled, size_t if_disabled) {
256 return content::AreAllSitesIsolatedForTesting() ||
257 IsIsolateExtensionsEnabled()
258 ? if_enabled
259 : if_disabled;
260 }
261
262 content::WebContents* OpenPopup(content::RenderFrameHost* opener, 255 content::WebContents* OpenPopup(content::RenderFrameHost* opener,
263 const GURL& url) { 256 const GURL& url) {
264 content::WindowedNotificationObserver popup_observer( 257 content::WindowedNotificationObserver popup_observer(
265 chrome::NOTIFICATION_TAB_ADDED, 258 chrome::NOTIFICATION_TAB_ADDED,
266 content::NotificationService::AllSources()); 259 content::NotificationService::AllSources());
267 EXPECT_TRUE(ExecuteScript( 260 EXPECT_TRUE(ExecuteScript(
268 opener, "window.popup = window.open('" + url.spec() + "')")); 261 opener, "window.popup = window.open('" + url.spec() + "')"));
269 popup_observer.Wait(); 262 popup_observer.Wait();
270 content::WebContents* popup = 263 content::WebContents* popup =
271 browser()->tab_strip_model()->GetActiveWebContents(); 264 browser()->tab_strip_model()->GetActiveWebContents();
(...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after
522 EXPECT_EQ(0u, pm->GetRenderFrameHostsForExtension(extension2->id()).size()); 515 EXPECT_EQ(0u, pm->GetRenderFrameHostsForExtension(extension2->id()).size());
523 516
524 NavigateToURL(embedded_test_server()->GetURL("/two_iframes.html")); 517 NavigateToURL(embedded_test_server()->GetURL("/two_iframes.html"));
525 EXPECT_EQ(0u, pm->GetAllFrames().size()); 518 EXPECT_EQ(0u, pm->GetAllFrames().size());
526 519
527 content::WebContents* tab = 520 content::WebContents* tab =
528 browser()->tab_strip_model()->GetActiveWebContents(); 521 browser()->tab_strip_model()->GetActiveWebContents();
529 522
530 // Tests extension frames in non-extension page. 523 // Tests extension frames in non-extension page.
531 EXPECT_TRUE(content::NavigateIframeToURL(tab, "frame1", kExt1EmptyUrl)); 524 EXPECT_TRUE(content::NavigateIframeToURL(tab, "frame1", kExt1EmptyUrl));
532 EXPECT_EQ(IfExtensionsIsolated(1, 0), 525 EXPECT_EQ(1u, pm->GetRenderFrameHostsForExtension(extension1->id()).size());
533 pm->GetRenderFrameHostsForExtension(extension1->id()).size()); 526 EXPECT_EQ(1u, pm->GetAllFrames().size());
534 EXPECT_EQ(IfExtensionsIsolated(1, 0), pm->GetAllFrames().size());
535 527
536 EXPECT_TRUE(content::NavigateIframeToURL(tab, "frame2", kExt2EmptyUrl)); 528 EXPECT_TRUE(content::NavigateIframeToURL(tab, "frame2", kExt2EmptyUrl));
537 EXPECT_EQ(IfExtensionsIsolated(1, 0), 529 EXPECT_EQ(1u, pm->GetRenderFrameHostsForExtension(extension2->id()).size());
538 pm->GetRenderFrameHostsForExtension(extension2->id()).size()); 530 EXPECT_EQ(2u, pm->GetAllFrames().size());
539 EXPECT_EQ(IfExtensionsIsolated(2, 0), pm->GetAllFrames().size());
540 531
541 // Tests non-extension page in extension frame. 532 // Tests non-extension page in extension frame.
542 NavigateToURL(kExt1TwoFramesUrl); 533 NavigateToURL(kExt1TwoFramesUrl);
543 // 1 top-level + 2 child frames from Extension 1. 534 // 1 top-level + 2 child frames from Extension 1.
544 EXPECT_EQ(3u, pm->GetAllFrames().size()); 535 EXPECT_EQ(3u, pm->GetAllFrames().size());
545 EXPECT_EQ(3u, pm->GetRenderFrameHostsForExtension(extension1->id()).size()); 536 EXPECT_EQ(3u, pm->GetRenderFrameHostsForExtension(extension1->id()).size());
546 EXPECT_EQ(0u, pm->GetRenderFrameHostsForExtension(extension2->id()).size()); 537 EXPECT_EQ(0u, pm->GetRenderFrameHostsForExtension(extension2->id()).size());
547 538
548 EXPECT_TRUE(content::NavigateIframeToURL(tab, "frame1", 539 EXPECT_TRUE(content::NavigateIframeToURL(tab, "frame1",
549 embedded_test_server() 540 embedded_test_server()
550 ->GetURL("/empty.html"))); 541 ->GetURL("/empty.html")));
551 // 1 top-level + 1 child frame from Extension 1. 542 // 1 top-level + 1 child frame from Extension 1.
552 EXPECT_EQ(2u, pm->GetRenderFrameHostsForExtension(extension1->id()).size()); 543 EXPECT_EQ(2u, pm->GetRenderFrameHostsForExtension(extension1->id()).size());
553 EXPECT_EQ(2u, pm->GetAllFrames().size()); 544 EXPECT_EQ(2u, pm->GetAllFrames().size());
554 545
555 EXPECT_TRUE(content::NavigateIframeToURL(tab, "frame1", kExt1EmptyUrl)); 546 EXPECT_TRUE(content::NavigateIframeToURL(tab, "frame1", kExt1EmptyUrl));
556 // 1 top-level + 2 child frames from Extension 1. 547 // 1 top-level + 2 child frames from Extension 1.
557 EXPECT_EQ(3u, pm->GetAllFrames().size()); 548 EXPECT_EQ(3u, pm->GetAllFrames().size());
558 EXPECT_EQ(3u, pm->GetRenderFrameHostsForExtension(extension1->id()).size()); 549 EXPECT_EQ(3u, pm->GetRenderFrameHostsForExtension(extension1->id()).size());
559 550
560 // Load a frame from another extension. 551 // Load a frame from another extension.
561 EXPECT_TRUE(content::NavigateIframeToURL(tab, "frame1", kExt2EmptyUrl)); 552 EXPECT_TRUE(content::NavigateIframeToURL(tab, "frame1", kExt2EmptyUrl));
562 // 1 top-level + 1 child frame from Extension 1, 553 // 1 top-level + 1 child frame from Extension 1,
563 // 1 child frame from Extension 2. 554 // 1 child frame from Extension 2.
564 EXPECT_EQ(IfExtensionsIsolated(3, 2), pm->GetAllFrames().size()); 555 EXPECT_EQ(3u, pm->GetAllFrames().size());
565 EXPECT_EQ(2u, pm->GetRenderFrameHostsForExtension(extension1->id()).size()); 556 EXPECT_EQ(2u, pm->GetRenderFrameHostsForExtension(extension1->id()).size());
566 EXPECT_EQ(IfExtensionsIsolated(1, 0), 557 EXPECT_EQ(1u, pm->GetRenderFrameHostsForExtension(extension2->id()).size());
567 pm->GetRenderFrameHostsForExtension(extension2->id()).size());
568 558
569 // Destroy all existing frames by navigating to another extension. 559 // Destroy all existing frames by navigating to another extension.
570 NavigateToURL(extension2->url().Resolve("empty.html")); 560 NavigateToURL(extension2->url().Resolve("empty.html"));
571 EXPECT_EQ(1u, pm->GetAllFrames().size()); 561 EXPECT_EQ(1u, pm->GetAllFrames().size());
572 EXPECT_EQ(0u, pm->GetRenderFrameHostsForExtension(extension1->id()).size()); 562 EXPECT_EQ(0u, pm->GetRenderFrameHostsForExtension(extension1->id()).size());
573 EXPECT_EQ(1u, pm->GetRenderFrameHostsForExtension(extension2->id()).size()); 563 EXPECT_EQ(1u, pm->GetRenderFrameHostsForExtension(extension2->id()).size());
574 564
575 // Test about:blank and about:srcdoc child frames. 565 // Test about:blank and about:srcdoc child frames.
576 NavigateToURL(extension2->url().Resolve("srcdoc_iframe.html")); 566 NavigateToURL(extension2->url().Resolve("srcdoc_iframe.html"));
577 // 1 top-level frame + 1 child frame from Extension 2. 567 // 1 top-level frame + 1 child frame from Extension 2.
(...skipping 27 matching lines...) Expand all
605 // 1 top-level + 2 child frames from Extension 1, 595 // 1 top-level + 2 child frames from Extension 1,
606 // 2 child frames in frame1 from Extension 2. 596 // 2 child frames in frame1 from Extension 2.
607 EXPECT_EQ(5u, pm->GetAllFrames().size()); 597 EXPECT_EQ(5u, pm->GetAllFrames().size());
608 EXPECT_EQ(5u, pm->GetRenderFrameHostsForExtension(extension2->id()).size()); 598 EXPECT_EQ(5u, pm->GetRenderFrameHostsForExtension(extension2->id()).size());
609 599
610 // The extension frame from the other extension should not be classified as an 600 // The extension frame from the other extension should not be classified as an
611 // extension (unless out-of-process frames are enabled). 601 // extension (unless out-of-process frames are enabled).
612 EXPECT_TRUE(content::NavigateIframeToURL(tab, "frame1", kExt1EmptyUrl)); 602 EXPECT_TRUE(content::NavigateIframeToURL(tab, "frame1", kExt1EmptyUrl));
613 // 1 top-level + 1 child frames from Extension 2, 603 // 1 top-level + 1 child frames from Extension 2,
614 // 1 child frame from Extension 1. 604 // 1 child frame from Extension 1.
615 EXPECT_EQ(IfExtensionsIsolated(3, 2), pm->GetAllFrames().size()); 605 EXPECT_EQ(3u, pm->GetAllFrames().size());
616 EXPECT_EQ(IfExtensionsIsolated(1, 0), 606 EXPECT_EQ(1u, pm->GetRenderFrameHostsForExtension(extension1->id()).size());
617 pm->GetRenderFrameHostsForExtension(extension1->id()).size());
618 EXPECT_EQ(2u, pm->GetRenderFrameHostsForExtension(extension2->id()).size()); 607 EXPECT_EQ(2u, pm->GetRenderFrameHostsForExtension(extension2->id()).size());
619 608
620 EXPECT_TRUE(content::NavigateIframeToURL(tab, "frame2", kExt1TwoFramesUrl)); 609 EXPECT_TRUE(content::NavigateIframeToURL(tab, "frame2", kExt1TwoFramesUrl));
621 // 1 top-level + 1 child frames from Extension 2, 610 // 1 top-level + 1 child frames from Extension 2,
622 // 1 child frame + 2 child frames in frame2 from Extension 1. 611 // 1 child frame + 2 child frames in frame2 from Extension 1.
623 EXPECT_EQ(IfExtensionsIsolated(5, 1), pm->GetAllFrames().size()); 612 EXPECT_EQ(5u, pm->GetAllFrames().size());
624 EXPECT_EQ(IfExtensionsIsolated(4, 0), 613 EXPECT_EQ(4u, pm->GetRenderFrameHostsForExtension(extension1->id()).size());
625 pm->GetRenderFrameHostsForExtension(extension1->id()).size());
626 EXPECT_EQ(1u, pm->GetRenderFrameHostsForExtension(extension2->id()).size()); 614 EXPECT_EQ(1u, pm->GetRenderFrameHostsForExtension(extension2->id()).size());
627 615
628 // Crash tab where the top-level frame is an extension frame. 616 // Crash tab where the top-level frame is an extension frame.
629 content::CrashTab(tab); 617 content::CrashTab(tab);
630 EXPECT_EQ(0u, pm->GetAllFrames().size()); 618 EXPECT_EQ(0u, pm->GetAllFrames().size());
631 EXPECT_EQ(0u, pm->GetRenderFrameHostsForExtension(extension1->id()).size()); 619 EXPECT_EQ(0u, pm->GetRenderFrameHostsForExtension(extension1->id()).size());
632 EXPECT_EQ(0u, pm->GetRenderFrameHostsForExtension(extension2->id()).size()); 620 EXPECT_EQ(0u, pm->GetRenderFrameHostsForExtension(extension2->id()).size());
633 621
634 // Now load an extension page and a non-extension page... 622 // Now load an extension page and a non-extension page...
635 ui_test_utils::NavigateToURLWithDisposition( 623 ui_test_utils::NavigateToURLWithDisposition(
636 browser(), kExt1EmptyUrl, WindowOpenDisposition::NEW_BACKGROUND_TAB, 624 browser(), kExt1EmptyUrl, WindowOpenDisposition::NEW_BACKGROUND_TAB,
637 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); 625 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION);
638 NavigateToURL(embedded_test_server()->GetURL("/two_iframes.html")); 626 NavigateToURL(embedded_test_server()->GetURL("/two_iframes.html"));
639 EXPECT_EQ(1u, pm->GetAllFrames().size()); 627 EXPECT_EQ(1u, pm->GetAllFrames().size());
640 628
641 // ... load an extension frame in the non-extension process 629 // ... load an extension frame in the non-extension process
642 EXPECT_TRUE(content::NavigateIframeToURL(tab, "frame1", kExt1EmptyUrl)); 630 EXPECT_TRUE(content::NavigateIframeToURL(tab, "frame1", kExt1EmptyUrl));
643 EXPECT_EQ(IfExtensionsIsolated(2, 1), 631 EXPECT_EQ(2u, pm->GetRenderFrameHostsForExtension(extension1->id()).size());
644 pm->GetRenderFrameHostsForExtension(extension1->id()).size());
645 632
646 // ... and take down the tab. The extension process is not part of the tab, 633 // ... and take down the tab. The extension process is not part of the tab,
647 // so it should be kept alive (minus the frames that died). 634 // so it should be kept alive (minus the frames that died).
648 content::CrashTab(tab); 635 content::CrashTab(tab);
649 EXPECT_EQ(1u, pm->GetAllFrames().size()); 636 EXPECT_EQ(1u, pm->GetAllFrames().size());
650 EXPECT_EQ(1u, pm->GetRenderFrameHostsForExtension(extension1->id()).size()); 637 EXPECT_EQ(1u, pm->GetRenderFrameHostsForExtension(extension1->id()).size());
651 } 638 }
652 639
653 // Verify correct keepalive count behavior on network request events. 640 // Verify correct keepalive count behavior on network request events.
654 // Regression test for http://crbug.com/535716. 641 // Regression test for http://crbug.com/535716.
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
756 // Navigate main tab to a web page with two web iframes. There should be no 743 // Navigate main tab to a web page with two web iframes. There should be no
757 // extension frames yet. 744 // extension frames yet.
758 NavigateToURL(embedded_test_server()->GetURL("/two_iframes.html")); 745 NavigateToURL(embedded_test_server()->GetURL("/two_iframes.html"));
759 ProcessManager* pm = ProcessManager::Get(profile()); 746 ProcessManager* pm = ProcessManager::Get(profile());
760 EXPECT_EQ(0u, pm->GetAllFrames().size()); 747 EXPECT_EQ(0u, pm->GetAllFrames().size());
761 EXPECT_EQ(0u, pm->GetRenderFrameHostsForExtension(extension->id()).size()); 748 EXPECT_EQ(0u, pm->GetRenderFrameHostsForExtension(extension->id()).size());
762 749
763 content::WebContents* tab = 750 content::WebContents* tab =
764 browser()->tab_strip_model()->GetActiveWebContents(); 751 browser()->tab_strip_model()->GetActiveWebContents();
765 752
766 // Navigate first subframe to an extension URL. With --isolate-extensions, 753 // Navigate first subframe to an extension URL. This will go into a new
767 // this will go into a new extension process. 754 // extension process.
768 const GURL extension_url(extension->url().Resolve("empty.html")); 755 const GURL extension_url(extension->url().Resolve("empty.html"));
769 EXPECT_TRUE(content::NavigateIframeToURL(tab, "frame1", extension_url)); 756 EXPECT_TRUE(content::NavigateIframeToURL(tab, "frame1", extension_url));
770 EXPECT_EQ(IfExtensionsIsolated(1, 0), 757 EXPECT_EQ(1u, pm->GetRenderFrameHostsForExtension(extension->id()).size());
771 pm->GetRenderFrameHostsForExtension(extension->id()).size()); 758 EXPECT_EQ(1u, pm->GetAllFrames().size());
772 EXPECT_EQ(IfExtensionsIsolated(1, 0), pm->GetAllFrames().size());
773 759
774 content::RenderFrameHost* main_frame = tab->GetMainFrame(); 760 content::RenderFrameHost* main_frame = tab->GetMainFrame();
775 content::RenderFrameHost* extension_frame = ChildFrameAt(main_frame, 0); 761 content::RenderFrameHost* extension_frame = ChildFrameAt(main_frame, 0);
776 762
777 // Validate that permissions have been granted for the extension scheme 763 // Validate that permissions have been granted for the extension scheme
778 // to the process of the extension iframe. 764 // to the process of the extension iframe.
779 content::ChildProcessSecurityPolicy* policy = 765 content::ChildProcessSecurityPolicy* policy =
780 content::ChildProcessSecurityPolicy::GetInstance(); 766 content::ChildProcessSecurityPolicy::GetInstance();
781 EXPECT_TRUE(policy->CanRequestURL( 767 EXPECT_TRUE(policy->CanRequestURL(
782 extension_frame->GetProcess()->GetID(), 768 extension_frame->GetProcess()->GetID(),
783 GURL("blob:chrome-extension://some-extension-id/some-guid"))); 769 GURL("blob:chrome-extension://some-extension-id/some-guid")));
784 EXPECT_TRUE(policy->CanRequestURL( 770 EXPECT_TRUE(policy->CanRequestURL(
785 main_frame->GetProcess()->GetID(), 771 main_frame->GetProcess()->GetID(),
786 GURL("blob:chrome-extension://some-extension-id/some-guid"))); 772 GURL("blob:chrome-extension://some-extension-id/some-guid")));
787 EXPECT_TRUE(policy->CanRequestURL( 773 EXPECT_TRUE(policy->CanRequestURL(
788 extension_frame->GetProcess()->GetID(), 774 extension_frame->GetProcess()->GetID(),
789 GURL("filesystem:chrome-extension://some-extension-id/some-path"))); 775 GURL("filesystem:chrome-extension://some-extension-id/some-path")));
790 EXPECT_TRUE(policy->CanRequestURL( 776 EXPECT_TRUE(policy->CanRequestURL(
791 main_frame->GetProcess()->GetID(), 777 main_frame->GetProcess()->GetID(),
792 GURL("filesystem:chrome-extension://some-extension-id/some-path"))); 778 GURL("filesystem:chrome-extension://some-extension-id/some-path")));
793 EXPECT_TRUE(policy->CanRequestURL( 779 EXPECT_TRUE(policy->CanRequestURL(
794 extension_frame->GetProcess()->GetID(), 780 extension_frame->GetProcess()->GetID(),
795 GURL("chrome-extension://some-extension-id/resource.html"))); 781 GURL("chrome-extension://some-extension-id/resource.html")));
796 EXPECT_TRUE(policy->CanRequestURL( 782 EXPECT_TRUE(policy->CanRequestURL(
797 main_frame->GetProcess()->GetID(), 783 main_frame->GetProcess()->GetID(),
798 GURL("chrome-extension://some-extension-id/resource.html"))); 784 GURL("chrome-extension://some-extension-id/resource.html")));
799 785
800 if (IsIsolateExtensionsEnabled()) { 786 EXPECT_TRUE(policy->CanCommitURL(
801 EXPECT_TRUE(policy->CanCommitURL( 787 extension_frame->GetProcess()->GetID(),
802 extension_frame->GetProcess()->GetID(), 788 GURL("blob:chrome-extension://some-extension-id/some-guid")));
803 GURL("blob:chrome-extension://some-extension-id/some-guid"))); 789 EXPECT_FALSE(policy->CanCommitURL(
804 EXPECT_FALSE(policy->CanCommitURL( 790 main_frame->GetProcess()->GetID(),
805 main_frame->GetProcess()->GetID(), 791 GURL("blob:chrome-extension://some-extension-id/some-guid")));
806 GURL("blob:chrome-extension://some-extension-id/some-guid"))); 792 EXPECT_TRUE(policy->CanCommitURL(
807 EXPECT_TRUE(policy->CanCommitURL( 793 extension_frame->GetProcess()->GetID(),
808 extension_frame->GetProcess()->GetID(), 794 GURL("chrome-extension://some-extension-id/resource.html")));
809 GURL("chrome-extension://some-extension-id/resource.html"))); 795 EXPECT_FALSE(policy->CanCommitURL(
810 EXPECT_FALSE(policy->CanCommitURL( 796 main_frame->GetProcess()->GetID(),
811 main_frame->GetProcess()->GetID(), 797 GURL("chrome-extension://some-extension-id/resource.html")));
812 GURL("chrome-extension://some-extension-id/resource.html"))); 798 EXPECT_TRUE(policy->CanCommitURL(
813 EXPECT_TRUE(policy->CanCommitURL( 799 extension_frame->GetProcess()->GetID(),
814 extension_frame->GetProcess()->GetID(), 800 GURL("filesystem:chrome-extension://some-extension-id/some-path")));
815 GURL("filesystem:chrome-extension://some-extension-id/some-path"))); 801 EXPECT_FALSE(policy->CanCommitURL(
816 EXPECT_FALSE(policy->CanCommitURL( 802 main_frame->GetProcess()->GetID(),
817 main_frame->GetProcess()->GetID(), 803 GURL("filesystem:chrome-extension://some-extension-id/some-path")));
818 GURL("filesystem:chrome-extension://some-extension-id/some-path")));
819 }
820 804
821 // Open a new about:blank popup from main frame. This should stay in the web 805 // Open a new about:blank popup from main frame. This should stay in the web
822 // process. 806 // process.
823 content::WebContents* popup = 807 content::WebContents* popup =
824 OpenPopup(main_frame, GURL(url::kAboutBlankURL)); 808 OpenPopup(main_frame, GURL(url::kAboutBlankURL));
825 EXPECT_NE(popup, tab); 809 EXPECT_NE(popup, tab);
826 ASSERT_EQ(2, browser()->tab_strip_model()->count()); 810 ASSERT_EQ(2, browser()->tab_strip_model()->count());
827 EXPECT_EQ(IfExtensionsIsolated(1, 0), 811 EXPECT_EQ(1u, pm->GetRenderFrameHostsForExtension(extension->id()).size());
828 pm->GetRenderFrameHostsForExtension(extension->id()).size()); 812 EXPECT_EQ(1u, pm->GetAllFrames().size());
829 EXPECT_EQ(IfExtensionsIsolated(1, 0), pm->GetAllFrames().size());
830 813
831 // Create valid blob and filesystem URLs in the extension's origin. 814 // Create valid blob and filesystem URLs in the extension's origin.
832 url::Origin extension_origin(extension_frame->GetLastCommittedOrigin()); 815 url::Origin extension_origin(extension_frame->GetLastCommittedOrigin());
833 GURL blob_url(CreateBlobURL(extension_frame, "foo")); 816 GURL blob_url(CreateBlobURL(extension_frame, "foo"));
834 EXPECT_EQ(extension_origin, url::Origin(blob_url)); 817 EXPECT_EQ(extension_origin, url::Origin(blob_url));
835 GURL filesystem_url(CreateFileSystemURL(extension_frame, "foo")); 818 GURL filesystem_url(CreateFileSystemURL(extension_frame, "foo"));
836 EXPECT_EQ(extension_origin, url::Origin(filesystem_url)); 819 EXPECT_EQ(extension_origin, url::Origin(filesystem_url));
837 820
838 // Navigate the popup to each nested URL with extension origin. 821 // Navigate the popup to each nested URL with extension origin.
839 GURL nested_urls[] = {blob_url, filesystem_url}; 822 GURL nested_urls[] = {blob_url, filesystem_url};
840 for (size_t i = 0; i < arraysize(nested_urls); i++) { 823 for (size_t i = 0; i < arraysize(nested_urls); i++) {
841 content::TestNavigationObserver observer(popup); 824 content::TestNavigationObserver observer(popup);
842 EXPECT_TRUE(ExecuteScript( 825 EXPECT_TRUE(ExecuteScript(
843 popup, "location.href = '" + nested_urls[i].spec() + "';")); 826 popup, "location.href = '" + nested_urls[i].spec() + "';"));
844 observer.Wait(); 827 observer.Wait();
845 828
846 // This is a top-level navigation that should be blocked since it 829 // This is a top-level navigation that should be blocked since it
847 // originates from a non-extension process. Ensure that the error page 830 // originates from a non-extension process. Ensure that the error page
848 // doesn't commit an extension URL or origin. 831 // doesn't commit an extension URL or origin.
849 EXPECT_NE(nested_urls[i], popup->GetLastCommittedURL()); 832 EXPECT_NE(nested_urls[i], popup->GetLastCommittedURL());
850 EXPECT_FALSE(extension_origin.IsSameOriginWith( 833 EXPECT_FALSE(extension_origin.IsSameOriginWith(
851 popup->GetMainFrame()->GetLastCommittedOrigin())); 834 popup->GetMainFrame()->GetLastCommittedOrigin()));
852 EXPECT_NE("foo", GetTextContent(popup->GetMainFrame())); 835 EXPECT_NE("foo", GetTextContent(popup->GetMainFrame()));
853 836
854 EXPECT_EQ(IfExtensionsIsolated(1, 0), 837 EXPECT_EQ(1u, pm->GetRenderFrameHostsForExtension(extension->id()).size());
855 pm->GetRenderFrameHostsForExtension(extension->id()).size()); 838 EXPECT_EQ(1u, pm->GetAllFrames().size());
856 EXPECT_EQ(IfExtensionsIsolated(1, 0), pm->GetAllFrames().size());
857 } 839 }
858 840
859 // Navigate second subframe to each nested URL from the main frame (i.e., 841 // Navigate second subframe to each nested URL from the main frame (i.e.,
860 // from non-extension process). This should be blocked in 842 // from non-extension process). This should be blocked.
861 // --isolate-extensions, but allowed without --isolate-extensions due to
862 // unblessed extension frames.
863 // 843 //
864 // TODO(alexmos): This is also temporarily allowed under PlzNavigate, because 844 // TODO(alexmos): This is also temporarily allowed under PlzNavigate, because
865 // currently this particular blocking happens in 845 // currently this particular blocking happens in
866 // ChromeContentBrowserClientExtensionsPart::ShouldAllowOpenURL, which isn't 846 // ChromeContentBrowserClientExtensionsPart::ShouldAllowOpenURL, which isn't
867 // triggered below under PlzNavigate (since there'll be no transfer). Once 847 // triggered below under PlzNavigate (since there'll be no transfer). Once
868 // the blob/filesystem URL checks in ExtensionNavigationThrottle are updated 848 // the blob/filesystem URL checks in ExtensionNavigationThrottle are updated
869 // to apply to all frames and not just main frames, the PlzNavigate exception 849 // to apply to all frames and not just main frames, the PlzNavigate exception
870 // below can be removed. See https://crbug.com/661324. 850 // below can be removed. See https://crbug.com/661324.
871 for (size_t i = 0; i < arraysize(nested_urls); i++) { 851 for (size_t i = 0; i < arraysize(nested_urls); i++) {
872 EXPECT_TRUE(content::NavigateIframeToURL(tab, "frame2", nested_urls[i])); 852 EXPECT_TRUE(content::NavigateIframeToURL(tab, "frame2", nested_urls[i]));
873 content::RenderFrameHost* second_frame = ChildFrameAt(main_frame, 1); 853 content::RenderFrameHost* second_frame = ChildFrameAt(main_frame, 1);
874 if (IsIsolateExtensionsEnabled() && 854 if (!content::IsBrowserSideNavigationEnabled()) {
875 !content::IsBrowserSideNavigationEnabled()) {
876 EXPECT_NE(nested_urls[i], second_frame->GetLastCommittedURL()); 855 EXPECT_NE(nested_urls[i], second_frame->GetLastCommittedURL());
877 EXPECT_FALSE(extension_origin.IsSameOriginWith( 856 EXPECT_FALSE(extension_origin.IsSameOriginWith(
878 second_frame->GetLastCommittedOrigin())); 857 second_frame->GetLastCommittedOrigin()));
879 EXPECT_NE("foo", GetTextContent(second_frame)); 858 EXPECT_NE("foo", GetTextContent(second_frame));
880 EXPECT_EQ(IfExtensionsIsolated(1, 0), 859 EXPECT_EQ(1u,
881 pm->GetRenderFrameHostsForExtension(extension->id()).size()); 860 pm->GetRenderFrameHostsForExtension(extension->id()).size());
882 EXPECT_EQ(IfExtensionsIsolated(1, 0), pm->GetAllFrames().size()); 861 EXPECT_EQ(1u, pm->GetAllFrames().size());
883 } else { 862 } else {
884 EXPECT_EQ(nested_urls[i], second_frame->GetLastCommittedURL()); 863 EXPECT_EQ(nested_urls[i], second_frame->GetLastCommittedURL());
885 EXPECT_EQ(extension_origin, second_frame->GetLastCommittedOrigin()); 864 EXPECT_EQ(extension_origin, second_frame->GetLastCommittedOrigin());
886 EXPECT_EQ("foo", GetTextContent(second_frame)); 865 EXPECT_EQ("foo", GetTextContent(second_frame));
887 EXPECT_EQ(IfExtensionsIsolated(2, 0), 866 EXPECT_EQ(2u,
888 pm->GetRenderFrameHostsForExtension(extension->id()).size()); 867 pm->GetRenderFrameHostsForExtension(extension->id()).size());
889 EXPECT_EQ(IfExtensionsIsolated(2, 0), pm->GetAllFrames().size()); 868 EXPECT_EQ(2u, pm->GetAllFrames().size());
890 } 869 }
891 EXPECT_TRUE( 870 EXPECT_TRUE(
892 content::NavigateIframeToURL(tab, "frame2", GURL(url::kAboutBlankURL))); 871 content::NavigateIframeToURL(tab, "frame2", GURL(url::kAboutBlankURL)));
893 } 872 }
894 } 873 }
895 874
896 // Test that navigations to blob: and filesystem: URLs with extension origins 875 // Test that navigations to blob: and filesystem: URLs with extension origins
897 // are allowed when initiated from extension processes. See 876 // are allowed when initiated from extension processes. See
898 // https://crbug.com/645028 and https://crbug.com/644426. 877 // https://crbug.com/645028 and https://crbug.com/644426.
899 IN_PROC_BROWSER_TEST_F(ProcessManagerBrowserTest, 878 IN_PROC_BROWSER_TEST_F(ProcessManagerBrowserTest,
(...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after
1170 1149
1171 // Verify that postMessage to window.opener works. 1150 // Verify that postMessage to window.opener works.
1172 VerifyPostMessageToOpener(popup->GetMainFrame(), main_frame); 1151 VerifyPostMessageToOpener(popup->GetMainFrame(), main_frame);
1173 } 1152 }
1174 1153
1175 // Verify that a web popup created via window.open from an extension subframe 1154 // Verify that a web popup created via window.open from an extension subframe
1176 // can communicate with the extension page via window.opener. Similar to the 1155 // can communicate with the extension page via window.opener. Similar to the
1177 // test above, but for subframes. See https://crbug.com/590068. 1156 // test above, but for subframes. See https://crbug.com/590068.
1178 IN_PROC_BROWSER_TEST_F(ProcessManagerBrowserTest, 1157 IN_PROC_BROWSER_TEST_F(ProcessManagerBrowserTest,
1179 WebPopupFromExtensionSubframeHasValidOpener) { 1158 WebPopupFromExtensionSubframeHasValidOpener) {
1180 // This test only makes sense if OOPIFs are enabled for extension subframes.
1181 if (!IsIsolateExtensionsEnabled())
1182 return;
1183
1184 // Create a simple extension without a background page. 1159 // Create a simple extension without a background page.
1185 const Extension* extension = CreateExtension("Extension", false); 1160 const Extension* extension = CreateExtension("Extension", false);
1186 embedded_test_server()->ServeFilesFromDirectory(extension->path()); 1161 embedded_test_server()->ServeFilesFromDirectory(extension->path());
1187 ASSERT_TRUE(embedded_test_server()->Start()); 1162 ASSERT_TRUE(embedded_test_server()->Start());
1188 1163
1189 // Navigate main tab to a web page with a blank iframe. There should be no 1164 // Navigate main tab to a web page with a blank iframe. There should be no
1190 // extension frames yet. 1165 // extension frames yet.
1191 NavigateToURL(embedded_test_server()->GetURL("/blank_iframe.html")); 1166 NavigateToURL(embedded_test_server()->GetURL("/blank_iframe.html"));
1192 ProcessManager* pm = ProcessManager::Get(profile()); 1167 ProcessManager* pm = ProcessManager::Get(profile());
1193 EXPECT_EQ(0u, pm->GetAllFrames().size()); 1168 EXPECT_EQ(0u, pm->GetAllFrames().size());
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
1268 GURL b_url(embedded_test_server()->GetURL("b.com", "/empty.html")); 1243 GURL b_url(embedded_test_server()->GetURL("b.com", "/empty.html"));
1269 EXPECT_TRUE(content::NavigateIframeToURL(tab, "frame0", b_url)); 1244 EXPECT_TRUE(content::NavigateIframeToURL(tab, "frame0", b_url));
1270 { 1245 {
1271 content::RenderFrameHost* subframe = ChildFrameAt(main_frame, 0); 1246 content::RenderFrameHost* subframe = ChildFrameAt(main_frame, 0);
1272 EXPECT_EQ(subframe->GetProcess(), main_frame->GetProcess()); 1247 EXPECT_EQ(subframe->GetProcess(), main_frame->GetProcess());
1273 EXPECT_EQ(subframe->GetSiteInstance(), main_frame->GetSiteInstance()); 1248 EXPECT_EQ(subframe->GetSiteInstance(), main_frame->GetSiteInstance());
1274 } 1249 }
1275 } 1250 }
1276 1251
1277 } // namespace extensions 1252 } // namespace extensions
OLDNEW
« no previous file with comments | « chrome/browser/extensions/process_management_browsertest.cc ('k') | chrome/browser/site_details_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698