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_message_filter.h" | 9 #include "content/browser/renderer_host/render_message_filter.h" |
10 #include "content/browser/renderer_host/render_view_host_delegate_view.h" | 10 #include "content/browser/renderer_host/render_view_host_delegate_view.h" |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
57 private: | 57 private: |
58 RenderViewHostTestBrowserClient test_browser_client_; | 58 RenderViewHostTestBrowserClient test_browser_client_; |
59 ContentBrowserClient* old_browser_client_; | 59 ContentBrowserClient* old_browser_client_; |
60 | 60 |
61 DISALLOW_COPY_AND_ASSIGN(RenderViewHostTest); | 61 DISALLOW_COPY_AND_ASSIGN(RenderViewHostTest); |
62 }; | 62 }; |
63 | 63 |
64 // All about URLs reported by the renderer should get rewritten to about:blank. | 64 // All about URLs reported by the renderer should get rewritten to about:blank. |
65 // See RenderViewHost::OnNavigate for a discussion. | 65 // See RenderViewHost::OnNavigate for a discussion. |
66 TEST_F(RenderViewHostTest, FilterAbout) { | 66 TEST_F(RenderViewHostTest, FilterAbout) { |
67 main_test_rfh()->NavigateAndCommitRendererInitiated( | 67 main_test_rfh()->NavigateAndCommitRendererInitiated(1, GURL("about:cache")); |
68 1, true, GURL("about:cache")); | |
69 ASSERT_TRUE(controller().GetVisibleEntry()); | 68 ASSERT_TRUE(controller().GetVisibleEntry()); |
70 EXPECT_EQ(GURL(url::kAboutBlankURL), | 69 EXPECT_EQ(GURL(url::kAboutBlankURL), |
71 controller().GetVisibleEntry()->GetURL()); | 70 controller().GetVisibleEntry()->GetURL()); |
72 } | 71 } |
73 | 72 |
74 // Create a full screen popup RenderWidgetHost and View. | 73 // Create a full screen popup RenderWidgetHost and View. |
75 TEST_F(RenderViewHostTest, CreateFullscreenWidget) { | 74 TEST_F(RenderViewHostTest, CreateFullscreenWidget) { |
76 int routing_id = process()->GetNextRoutingID(); | 75 int routing_id = process()->GetNextRoutingID(); |
77 test_rvh()->CreateNewFullscreenWidget(routing_id); | 76 test_rvh()->CreateNewFullscreenWidget(routing_id); |
78 } | 77 } |
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
228 } | 227 } |
229 | 228 |
230 TEST_F(RenderViewHostTest, NavigationWithBadHistoryItemFiles) { | 229 TEST_F(RenderViewHostTest, NavigationWithBadHistoryItemFiles) { |
231 GURL url("http://www.google.com"); | 230 GURL url("http://www.google.com"); |
232 base::FilePath file_path; | 231 base::FilePath file_path; |
233 EXPECT_TRUE(PathService::Get(base::DIR_TEMP, &file_path)); | 232 EXPECT_TRUE(PathService::Get(base::DIR_TEMP, &file_path)); |
234 file_path = file_path.AppendASCII("bar"); | 233 file_path = file_path.AppendASCII("bar"); |
235 EXPECT_EQ(0, process()->bad_msg_count()); | 234 EXPECT_EQ(0, process()->bad_msg_count()); |
236 main_test_rfh()->SendRendererInitiatedNavigationRequest(url, false); | 235 main_test_rfh()->SendRendererInitiatedNavigationRequest(url, false); |
237 main_test_rfh()->PrepareForCommit(); | 236 main_test_rfh()->PrepareForCommit(); |
238 contents()->GetMainFrame()->SendNavigateWithFile(1, 1, true, url, file_path); | 237 contents()->GetMainFrame()->SendNavigateWithFile(1, url, file_path); |
239 EXPECT_EQ(1, process()->bad_msg_count()); | 238 EXPECT_EQ(1, process()->bad_msg_count()); |
240 | 239 |
241 ChildProcessSecurityPolicyImpl::GetInstance()->GrantReadFile( | 240 ChildProcessSecurityPolicyImpl::GetInstance()->GrantReadFile( |
242 process()->GetID(), file_path); | 241 process()->GetID(), file_path); |
243 main_test_rfh()->SendRendererInitiatedNavigationRequest(url, false); | 242 main_test_rfh()->SendRendererInitiatedNavigationRequest(url, false); |
244 main_test_rfh()->PrepareForCommit(); | 243 main_test_rfh()->PrepareForCommit(); |
245 contents()->GetMainFrame()->SendNavigateWithFile(2, 2, true, url, file_path); | 244 contents()->GetMainFrame()->SendNavigateWithFile(process()->GetID(), url, |
| 245 file_path); |
246 EXPECT_EQ(1, process()->bad_msg_count()); | 246 EXPECT_EQ(1, process()->bad_msg_count()); |
247 } | 247 } |
248 | 248 |
249 TEST_F(RenderViewHostTest, RoutingIdSane) { | 249 TEST_F(RenderViewHostTest, RoutingIdSane) { |
250 RenderFrameHostImpl* root_rfh = | 250 RenderFrameHostImpl* root_rfh = |
251 contents()->GetFrameTree()->root()->current_frame_host(); | 251 contents()->GetFrameTree()->root()->current_frame_host(); |
252 EXPECT_EQ(contents()->GetMainFrame(), root_rfh); | 252 EXPECT_EQ(contents()->GetMainFrame(), root_rfh); |
253 EXPECT_EQ(test_rvh()->GetProcess(), root_rfh->GetProcess()); | 253 EXPECT_EQ(test_rvh()->GetProcess(), root_rfh->GetProcess()); |
254 EXPECT_NE(test_rvh()->GetRoutingID(), root_rfh->routing_id()); | 254 EXPECT_NE(test_rvh()->GetRoutingID(), root_rfh->routing_id()); |
255 } | 255 } |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
315 const std::string data_url = "data:image/gif;base64," | 315 const std::string data_url = "data:image/gif;base64," |
316 "R0lGODlhAQABAIAAAAUEBAAAACwAAAAAAQABAAACAkQBADs="; | 316 "R0lGODlhAQABAIAAAAUEBAAAACwAAAAAAQABAAACAkQBADs="; |
317 | 317 |
318 tester->Reset(); | 318 tester->Reset(); |
319 tester->Test(data_url); | 319 tester->Test(data_url); |
320 EXPECT_EQ(tester->UrlString(), data_url); | 320 EXPECT_EQ(tester->UrlString(), data_url); |
321 EXPECT_TRUE(tester->IsDownloaded()); | 321 EXPECT_TRUE(tester->IsDownloaded()); |
322 } | 322 } |
323 | 323 |
324 } // namespace content | 324 } // namespace content |
OLD | NEW |