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

Side by Side Diff: content/browser/renderer_host/render_view_host_unittest.cc

Issue 1723763002: Add WebDragData to blink::WebView::dragtargetDrop (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix browser plugin guest logic Created 4 years, 6 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 <stdint.h> 5 #include <stdint.h>
6 6
7 #include "base/macros.h" 7 #include "base/macros.h"
8 #include "base/path_service.h" 8 #include "base/path_service.h"
9 #include "base/strings/utf_string_conversions.h" 9 #include "base/strings/utf_string_conversions.h"
10 #include "content/browser/child_process_security_policy_impl.h" 10 #include "content/browser/child_process_security_policy_impl.h"
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after
163 gfx::Point screen_point; 163 gfx::Point screen_point;
164 // We use "//foo/bar" path (rather than "/foo/bar") since dragged paths are 164 // We use "//foo/bar" path (rather than "/foo/bar") since dragged paths are
165 // expected to be absolute on any platforms. 165 // expected to be absolute on any platforms.
166 base::FilePath highlighted_file_path(FILE_PATH_LITERAL("//tmp/foo.html")); 166 base::FilePath highlighted_file_path(FILE_PATH_LITERAL("//tmp/foo.html"));
167 base::FilePath dragged_file_path(FILE_PATH_LITERAL("//tmp/image.jpg")); 167 base::FilePath dragged_file_path(FILE_PATH_LITERAL("//tmp/image.jpg"));
168 base::FilePath sensitive_file_path(FILE_PATH_LITERAL("//etc/passwd")); 168 base::FilePath sensitive_file_path(FILE_PATH_LITERAL("//etc/passwd"));
169 GURL highlighted_file_url = net::FilePathToFileURL(highlighted_file_path); 169 GURL highlighted_file_url = net::FilePathToFileURL(highlighted_file_path);
170 GURL dragged_file_url = net::FilePathToFileURL(dragged_file_path); 170 GURL dragged_file_url = net::FilePathToFileURL(dragged_file_path);
171 GURL sensitive_file_url = net::FilePathToFileURL(sensitive_file_path); 171 GURL sensitive_file_url = net::FilePathToFileURL(sensitive_file_path);
172 dropped_data.url = highlighted_file_url; 172 dropped_data.url = highlighted_file_url;
173 dropped_data.has_url = true;
173 dropped_data.filenames.push_back( 174 dropped_data.filenames.push_back(
174 ui::FileInfo(dragged_file_path, base::FilePath())); 175 ui::FileInfo(dragged_file_path, base::FilePath()));
175 176
177 rvh()->FilterDropData(&dropped_data);
176 rvh()->DragTargetDragEnter(dropped_data, client_point, screen_point, 178 rvh()->DragTargetDragEnter(dropped_data, client_point, screen_point,
177 blink::WebDragOperationNone, 0); 179 blink::WebDragOperationNone, 0);
178 180
179 int id = process()->GetID(); 181 int id = process()->GetID();
180 ChildProcessSecurityPolicyImpl* policy = 182 ChildProcessSecurityPolicyImpl* policy =
181 ChildProcessSecurityPolicyImpl::GetInstance(); 183 ChildProcessSecurityPolicyImpl::GetInstance();
182 184
185 // Permissions are not granted at DragEnter.
183 EXPECT_FALSE(policy->CanRequestURL(id, highlighted_file_url)); 186 EXPECT_FALSE(policy->CanRequestURL(id, highlighted_file_url));
184 EXPECT_FALSE(policy->CanReadFile(id, highlighted_file_path)); 187 EXPECT_FALSE(policy->CanReadFile(id, highlighted_file_path));
185 EXPECT_TRUE(policy->CanRequestURL(id, dragged_file_url)); 188 EXPECT_FALSE(policy->CanRequestURL(id, dragged_file_url));
186 EXPECT_TRUE(policy->CanReadFile(id, dragged_file_path)); 189 EXPECT_FALSE(policy->CanReadFile(id, dragged_file_path));
187 EXPECT_FALSE(policy->CanRequestURL(id, sensitive_file_url)); 190 EXPECT_FALSE(policy->CanRequestURL(id, sensitive_file_url));
188 EXPECT_FALSE(policy->CanReadFile(id, sensitive_file_path)); 191 EXPECT_FALSE(policy->CanReadFile(id, sensitive_file_path));
189 } 192 }
190 193
191 TEST_F(RenderViewHostTest, MessageWithBadHistoryItemFiles) { 194 TEST_F(RenderViewHostTest, MessageWithBadHistoryItemFiles) {
192 base::FilePath file_path; 195 base::FilePath file_path;
193 EXPECT_TRUE(PathService::Get(base::DIR_TEMP, &file_path)); 196 EXPECT_TRUE(PathService::Get(base::DIR_TEMP, &file_path));
194 file_path = file_path.AppendASCII("foo"); 197 file_path = file_path.AppendASCII("foo");
195 EXPECT_EQ(0, process()->bad_msg_count()); 198 EXPECT_EQ(0, process()->bad_msg_count());
196 test_rvh()->TestOnUpdateStateWithFile(-1, file_path); 199 test_rvh()->TestOnUpdateStateWithFile(-1, file_path);
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
303 const std::string data_url = "data:image/gif;base64," 306 const std::string data_url = "data:image/gif;base64,"
304 "R0lGODlhAQABAIAAAAUEBAAAACwAAAAAAQABAAACAkQBADs="; 307 "R0lGODlhAQABAIAAAAUEBAAAACwAAAAAAQABAAACAkQBADs=";
305 308
306 tester->Reset(); 309 tester->Reset();
307 tester->Test(data_url); 310 tester->Test(data_url);
308 EXPECT_EQ(tester->UrlString(), data_url); 311 EXPECT_EQ(tester->UrlString(), data_url);
309 EXPECT_TRUE(tester->IsDownloaded()); 312 EXPECT_TRUE(tester->IsDownloaded());
310 } 313 }
311 314
312 } // namespace content 315 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698