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

Unified Diff: content/browser/renderer_host/render_view_host_unittest.cc

Issue 10397002: DragEnter grants both read and navigate permissions to files. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 7 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
« no previous file with comments | « content/browser/renderer_host/render_view_host_impl.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/renderer_host/render_view_host_unittest.cc
===================================================================
--- content/browser/renderer_host/render_view_host_unittest.cc (revision 136090)
+++ content/browser/renderer_host/render_view_host_unittest.cc (working copy)
@@ -2,6 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+#include "base/utf_string_conversions.h"
#include "content/browser/child_process_security_policy_impl.h"
#include "content/browser/renderer_host/test_render_view_host.h"
#include "content/browser/web_contents/navigation_controller_impl.h"
@@ -164,12 +165,25 @@
WebDropData dropped_data;
gfx::Point client_point;
gfx::Point screen_point;
- GURL file_url = GURL("file:///etc/passwd");
- dropped_data.url = file_url;
+ FilePath highlighted_file_path(FILE_PATH_LITERAL("/etc/passwd"));
+ FilePath selected_file_path(FILE_PATH_LITERAL("/tmp/image.jpg"));
+ GURL highlighted_file_url = net::FilePathToFileURL(highlighted_file_path);
+ GURL selected_file_url = net::FilePathToFileURL(selected_file_path);
+ dropped_data.url = highlighted_file_url;
+ dropped_data.filenames.push_back(WebDropData::FileInfo(
+ UTF8ToUTF16(selected_file_path.AsUTF8Unsafe()), string16()));
+
rvh()->DragTargetDragEnter(dropped_data, client_point, screen_point,
WebKit::WebDragOperationNone);
- EXPECT_FALSE(ChildProcessSecurityPolicyImpl::GetInstance()->CanRequestURL(
- process()->GetID(), file_url));
+
+ int id = process()->GetID();
+ ChildProcessSecurityPolicyImpl* policy =
+ ChildProcessSecurityPolicyImpl::GetInstance();
+
+ EXPECT_FALSE(policy->CanRequestURL(id, highlighted_file_url));
+ EXPECT_FALSE(policy->CanReadFile(id, highlighted_file_path));
+ EXPECT_FALSE(policy->CanRequestURL(id, selected_file_url));
+ EXPECT_TRUE(policy->CanReadFile(id, selected_file_path));
}
// The test that follow trigger DCHECKS in debug build.
« no previous file with comments | « content/browser/renderer_host/render_view_host_impl.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698