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

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

Issue 2399853003: [M54 merge] Lock down creation of blob:chrome-extension URLs from non-extension processes. (Closed)
Patch Set: Rebase Created 4 years, 2 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"
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 660 matching lines...) Expand 10 before | Expand all | Expand 10 after
692 // this will go into a new extension process. 693 // this will go into a new extension process.
693 const GURL extension_url(extension->url().Resolve("empty.html")); 694 const GURL extension_url(extension->url().Resolve("empty.html"));
694 EXPECT_TRUE(content::NavigateIframeToURL(tab, "frame1", extension_url)); 695 EXPECT_TRUE(content::NavigateIframeToURL(tab, "frame1", extension_url));
695 EXPECT_EQ(IfExtensionsIsolated(1, 0), 696 EXPECT_EQ(IfExtensionsIsolated(1, 0),
696 pm->GetRenderFrameHostsForExtension(extension->id()).size()); 697 pm->GetRenderFrameHostsForExtension(extension->id()).size());
697 EXPECT_EQ(IfExtensionsIsolated(1, 0), pm->GetAllFrames().size()); 698 EXPECT_EQ(IfExtensionsIsolated(1, 0), pm->GetAllFrames().size());
698 699
699 content::RenderFrameHost* main_frame = tab->GetMainFrame(); 700 content::RenderFrameHost* main_frame = tab->GetMainFrame();
700 content::RenderFrameHost* extension_frame = ChildFrameAt(main_frame, 0); 701 content::RenderFrameHost* extension_frame = ChildFrameAt(main_frame, 0);
701 702
703 // Validate that permissions have been granted for the extension scheme
704 // to the process of the extension iframe.
705 content::ChildProcessSecurityPolicy* policy =
706 content::ChildProcessSecurityPolicy::GetInstance();
707 EXPECT_TRUE(policy->CanRequestURL(
708 extension_frame->GetProcess()->GetID(),
709 GURL("blob:chrome-extension://some-extension-id/some-guid")));
710 EXPECT_TRUE(policy->CanRequestURL(
711 main_frame->GetProcess()->GetID(),
712 GURL("blob:chrome-extension://some-extension-id/some-guid")));
713 EXPECT_TRUE(policy->CanRequestURL(
714 extension_frame->GetProcess()->GetID(),
715 GURL("filesystem:chrome-extension://some-extension-id/some-path")));
716 EXPECT_TRUE(policy->CanRequestURL(
717 main_frame->GetProcess()->GetID(),
718 GURL("filesystem:chrome-extension://some-extension-id/some-path")));
719 EXPECT_TRUE(policy->CanRequestURL(
720 extension_frame->GetProcess()->GetID(),
721 GURL("chrome-extension://some-extension-id/resource.html")));
722 EXPECT_TRUE(policy->CanRequestURL(
723 main_frame->GetProcess()->GetID(),
724 GURL("chrome-extension://some-extension-id/resource.html")));
725
726 if (extensions::IsIsolateExtensionsEnabled()) {
727 EXPECT_TRUE(policy->CanCommitURL(
728 extension_frame->GetProcess()->GetID(),
729 GURL("blob:chrome-extension://some-extension-id/some-guid")));
730 EXPECT_FALSE(policy->CanCommitURL(
731 main_frame->GetProcess()->GetID(),
732 GURL("blob:chrome-extension://some-extension-id/some-guid")));
733 EXPECT_TRUE(policy->CanCommitURL(
734 extension_frame->GetProcess()->GetID(),
735 GURL("chrome-extension://some-extension-id/resource.html")));
736 EXPECT_FALSE(policy->CanCommitURL(
737 main_frame->GetProcess()->GetID(),
738 GURL("chrome-extension://some-extension-id/resource.html")));
739 EXPECT_TRUE(policy->CanCommitURL(
740 extension_frame->GetProcess()->GetID(),
741 GURL("filesystem:chrome-extension://some-extension-id/some-path")));
742 EXPECT_FALSE(policy->CanCommitURL(
743 main_frame->GetProcess()->GetID(),
744 GURL("filesystem:chrome-extension://some-extension-id/some-path")));
745 }
746
702 // Open a new about:blank popup from main frame. This should stay in the web 747 // Open a new about:blank popup from main frame. This should stay in the web
703 // process. 748 // process.
704 content::WebContents* popup = 749 content::WebContents* popup =
705 OpenPopup(main_frame, GURL(url::kAboutBlankURL)); 750 OpenPopup(main_frame, GURL(url::kAboutBlankURL));
706 EXPECT_NE(popup, tab); 751 EXPECT_NE(popup, tab);
707 ASSERT_EQ(2, browser()->tab_strip_model()->count()); 752 ASSERT_EQ(2, browser()->tab_strip_model()->count());
708 EXPECT_EQ(IfExtensionsIsolated(1, 0), 753 EXPECT_EQ(IfExtensionsIsolated(1, 0),
709 pm->GetRenderFrameHostsForExtension(extension->id()).size()); 754 pm->GetRenderFrameHostsForExtension(extension->id()).size());
710 EXPECT_EQ(IfExtensionsIsolated(1, 0), pm->GetAllFrames().size()); 755 EXPECT_EQ(IfExtensionsIsolated(1, 0), pm->GetAllFrames().size());
711 756
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after
912 EXPECT_TRUE(ExecuteScriptAndExtractBool( 957 EXPECT_TRUE(ExecuteScriptAndExtractBool(
913 popup, "window.domAutomationController.send(!!window.opener)", 958 popup, "window.domAutomationController.send(!!window.opener)",
914 &is_opener_defined)); 959 &is_opener_defined));
915 EXPECT_TRUE(is_opener_defined); 960 EXPECT_TRUE(is_opener_defined);
916 961
917 // Verify that postMessage to window.opener works. 962 // Verify that postMessage to window.opener works.
918 VerifyPostMessageToOpener(popup->GetMainFrame(), extension_frame); 963 VerifyPostMessageToOpener(popup->GetMainFrame(), extension_frame);
919 } 964 }
920 965
921 } // namespace extensions 966 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698