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/common/view_messages.h" | 9 #include "content/common/view_messages.h" |
10 #include "content/port/browser/render_view_host_delegate_view.h" | 10 #include "content/port/browser/render_view_host_delegate_view.h" |
11 #include "content/public/browser/navigation_entry.h" | 11 #include "content/public/browser/navigation_entry.h" |
12 #include "content/public/common/bindings_policy.h" | 12 #include "content/public/common/bindings_policy.h" |
13 #include "content/public/common/page_transition_types.h" | 13 #include "content/public/common/page_transition_types.h" |
| 14 #include "content/public/common/url_constants.h" |
14 #include "content/public/test/mock_render_process_host.h" | 15 #include "content/public/test/mock_render_process_host.h" |
| 16 #include "content/test/test_content_browser_client.h" |
15 #include "content/test/test_web_contents.h" | 17 #include "content/test/test_web_contents.h" |
16 #include "net/base/net_util.h" | 18 #include "net/base/net_util.h" |
17 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDragOperation.h" | 19 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDragOperation.h" |
18 #include "webkit/glue/webdropdata.h" | 20 #include "webkit/glue/webdropdata.h" |
19 | 21 |
20 namespace content { | 22 namespace content { |
21 | 23 |
| 24 class RenderViewHostTestBrowserClient : public TestContentBrowserClient { |
| 25 public: |
| 26 RenderViewHostTestBrowserClient() {} |
| 27 virtual ~RenderViewHostTestBrowserClient() {} |
| 28 |
| 29 virtual bool IsHandledURL(const GURL& url) OVERRIDE { |
| 30 return url.scheme() == chrome::kFileScheme; |
| 31 } |
| 32 |
| 33 private: |
| 34 DISALLOW_COPY_AND_ASSIGN(RenderViewHostTestBrowserClient); |
| 35 }; |
| 36 |
22 class RenderViewHostTest : public RenderViewHostImplTestHarness { | 37 class RenderViewHostTest : public RenderViewHostImplTestHarness { |
| 38 public: |
| 39 RenderViewHostTest() : old_browser_client_(NULL) {} |
| 40 virtual ~RenderViewHostTest() {} |
| 41 |
| 42 virtual void SetUp() OVERRIDE { |
| 43 RenderViewHostImplTestHarness::SetUp(); |
| 44 old_browser_client_ = SetBrowserClientForTesting(&test_browser_client_); |
| 45 } |
| 46 |
| 47 virtual void TearDown() OVERRIDE { |
| 48 SetBrowserClientForTesting(old_browser_client_); |
| 49 RenderViewHostImplTestHarness::TearDown(); |
| 50 } |
| 51 |
| 52 private: |
| 53 RenderViewHostTestBrowserClient test_browser_client_; |
| 54 ContentBrowserClient* old_browser_client_; |
| 55 |
| 56 DISALLOW_COPY_AND_ASSIGN(RenderViewHostTest); |
23 }; | 57 }; |
24 | 58 |
25 // All about URLs reported by the renderer should get rewritten to about:blank. | 59 // All about URLs reported by the renderer should get rewritten to about:blank. |
26 // See RenderViewHost::OnNavigate for a discussion. | 60 // See RenderViewHost::OnNavigate for a discussion. |
27 TEST_F(RenderViewHostTest, FilterAbout) { | 61 TEST_F(RenderViewHostTest, FilterAbout) { |
28 test_rvh()->SendNavigate(1, GURL("about:cache")); | 62 test_rvh()->SendNavigate(1, GURL("about:cache")); |
29 ASSERT_TRUE(controller().GetActiveEntry()); | 63 ASSERT_TRUE(controller().GetActiveEntry()); |
30 EXPECT_EQ(GURL("about:blank"), controller().GetActiveEntry()->GetURL()); | 64 EXPECT_EQ(GURL("about:blank"), controller().GetActiveEntry()->GetURL()); |
31 } | 65 } |
32 | 66 |
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
220 // OnInputEventAck() processing. | 254 // OnInputEventAck() processing. |
221 IPC::Message message(0, ViewHostMsg_HandleInputEvent_ACK::ID, | 255 IPC::Message message(0, ViewHostMsg_HandleInputEvent_ACK::ID, |
222 IPC::Message::PRIORITY_NORMAL); | 256 IPC::Message::PRIORITY_NORMAL); |
223 test_rvh()->OnMessageReceived(message); | 257 test_rvh()->OnMessageReceived(message); |
224 EXPECT_EQ(1, process()->bad_msg_count()); | 258 EXPECT_EQ(1, process()->bad_msg_count()); |
225 } | 259 } |
226 | 260 |
227 #endif | 261 #endif |
228 | 262 |
229 } // namespace content | 263 } // namespace content |
OLD | NEW |