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/utf_string_conversions.h" | 5 #include "base/utf_string_conversions.h" |
6 #include "content/browser/child_process_security_policy_impl.h" | 6 #include "content/browser/child_process_security_policy_impl.h" |
7 #include "content/browser/renderer_host/test_render_view_host.h" | 7 #include "content/browser/renderer_host/test_render_view_host.h" |
8 #include "content/browser/web_contents/navigation_controller_impl.h" | 8 #include "content/browser/web_contents/navigation_controller_impl.h" |
9 #include "content/browser/web_contents/test_web_contents.h" | 9 #include "content/browser/web_contents/test_web_contents.h" |
10 #include "content/common/view_messages.h" | 10 #include "content/common/view_messages.h" |
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
169 dropped_data.filenames.push_back(WebDropData::FileInfo( | 169 dropped_data.filenames.push_back(WebDropData::FileInfo( |
170 UTF8ToUTF16(dragged_file_path.AsUTF8Unsafe()), string16())); | 170 UTF8ToUTF16(dragged_file_path.AsUTF8Unsafe()), string16())); |
171 | 171 |
172 rvh()->DragTargetDragEnter(dropped_data, client_point, screen_point, | 172 rvh()->DragTargetDragEnter(dropped_data, client_point, screen_point, |
173 WebKit::WebDragOperationNone, 0); | 173 WebKit::WebDragOperationNone, 0); |
174 | 174 |
175 int id = process()->GetID(); | 175 int id = process()->GetID(); |
176 ChildProcessSecurityPolicyImpl* policy = | 176 ChildProcessSecurityPolicyImpl* policy = |
177 ChildProcessSecurityPolicyImpl::GetInstance(); | 177 ChildProcessSecurityPolicyImpl::GetInstance(); |
178 | 178 |
179 EXPECT_FALSE(policy->CanRequestURL(id, highlighted_file_url)); | 179 EXPECT_FALSE(policy->CanRequestURL(id, highlighted_file_url, |
| 180 ResourceType::MAIN_FRAME)); |
180 EXPECT_FALSE(policy->CanReadFile(id, highlighted_file_path)); | 181 EXPECT_FALSE(policy->CanReadFile(id, highlighted_file_path)); |
181 EXPECT_TRUE(policy->CanRequestURL(id, dragged_file_url)); | 182 EXPECT_TRUE(policy->CanRequestURL(id, dragged_file_url, |
| 183 ResourceType::MAIN_FRAME)); |
182 EXPECT_TRUE(policy->CanReadFile(id, dragged_file_path)); | 184 EXPECT_TRUE(policy->CanReadFile(id, dragged_file_path)); |
183 EXPECT_FALSE(policy->CanRequestURL(id, sensitive_file_url)); | 185 EXPECT_FALSE(policy->CanRequestURL(id, sensitive_file_url, |
| 186 ResourceType::MAIN_FRAME)); |
184 EXPECT_FALSE(policy->CanReadFile(id, sensitive_file_path)); | 187 EXPECT_FALSE(policy->CanReadFile(id, sensitive_file_path)); |
185 } | 188 } |
186 | 189 |
187 // The test that follow trigger DCHECKS in debug build. | 190 // The test that follow trigger DCHECKS in debug build. |
188 #if defined(NDEBUG) && !defined(DCHECK_ALWAYS_ON) | 191 #if defined(NDEBUG) && !defined(DCHECK_ALWAYS_ON) |
189 | 192 |
190 // Test that when we fail to de-serialize a message, RenderViewHost calls the | 193 // Test that when we fail to de-serialize a message, RenderViewHost calls the |
191 // ReceivedBadMessage() handler. | 194 // ReceivedBadMessage() handler. |
192 TEST_F(RenderViewHostTest, BadMessageHandlerRenderViewHost) { | 195 TEST_F(RenderViewHostTest, BadMessageHandlerRenderViewHost) { |
193 EXPECT_EQ(0, process()->bad_msg_count()); | 196 EXPECT_EQ(0, process()->bad_msg_count()); |
(...skipping 26 matching lines...) Expand all Loading... |
220 // OnMsgInputEventAck() processing. | 223 // OnMsgInputEventAck() processing. |
221 IPC::Message message(0, ViewHostMsg_HandleInputEvent_ACK::ID, | 224 IPC::Message message(0, ViewHostMsg_HandleInputEvent_ACK::ID, |
222 IPC::Message::PRIORITY_NORMAL); | 225 IPC::Message::PRIORITY_NORMAL); |
223 test_rvh()->OnMessageReceived(message); | 226 test_rvh()->OnMessageReceived(message); |
224 EXPECT_EQ(1, process()->bad_msg_count()); | 227 EXPECT_EQ(1, process()->bad_msg_count()); |
225 } | 228 } |
226 | 229 |
227 #endif | 230 #endif |
228 | 231 |
229 } // namespace content | 232 } // namespace content |
OLD | NEW |