OLD | NEW |
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" |
11 #include "base/macros.h" | 11 #include "base/macros.h" |
12 #include "base/run_loop.h" | 12 #include "base/run_loop.h" |
13 #include "chrome/browser/extensions/browser_action_test_util.h" | 13 #include "chrome/browser/extensions/browser_action_test_util.h" |
14 #include "chrome/browser/extensions/extension_browsertest.h" | 14 #include "chrome/browser/extensions/extension_browsertest.h" |
15 #include "chrome/browser/extensions/extension_service.h" | 15 #include "chrome/browser/extensions/extension_service.h" |
16 #include "chrome/browser/extensions/test_extension_dir.h" | 16 #include "chrome/browser/extensions/test_extension_dir.h" |
17 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 17 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
18 #include "chrome/common/extensions/extension_process_policy.h" | 18 #include "chrome/common/extensions/extension_process_policy.h" |
19 #include "chrome/common/pref_names.h" | 19 #include "chrome/common/pref_names.h" |
20 #include "chrome/test/base/in_process_browser_test.h" | 20 #include "chrome/test/base/in_process_browser_test.h" |
21 #include "chrome/test/base/ui_test_utils.h" | 21 #include "chrome/test/base/ui_test_utils.h" |
| 22 #include "content/public/browser/child_process_security_policy.h" |
22 #include "content/public/browser/notification_service.h" | 23 #include "content/public/browser/notification_service.h" |
23 #include "content/public/browser/render_frame_host.h" | 24 #include "content/public/browser/render_frame_host.h" |
24 #include "content/public/browser/render_process_host.h" | 25 #include "content/public/browser/render_process_host.h" |
25 #include "content/public/browser/web_contents.h" | 26 #include "content/public/browser/web_contents.h" |
26 #include "content/public/test/browser_test_utils.h" | 27 #include "content/public/test/browser_test_utils.h" |
27 #include "content/public/test/test_navigation_observer.h" | 28 #include "content/public/test/test_navigation_observer.h" |
28 #include "content/public/test/test_utils.h" | 29 #include "content/public/test/test_utils.h" |
29 #include "extensions/browser/process_manager.h" | 30 #include "extensions/browser/process_manager.h" |
30 #include "extensions/common/value_builder.h" | 31 #include "extensions/common/value_builder.h" |
31 #include "extensions/test/background_page_watcher.h" | 32 #include "extensions/test/background_page_watcher.h" |
(...skipping 635 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
667 // this will go into a new extension process. | 668 // this will go into a new extension process. |
668 const GURL extension_url(extension->url().Resolve("empty.html")); | 669 const GURL extension_url(extension->url().Resolve("empty.html")); |
669 EXPECT_TRUE(content::NavigateIframeToURL(tab, "frame1", extension_url)); | 670 EXPECT_TRUE(content::NavigateIframeToURL(tab, "frame1", extension_url)); |
670 EXPECT_EQ(IfExtensionsIsolated(1, 0), | 671 EXPECT_EQ(IfExtensionsIsolated(1, 0), |
671 pm->GetRenderFrameHostsForExtension(extension->id()).size()); | 672 pm->GetRenderFrameHostsForExtension(extension->id()).size()); |
672 EXPECT_EQ(IfExtensionsIsolated(1, 0), pm->GetAllFrames().size()); | 673 EXPECT_EQ(IfExtensionsIsolated(1, 0), pm->GetAllFrames().size()); |
673 | 674 |
674 content::RenderFrameHost* main_frame = tab->GetMainFrame(); | 675 content::RenderFrameHost* main_frame = tab->GetMainFrame(); |
675 content::RenderFrameHost* extension_frame = ChildFrameAt(main_frame, 0); | 676 content::RenderFrameHost* extension_frame = ChildFrameAt(main_frame, 0); |
676 | 677 |
| 678 // Validate that permissions have been granted for the extension scheme |
| 679 // to the process of the extension iframe. |
| 680 content::ChildProcessSecurityPolicy* policy = |
| 681 content::ChildProcessSecurityPolicy::GetInstance(); |
| 682 EXPECT_TRUE(policy->CanRequestURL( |
| 683 extension_frame->GetProcess()->GetID(), |
| 684 GURL("blob:chrome-extension://some-extension-id/some-guid"))); |
| 685 EXPECT_TRUE(policy->CanRequestURL( |
| 686 main_frame->GetProcess()->GetID(), |
| 687 GURL("blob:chrome-extension://some-extension-id/some-guid"))); |
| 688 EXPECT_TRUE(policy->CanRequestURL( |
| 689 extension_frame->GetProcess()->GetID(), |
| 690 GURL("filesystem:chrome-extension://some-extension-id/some-path"))); |
| 691 EXPECT_TRUE(policy->CanRequestURL( |
| 692 main_frame->GetProcess()->GetID(), |
| 693 GURL("filesystem:chrome-extension://some-extension-id/some-path"))); |
| 694 EXPECT_TRUE(policy->CanRequestURL( |
| 695 extension_frame->GetProcess()->GetID(), |
| 696 GURL("chrome-extension://some-extension-id/resource.html"))); |
| 697 EXPECT_TRUE(policy->CanRequestURL( |
| 698 main_frame->GetProcess()->GetID(), |
| 699 GURL("chrome-extension://some-extension-id/resource.html"))); |
| 700 |
| 701 EXPECT_TRUE(policy->CanCommitURL( |
| 702 extension_frame->GetProcess()->GetID(), |
| 703 GURL("blob:chrome-extension://some-extension-id/some-guid"))); |
| 704 EXPECT_FALSE(policy->CanCommitURL( |
| 705 main_frame->GetProcess()->GetID(), |
| 706 GURL("blob:chrome-extension://some-extension-id/some-guid"))); |
| 707 EXPECT_TRUE(policy->CanCommitURL( |
| 708 extension_frame->GetProcess()->GetID(), |
| 709 GURL("chrome-extension://some-extension-id/resource.html"))); |
| 710 EXPECT_FALSE(policy->CanCommitURL( |
| 711 main_frame->GetProcess()->GetID(), |
| 712 GURL("chrome-extension://some-extension-id/resource.html"))); |
| 713 EXPECT_TRUE(policy->CanCommitURL( |
| 714 extension_frame->GetProcess()->GetID(), |
| 715 GURL("filesystem:chrome-extension://some-extension-id/some-path"))); |
| 716 EXPECT_FALSE(policy->CanCommitURL( |
| 717 main_frame->GetProcess()->GetID(), |
| 718 GURL("filesystem:chrome-extension://some-extension-id/some-path"))); |
| 719 |
677 // Open a new about:blank popup from main frame. This should stay in the web | 720 // Open a new about:blank popup from main frame. This should stay in the web |
678 // process. | 721 // process. |
679 content::WebContents* popup = | 722 content::WebContents* popup = |
680 OpenPopup(main_frame, GURL(url::kAboutBlankURL)); | 723 OpenPopup(main_frame, GURL(url::kAboutBlankURL)); |
681 EXPECT_NE(popup, tab); | 724 EXPECT_NE(popup, tab); |
682 ASSERT_EQ(2, browser()->tab_strip_model()->count()); | 725 ASSERT_EQ(2, browser()->tab_strip_model()->count()); |
683 EXPECT_EQ(IfExtensionsIsolated(1, 0), | 726 EXPECT_EQ(IfExtensionsIsolated(1, 0), |
684 pm->GetRenderFrameHostsForExtension(extension->id()).size()); | 727 pm->GetRenderFrameHostsForExtension(extension->id()).size()); |
685 EXPECT_EQ(IfExtensionsIsolated(1, 0), pm->GetAllFrames().size()); | 728 EXPECT_EQ(IfExtensionsIsolated(1, 0), pm->GetAllFrames().size()); |
686 | 729 |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
790 popup->GetMainFrame()->GetLastCommittedOrigin()); | 833 popup->GetMainFrame()->GetLastCommittedOrigin()); |
791 EXPECT_EQ("foo", GetTextContent(popup->GetMainFrame())); | 834 EXPECT_EQ("foo", GetTextContent(popup->GetMainFrame())); |
792 | 835 |
793 EXPECT_EQ(3 + i, | 836 EXPECT_EQ(3 + i, |
794 pm->GetRenderFrameHostsForExtension(extension->id()).size()); | 837 pm->GetRenderFrameHostsForExtension(extension->id()).size()); |
795 EXPECT_EQ(3 + i, pm->GetAllFrames().size()); | 838 EXPECT_EQ(3 + i, pm->GetAllFrames().size()); |
796 } | 839 } |
797 } | 840 } |
798 | 841 |
799 } // namespace extensions | 842 } // namespace extensions |
OLD | NEW |