| OLD | NEW |
| 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/frame_host/render_frame_host_impl.h" | 8 #include "content/browser/frame_host/render_frame_host_impl.h" |
| 9 #include "content/browser/renderer_host/render_view_host_delegate_view.h" | 9 #include "content/browser/renderer_host/render_view_host_delegate_view.h" |
| 10 #include "content/common/input_messages.h" | 10 #include "content/common/input_messages.h" |
| (...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 207 EXPECT_TRUE(policy->CanReadFile(id, dragged_file_path)); | 207 EXPECT_TRUE(policy->CanReadFile(id, dragged_file_path)); |
| 208 EXPECT_FALSE(policy->CanRequestURL(id, sensitive_file_url)); | 208 EXPECT_FALSE(policy->CanRequestURL(id, sensitive_file_url)); |
| 209 EXPECT_FALSE(policy->CanReadFile(id, sensitive_file_path)); | 209 EXPECT_FALSE(policy->CanReadFile(id, sensitive_file_path)); |
| 210 } | 210 } |
| 211 | 211 |
| 212 TEST_F(RenderViewHostTest, MessageWithBadHistoryItemFiles) { | 212 TEST_F(RenderViewHostTest, MessageWithBadHistoryItemFiles) { |
| 213 base::FilePath file_path; | 213 base::FilePath file_path; |
| 214 EXPECT_TRUE(PathService::Get(base::DIR_TEMP, &file_path)); | 214 EXPECT_TRUE(PathService::Get(base::DIR_TEMP, &file_path)); |
| 215 file_path = file_path.AppendASCII("foo"); | 215 file_path = file_path.AppendASCII("foo"); |
| 216 EXPECT_EQ(0, process()->bad_msg_count()); | 216 EXPECT_EQ(0, process()->bad_msg_count()); |
| 217 test_rvh()->TestOnUpdateStateWithFile(process()->GetID(), file_path); | 217 test_rvh()->TestOnUpdateStateWithFile(-1, file_path); |
| 218 EXPECT_EQ(1, process()->bad_msg_count()); | 218 EXPECT_EQ(1, process()->bad_msg_count()); |
| 219 | 219 |
| 220 ChildProcessSecurityPolicyImpl::GetInstance()->GrantReadFile( | 220 ChildProcessSecurityPolicyImpl::GetInstance()->GrantReadFile( |
| 221 process()->GetID(), file_path); | 221 process()->GetID(), file_path); |
| 222 test_rvh()->TestOnUpdateStateWithFile(process()->GetID(), file_path); | 222 test_rvh()->TestOnUpdateStateWithFile(-1, file_path); |
| 223 EXPECT_EQ(1, process()->bad_msg_count()); | 223 EXPECT_EQ(1, process()->bad_msg_count()); |
| 224 } | 224 } |
| 225 | 225 |
| 226 TEST_F(RenderViewHostTest, NavigationWithBadHistoryItemFiles) { | 226 TEST_F(RenderViewHostTest, NavigationWithBadHistoryItemFiles) { |
| 227 GURL url("http://www.google.com"); | 227 GURL url("http://www.google.com"); |
| 228 base::FilePath file_path; | 228 base::FilePath file_path; |
| 229 EXPECT_TRUE(PathService::Get(base::DIR_TEMP, &file_path)); | 229 EXPECT_TRUE(PathService::Get(base::DIR_TEMP, &file_path)); |
| 230 file_path = file_path.AppendASCII("bar"); | 230 file_path = file_path.AppendASCII("bar"); |
| 231 EXPECT_EQ(0, process()->bad_msg_count()); | 231 EXPECT_EQ(0, process()->bad_msg_count()); |
| 232 test_rvh()->SendNavigateWithFile(1, url, file_path); | 232 test_rvh()->SendNavigateWithFile(1, url, file_path); |
| 233 EXPECT_EQ(1, process()->bad_msg_count()); | 233 EXPECT_EQ(1, process()->bad_msg_count()); |
| 234 | 234 |
| 235 ChildProcessSecurityPolicyImpl::GetInstance()->GrantReadFile( | 235 ChildProcessSecurityPolicyImpl::GetInstance()->GrantReadFile( |
| 236 process()->GetID(), file_path); | 236 process()->GetID(), file_path); |
| 237 test_rvh()->SendNavigateWithFile(process()->GetID(), url, file_path); | 237 test_rvh()->SendNavigateWithFile(process()->GetID(), url, file_path); |
| 238 EXPECT_EQ(1, process()->bad_msg_count()); | 238 EXPECT_EQ(1, process()->bad_msg_count()); |
| 239 } | 239 } |
| 240 | 240 |
| 241 TEST_F(RenderViewHostTest, RoutingIdSane) { | 241 TEST_F(RenderViewHostTest, RoutingIdSane) { |
| 242 RenderFrameHostImpl* root_rfh = | 242 RenderFrameHostImpl* root_rfh = |
| 243 contents()->GetFrameTree()->root()->current_frame_host(); | 243 contents()->GetFrameTree()->root()->current_frame_host(); |
| 244 EXPECT_EQ(test_rvh()->GetProcess(), root_rfh->GetProcess()); | 244 EXPECT_EQ(test_rvh()->GetProcess(), root_rfh->GetProcess()); |
| 245 EXPECT_NE(test_rvh()->GetRoutingID(), root_rfh->routing_id()); | 245 EXPECT_NE(test_rvh()->GetRoutingID(), root_rfh->routing_id()); |
| 246 } | 246 } |
| 247 | 247 |
| 248 } // namespace content | 248 } // namespace content |
| OLD | NEW |