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

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

Issue 2385553002: Revert of Lock down the registration of blob:chrome-extension:// URLs (Closed)
Patch Set: 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
« no previous file with comments | « chrome/browser/devtools/devtools_ui_bindings.cc ('k') | content/browser/bad_message.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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"
23 #include "content/public/browser/notification_service.h" 22 #include "content/public/browser/notification_service.h"
24 #include "content/public/browser/render_frame_host.h" 23 #include "content/public/browser/render_frame_host.h"
25 #include "content/public/browser/render_process_host.h" 24 #include "content/public/browser/render_process_host.h"
26 #include "content/public/browser/web_contents.h" 25 #include "content/public/browser/web_contents.h"
27 #include "content/public/test/browser_test_utils.h" 26 #include "content/public/test/browser_test_utils.h"
28 #include "content/public/test/test_navigation_observer.h" 27 #include "content/public/test/test_navigation_observer.h"
29 #include "content/public/test/test_utils.h" 28 #include "content/public/test/test_utils.h"
30 #include "extensions/browser/process_manager.h" 29 #include "extensions/browser/process_manager.h"
31 #include "extensions/common/value_builder.h" 30 #include "extensions/common/value_builder.h"
32 #include "extensions/test/background_page_watcher.h" 31 #include "extensions/test/background_page_watcher.h"
(...skipping 635 matching lines...) Expand 10 before | Expand all | Expand 10 after
668 // this will go into a new extension process. 667 // this will go into a new extension process.
669 const GURL extension_url(extension->url().Resolve("empty.html")); 668 const GURL extension_url(extension->url().Resolve("empty.html"));
670 EXPECT_TRUE(content::NavigateIframeToURL(tab, "frame1", extension_url)); 669 EXPECT_TRUE(content::NavigateIframeToURL(tab, "frame1", extension_url));
671 EXPECT_EQ(IfExtensionsIsolated(1, 0), 670 EXPECT_EQ(IfExtensionsIsolated(1, 0),
672 pm->GetRenderFrameHostsForExtension(extension->id()).size()); 671 pm->GetRenderFrameHostsForExtension(extension->id()).size());
673 EXPECT_EQ(IfExtensionsIsolated(1, 0), pm->GetAllFrames().size()); 672 EXPECT_EQ(IfExtensionsIsolated(1, 0), pm->GetAllFrames().size());
674 673
675 content::RenderFrameHost* main_frame = tab->GetMainFrame(); 674 content::RenderFrameHost* main_frame = tab->GetMainFrame();
676 content::RenderFrameHost* extension_frame = ChildFrameAt(main_frame, 0); 675 content::RenderFrameHost* extension_frame = ChildFrameAt(main_frame, 0);
677 676
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
720 // Open a new about:blank popup from main frame. This should stay in the web 677 // Open a new about:blank popup from main frame. This should stay in the web
721 // process. 678 // process.
722 content::WebContents* popup = 679 content::WebContents* popup =
723 OpenPopup(main_frame, GURL(url::kAboutBlankURL)); 680 OpenPopup(main_frame, GURL(url::kAboutBlankURL));
724 EXPECT_NE(popup, tab); 681 EXPECT_NE(popup, tab);
725 ASSERT_EQ(2, browser()->tab_strip_model()->count()); 682 ASSERT_EQ(2, browser()->tab_strip_model()->count());
726 EXPECT_EQ(IfExtensionsIsolated(1, 0), 683 EXPECT_EQ(IfExtensionsIsolated(1, 0),
727 pm->GetRenderFrameHostsForExtension(extension->id()).size()); 684 pm->GetRenderFrameHostsForExtension(extension->id()).size());
728 EXPECT_EQ(IfExtensionsIsolated(1, 0), pm->GetAllFrames().size()); 685 EXPECT_EQ(IfExtensionsIsolated(1, 0), pm->GetAllFrames().size());
729 686
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
833 popup->GetMainFrame()->GetLastCommittedOrigin()); 790 popup->GetMainFrame()->GetLastCommittedOrigin());
834 EXPECT_EQ("foo", GetTextContent(popup->GetMainFrame())); 791 EXPECT_EQ("foo", GetTextContent(popup->GetMainFrame()));
835 792
836 EXPECT_EQ(3 + i, 793 EXPECT_EQ(3 + i,
837 pm->GetRenderFrameHostsForExtension(extension->id()).size()); 794 pm->GetRenderFrameHostsForExtension(extension->id()).size());
838 EXPECT_EQ(3 + i, pm->GetAllFrames().size()); 795 EXPECT_EQ(3 + i, pm->GetAllFrames().size());
839 } 796 }
840 } 797 }
841 798
842 } // namespace extensions 799 } // namespace extensions
OLDNEW
« no previous file with comments | « chrome/browser/devtools/devtools_ui_bindings.cc ('k') | content/browser/bad_message.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698