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

Unified Diff: content/browser/child_process_security_policy_unittest.cc

Issue 1362433002: Fix for "chrome://" links in PDFs. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Small fix. Created 5 years, 3 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 side-by-side diff with in-line comments
Download patch
Index: content/browser/child_process_security_policy_unittest.cc
diff --git a/content/browser/child_process_security_policy_unittest.cc b/content/browser/child_process_security_policy_unittest.cc
index beb85b69cedc1ca2cc3443a37c99069dc8e0f709..6cba102e288177f821ba33b68ca6f89c0aa47468 100644
--- a/content/browser/child_process_security_policy_unittest.cc
+++ b/content/browser/child_process_security_policy_unittest.cc
@@ -16,6 +16,7 @@
#include "storage/common/fileapi/file_system_types.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "url/gurl.h"
+#include "url/origin.h"
namespace content {
namespace {
@@ -697,4 +698,44 @@ TEST_F(ChildProcessSecurityPolicyTest, RemoveRace) {
EXPECT_FALSE(p->HasWebUIBindings(kRendererID));
}
+// Test the granting of origin permissions, and their interactions with
+// granting scheme permissions.
+TEST_F(ChildProcessSecurityPolicyTest, OriginGranting) {
+ ChildProcessSecurityPolicyImpl* p =
+ ChildProcessSecurityPolicyImpl::GetInstance();
+
+ p->Add(kRendererID);
+
+ GURL url_foo1("chrome://foo/resource1");
+ GURL url_foo2("chrome://foo/resource2");
+ GURL url_bar("chrome://bar/resource3");
+
+ EXPECT_FALSE(p->CanRequestURL(kRendererID, url_foo1));
+ EXPECT_FALSE(p->CanRequestURL(kRendererID, url_foo2));
+ EXPECT_FALSE(p->CanRequestURL(kRendererID, url_bar));
+ EXPECT_FALSE(p->CanCommitURL(kRendererID, url_foo1));
+ EXPECT_FALSE(p->CanCommitURL(kRendererID, url_foo2));
+ EXPECT_FALSE(p->CanCommitURL(kRendererID, url_bar));
+
+ p->GrantOrigin(kRendererID, url::Origin(url_foo1));
+
+ EXPECT_TRUE(p->CanRequestURL(kRendererID, url_foo1));
+ EXPECT_TRUE(p->CanRequestURL(kRendererID, url_foo2));
+ EXPECT_FALSE(p->CanRequestURL(kRendererID, url_bar));
+ EXPECT_TRUE(p->CanCommitURL(kRendererID, url_foo1));
+ EXPECT_TRUE(p->CanCommitURL(kRendererID, url_foo2));
+ EXPECT_FALSE(p->CanCommitURL(kRendererID, url_bar));
+
+ p->GrantScheme(kRendererID, kChromeUIScheme);
+
+ EXPECT_TRUE(p->CanRequestURL(kRendererID, url_foo1));
+ EXPECT_TRUE(p->CanRequestURL(kRendererID, url_foo2));
+ EXPECT_TRUE(p->CanRequestURL(kRendererID, url_bar));
+ EXPECT_TRUE(p->CanCommitURL(kRendererID, url_foo1));
+ EXPECT_TRUE(p->CanCommitURL(kRendererID, url_foo2));
+ EXPECT_TRUE(p->CanCommitURL(kRendererID, url_bar));
+
+ p->Remove(kRendererID);
+}
+
} // namespace content
« no previous file with comments | « content/browser/child_process_security_policy_impl.cc ('k') | content/public/browser/child_process_security_policy.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698