| 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 <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 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 188 EXPECT_FALSE(policy->CanReadFile(id, dragged_file_path)); | 188 EXPECT_FALSE(policy->CanReadFile(id, dragged_file_path)); |
| 189 EXPECT_FALSE(policy->CanRequestURL(id, sensitive_file_url)); | 189 EXPECT_FALSE(policy->CanRequestURL(id, sensitive_file_url)); |
| 190 EXPECT_FALSE(policy->CanReadFile(id, sensitive_file_path)); | 190 EXPECT_FALSE(policy->CanReadFile(id, sensitive_file_path)); |
| 191 } | 191 } |
| 192 | 192 |
| 193 TEST_F(RenderViewHostTest, MessageWithBadHistoryItemFiles) { | 193 TEST_F(RenderViewHostTest, MessageWithBadHistoryItemFiles) { |
| 194 base::FilePath file_path; | 194 base::FilePath file_path; |
| 195 EXPECT_TRUE(PathService::Get(base::DIR_TEMP, &file_path)); | 195 EXPECT_TRUE(PathService::Get(base::DIR_TEMP, &file_path)); |
| 196 file_path = file_path.AppendASCII("foo"); | 196 file_path = file_path.AppendASCII("foo"); |
| 197 EXPECT_EQ(0, process()->bad_msg_count()); | 197 EXPECT_EQ(0, process()->bad_msg_count()); |
| 198 test_rvh()->TestOnUpdateStateWithFile(-1, file_path); | 198 test_rvh()->TestOnUpdateStateWithFile(file_path); |
| 199 EXPECT_EQ(1, process()->bad_msg_count()); | 199 EXPECT_EQ(1, process()->bad_msg_count()); |
| 200 | 200 |
| 201 ChildProcessSecurityPolicyImpl::GetInstance()->GrantReadFile( | 201 ChildProcessSecurityPolicyImpl::GetInstance()->GrantReadFile( |
| 202 process()->GetID(), file_path); | 202 process()->GetID(), file_path); |
| 203 test_rvh()->TestOnUpdateStateWithFile(-1, file_path); | 203 test_rvh()->TestOnUpdateStateWithFile(file_path); |
| 204 EXPECT_EQ(1, process()->bad_msg_count()); | 204 EXPECT_EQ(1, process()->bad_msg_count()); |
| 205 } | 205 } |
| 206 | 206 |
| 207 namespace { | 207 namespace { |
| 208 void SetBadFilePath(const GURL& url, | 208 void SetBadFilePath(const GURL& url, |
| 209 const base::FilePath& file_path, | 209 const base::FilePath& file_path, |
| 210 FrameHostMsg_DidCommitProvisionalLoad_Params* params) { | 210 FrameHostMsg_DidCommitProvisionalLoad_Params* params) { |
| 211 params->page_state = | 211 params->page_state = |
| 212 PageState::CreateForTesting(url, false, "data", &file_path); | 212 PageState::CreateForTesting(url, false, "data", &file_path); |
| 213 } | 213 } |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 303 const std::string data_url = "data:image/gif;base64," | 303 const std::string data_url = "data:image/gif;base64," |
| 304 "R0lGODlhAQABAIAAAAUEBAAAACwAAAAAAQABAAACAkQBADs="; | 304 "R0lGODlhAQABAIAAAAUEBAAAACwAAAAAAQABAAACAkQBADs="; |
| 305 | 305 |
| 306 tester->Reset(); | 306 tester->Reset(); |
| 307 tester->Test(data_url); | 307 tester->Test(data_url); |
| 308 EXPECT_EQ(tester->UrlString(), data_url); | 308 EXPECT_EQ(tester->UrlString(), data_url); |
| 309 EXPECT_TRUE(tester->IsDownloaded()); | 309 EXPECT_TRUE(tester->IsDownloaded()); |
| 310 } | 310 } |
| 311 | 311 |
| 312 } // namespace content | 312 } // namespace content |
| OLD | NEW |