summaryrefslogtreecommitdiffstats
path: root/content/browser/child_process_security_policy_unittest.cc
diff options
context:
space:
mode:
authorjohnnyg@chromium.org <johnnyg@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-04-12 00:01:51 +0000
committerjohnnyg@chromium.org <johnnyg@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-04-12 00:01:51 +0000
commit600ea40f950f2c2a177428986b9a2d557e7a8c90 (patch)
treee1d602a1e424758b8c18aee583e4dbbef75427da /content/browser/child_process_security_policy_unittest.cc
parent491af0cde7544b0f973296782dbb1daccbc3d603 (diff)
downloadchromium_src-600ea40f950f2c2a177428986b9a2d557e7a8c90.zip
chromium_src-600ea40f950f2c2a177428986b9a2d557e7a8c90.tar.gz
chromium_src-600ea40f950f2c2a177428986b9a2d557e7a8c90.tar.bz2
Add a path for a web page to request the enumeration of a directory. This, together with a WebKit change, will allow a drag-and-drop on a Directory Upload control (<input type=file webkitdirectory>) which provides only the path to the renderer, to correctly populate the control as if the user had selected that directory in a file picker.
BUG=58977 TEST=drag-and-drop on directory upload control (with upstream change) Review URL: http://codereview.chromium.org/6623015 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@81183 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content/browser/child_process_security_policy_unittest.cc')
-rw-r--r--content/browser/child_process_security_policy_unittest.cc32
1 files changed, 32 insertions, 0 deletions
diff --git a/content/browser/child_process_security_policy_unittest.cc b/content/browser/child_process_security_policy_unittest.cc
index 8ad4ad4..e20178e 100644
--- a/content/browser/child_process_security_policy_unittest.cc
+++ b/content/browser/child_process_security_policy_unittest.cc
@@ -215,6 +215,38 @@ TEST_F(ChildProcessSecurityPolicyTest, CanReadFiles) {
p->Remove(kRendererID);
}
+TEST_F(ChildProcessSecurityPolicyTest, CanReadDirectories) {
+ ChildProcessSecurityPolicy* p = ChildProcessSecurityPolicy::GetInstance();
+
+ p->Add(kRendererID);
+
+ EXPECT_FALSE(p->CanReadDirectory(kRendererID,
+ FilePath(FILE_PATH_LITERAL("/etc/"))));
+ p->GrantReadDirectory(kRendererID, FilePath(FILE_PATH_LITERAL("/etc/")));
+ EXPECT_TRUE(p->CanReadDirectory(kRendererID,
+ FilePath(FILE_PATH_LITERAL("/etc/"))));
+ EXPECT_TRUE(p->CanReadFile(kRendererID,
+ FilePath(FILE_PATH_LITERAL("/etc/passwd"))));
+
+ p->Remove(kRendererID);
+ p->Add(kRendererID);
+
+ EXPECT_FALSE(p->CanReadDirectory(kRendererID,
+ FilePath(FILE_PATH_LITERAL("/etc/"))));
+ EXPECT_FALSE(p->CanReadFile(kRendererID,
+ FilePath(FILE_PATH_LITERAL("/etc/passwd"))));
+
+ // Just granting read permission as a file doesn't imply reading as a
+ // directory.
+ p->GrantReadFile(kRendererID, FilePath(FILE_PATH_LITERAL("/etc/")));
+ EXPECT_TRUE(p->CanReadFile(kRendererID,
+ FilePath(FILE_PATH_LITERAL("/etc/passwd"))));
+ EXPECT_FALSE(p->CanReadDirectory(kRendererID,
+ FilePath(FILE_PATH_LITERAL("/etc/"))));
+
+ p->Remove(kRendererID);
+}
+
TEST_F(ChildProcessSecurityPolicyTest, FilePermissions) {
ChildProcessSecurityPolicy* p = ChildProcessSecurityPolicy::GetInstance();