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

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

Issue 18129002: Update the child process security policy to use explicit permission grants. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Change RVH to use FileChooserParam mode Created 7 years, 5 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 | Annotate | Revision Log
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 "base/path_service.h" 5 #include "base/path_service.h"
6 #include "base/strings/utf_string_conversions.h" 6 #include "base/strings/utf_string_conversions.h"
7 #include "content/browser/child_process_security_policy_impl.h" 7 #include "content/browser/child_process_security_policy_impl.h"
8 #include "content/browser/renderer_host/test_render_view_host.h" 8 #include "content/browser/renderer_host/test_render_view_host.h"
9 #include "content/browser/web_contents/navigation_controller_impl.h" 9 #include "content/browser/web_contents/navigation_controller_impl.h"
10 #include "content/common/input_messages.h" 10 #include "content/common/input_messages.h"
(...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after
260 #endif 260 #endif
261 261
262 TEST_F(RenderViewHostTest, MessageWithBadHistoryItemFiles) { 262 TEST_F(RenderViewHostTest, MessageWithBadHistoryItemFiles) {
263 base::FilePath file_path; 263 base::FilePath file_path;
264 EXPECT_TRUE(PathService::Get(base::DIR_TEMP, &file_path)); 264 EXPECT_TRUE(PathService::Get(base::DIR_TEMP, &file_path));
265 file_path = file_path.AppendASCII("foo"); 265 file_path = file_path.AppendASCII("foo");
266 EXPECT_EQ(0, process()->bad_msg_count()); 266 EXPECT_EQ(0, process()->bad_msg_count());
267 test_rvh()->TestOnUpdateStateWithFile(process()->GetID(), file_path); 267 test_rvh()->TestOnUpdateStateWithFile(process()->GetID(), file_path);
268 EXPECT_EQ(1, process()->bad_msg_count()); 268 EXPECT_EQ(1, process()->bad_msg_count());
269 269
270 ChildProcessSecurityPolicyImpl::GetInstance()->GrantPermissionsForFile( 270 ChildProcessSecurityPolicyImpl::GetInstance()->GrantReadFile(
271 process()->GetID(), file_path, 271 process()->GetID(), file_path);
272 base::PLATFORM_FILE_OPEN |
273 base::PLATFORM_FILE_READ |
274 base::PLATFORM_FILE_EXCLUSIVE_READ |
275 base::PLATFORM_FILE_ASYNC);
276 test_rvh()->TestOnUpdateStateWithFile(process()->GetID(), file_path); 272 test_rvh()->TestOnUpdateStateWithFile(process()->GetID(), file_path);
277 EXPECT_EQ(1, process()->bad_msg_count()); 273 EXPECT_EQ(1, process()->bad_msg_count());
278 } 274 }
279 275
280 TEST_F(RenderViewHostTest, NavigationWithBadHistoryItemFiles) { 276 TEST_F(RenderViewHostTest, NavigationWithBadHistoryItemFiles) {
281 GURL url("http://www.google.com"); 277 GURL url("http://www.google.com");
282 base::FilePath file_path; 278 base::FilePath file_path;
283 EXPECT_TRUE(PathService::Get(base::DIR_TEMP, &file_path)); 279 EXPECT_TRUE(PathService::Get(base::DIR_TEMP, &file_path));
284 file_path = file_path.AppendASCII("bar"); 280 file_path = file_path.AppendASCII("bar");
285 EXPECT_EQ(0, process()->bad_msg_count()); 281 EXPECT_EQ(0, process()->bad_msg_count());
286 test_rvh()->SendNavigateWithFile(1, url, file_path); 282 test_rvh()->SendNavigateWithFile(1, url, file_path);
287 EXPECT_EQ(1, process()->bad_msg_count()); 283 EXPECT_EQ(1, process()->bad_msg_count());
288 284
289 ChildProcessSecurityPolicyImpl::GetInstance()->GrantPermissionsForFile( 285 ChildProcessSecurityPolicyImpl::GetInstance()->GrantReadFile(
290 process()->GetID(), file_path, 286 process()->GetID(), file_path);
291 base::PLATFORM_FILE_OPEN |
292 base::PLATFORM_FILE_READ |
293 base::PLATFORM_FILE_EXCLUSIVE_READ |
294 base::PLATFORM_FILE_ASYNC);
295 test_rvh()->SendNavigateWithFile(process()->GetID(), url, file_path); 287 test_rvh()->SendNavigateWithFile(process()->GetID(), url, file_path);
296 EXPECT_EQ(1, process()->bad_msg_count()); 288 EXPECT_EQ(1, process()->bad_msg_count());
297 } 289 }
298 290
299 } // namespace content 291 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/renderer_host/render_view_host_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