OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/basictypes.h" | 5 #include "base/basictypes.h" |
6 #include "base/bind.h" | 6 #include "base/bind.h" |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/files/file_util.h" | 8 #include "base/files/file_util.h" |
9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
10 #include "base/stl_util.h" | 10 #include "base/stl_util.h" |
(...skipping 3262 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3273 contents()->GetFrameTree()->root()->navigator(); | 3273 contents()->GetFrameTree()->root()->navigator(); |
3274 | 3274 |
3275 const GURL url1("nonexistent:12121"); | 3275 const GURL url1("nonexistent:12121"); |
3276 const GURL url1_fixed("http://nonexistent:12121/"); | 3276 const GURL url1_fixed("http://nonexistent:12121/"); |
3277 const GURL url2("http://foo"); | 3277 const GURL url2("http://foo"); |
3278 | 3278 |
3279 // We create pending entries for renderer-initiated navigations so that we | 3279 // We create pending entries for renderer-initiated navigations so that we |
3280 // can show them in new tabs when it is safe. | 3280 // can show them in new tabs when it is safe. |
3281 main_test_rfh()->SendRendererInitiatedNavigationRequest(url1, false); | 3281 main_test_rfh()->SendRendererInitiatedNavigationRequest(url1, false); |
3282 main_test_rfh()->PrepareForCommit(); | 3282 main_test_rfh()->PrepareForCommit(); |
3283 navigator->DidStartProvisionalLoad(main_test_rfh(), url1); | 3283 navigator->DidStartProvisionalLoad(main_test_rfh(), url1, 0); |
3284 | 3284 |
3285 // Simulate what happens if a BrowserURLHandler rewrites the URL, causing | 3285 // Simulate what happens if a BrowserURLHandler rewrites the URL, causing |
3286 // the virtual URL to differ from the URL. | 3286 // the virtual URL to differ from the URL. |
3287 controller.GetPendingEntry()->SetURL(url1_fixed); | 3287 controller.GetPendingEntry()->SetURL(url1_fixed); |
3288 controller.GetPendingEntry()->SetVirtualURL(url1); | 3288 controller.GetPendingEntry()->SetVirtualURL(url1); |
3289 | 3289 |
3290 EXPECT_EQ(url1_fixed, controller.GetPendingEntry()->GetURL()); | 3290 EXPECT_EQ(url1_fixed, controller.GetPendingEntry()->GetURL()); |
3291 EXPECT_EQ(url1, controller.GetPendingEntry()->GetVirtualURL()); | 3291 EXPECT_EQ(url1, controller.GetPendingEntry()->GetVirtualURL()); |
3292 EXPECT_TRUE(controller.GetPendingEntry()->is_renderer_initiated()); | 3292 EXPECT_TRUE(controller.GetPendingEntry()->is_renderer_initiated()); |
3293 | 3293 |
3294 // If the user clicks another link, we should replace the pending entry. | 3294 // If the user clicks another link, we should replace the pending entry. |
3295 main_test_rfh()->SendRendererInitiatedNavigationRequest(url2, false); | 3295 main_test_rfh()->SendRendererInitiatedNavigationRequest(url2, false); |
3296 main_test_rfh()->PrepareForCommit(); | 3296 main_test_rfh()->PrepareForCommit(); |
3297 navigator->DidStartProvisionalLoad(main_test_rfh(), url2); | 3297 navigator->DidStartProvisionalLoad(main_test_rfh(), url2, 0); |
3298 EXPECT_EQ(url2, controller.GetPendingEntry()->GetURL()); | 3298 EXPECT_EQ(url2, controller.GetPendingEntry()->GetURL()); |
3299 EXPECT_EQ(url2, controller.GetPendingEntry()->GetVirtualURL()); | 3299 EXPECT_EQ(url2, controller.GetPendingEntry()->GetVirtualURL()); |
3300 | 3300 |
3301 // Once it commits, the URL and virtual URL should reflect the actual page. | 3301 // Once it commits, the URL and virtual URL should reflect the actual page. |
3302 main_test_rfh()->SendNavigate(0, 0, true, url2); | 3302 main_test_rfh()->SendNavigate(0, 0, true, url2); |
3303 EXPECT_EQ(url2, controller.GetLastCommittedEntry()->GetURL()); | 3303 EXPECT_EQ(url2, controller.GetLastCommittedEntry()->GetURL()); |
3304 EXPECT_EQ(url2, controller.GetLastCommittedEntry()->GetVirtualURL()); | 3304 EXPECT_EQ(url2, controller.GetLastCommittedEntry()->GetVirtualURL()); |
3305 | 3305 |
3306 // We should not replace the pending entry for an error URL. | 3306 // We should not replace the pending entry for an error URL. |
3307 navigator->DidStartProvisionalLoad(main_test_rfh(), url1); | 3307 navigator->DidStartProvisionalLoad(main_test_rfh(), url1, 0); |
3308 EXPECT_EQ(url1, controller.GetPendingEntry()->GetURL()); | 3308 EXPECT_EQ(url1, controller.GetPendingEntry()->GetURL()); |
3309 navigator->DidStartProvisionalLoad(main_test_rfh(), | 3309 navigator->DidStartProvisionalLoad(main_test_rfh(), |
3310 GURL(kUnreachableWebDataURL)); | 3310 GURL(kUnreachableWebDataURL), 0); |
3311 EXPECT_EQ(url1, controller.GetPendingEntry()->GetURL()); | 3311 EXPECT_EQ(url1, controller.GetPendingEntry()->GetURL()); |
3312 | 3312 |
3313 // We should remember if the pending entry will replace the current one. | 3313 // We should remember if the pending entry will replace the current one. |
3314 // http://crbug.com/308444. | 3314 // http://crbug.com/308444. |
3315 navigator->DidStartProvisionalLoad(main_test_rfh(), url1); | 3315 navigator->DidStartProvisionalLoad(main_test_rfh(), url1, 0); |
3316 controller.GetPendingEntry()->set_should_replace_entry(true); | 3316 controller.GetPendingEntry()->set_should_replace_entry(true); |
3317 | 3317 |
3318 main_test_rfh()->SendRendererInitiatedNavigationRequest(url2, false); | 3318 main_test_rfh()->SendRendererInitiatedNavigationRequest(url2, false); |
3319 main_test_rfh()->PrepareForCommit(); | 3319 main_test_rfh()->PrepareForCommit(); |
3320 navigator->DidStartProvisionalLoad(main_test_rfh(), url2); | 3320 navigator->DidStartProvisionalLoad(main_test_rfh(), url2, 0); |
3321 EXPECT_TRUE(controller.GetPendingEntry()->should_replace_entry()); | 3321 EXPECT_TRUE(controller.GetPendingEntry()->should_replace_entry()); |
3322 main_test_rfh()->SendNavigate(0, 0, false, url2); | 3322 main_test_rfh()->SendNavigate(0, 0, false, url2); |
3323 EXPECT_EQ(url2, controller.GetLastCommittedEntry()->GetURL()); | 3323 EXPECT_EQ(url2, controller.GetLastCommittedEntry()->GetURL()); |
3324 } | 3324 } |
3325 | 3325 |
3326 // Tests that the URLs for renderer-initiated navigations are not displayed to | 3326 // Tests that the URLs for renderer-initiated navigations are not displayed to |
3327 // the user until the navigation commits, to prevent URL spoof attacks. | 3327 // the user until the navigation commits, to prevent URL spoof attacks. |
3328 // See http://crbug.com/99016. | 3328 // See http://crbug.com/99016. |
3329 TEST_F(NavigationControllerTest, DontShowRendererURLUntilCommit) { | 3329 TEST_F(NavigationControllerTest, DontShowRendererURLUntilCommit) { |
3330 NavigationControllerImpl& controller = controller_impl(); | 3330 NavigationControllerImpl& controller = controller_impl(); |
(...skipping 1718 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5049 EXPECT_EQ(default_ssl_status.connection_status, | 5049 EXPECT_EQ(default_ssl_status.connection_status, |
5050 details.ssl_status.connection_status); | 5050 details.ssl_status.connection_status); |
5051 EXPECT_EQ(default_ssl_status.content_status, | 5051 EXPECT_EQ(default_ssl_status.content_status, |
5052 details.ssl_status.content_status); | 5052 details.ssl_status.content_status); |
5053 EXPECT_EQ(0u, details.ssl_status.signed_certificate_timestamp_ids.size()); | 5053 EXPECT_EQ(0u, details.ssl_status.signed_certificate_timestamp_ids.size()); |
5054 | 5054 |
5055 EXPECT_EQ(1, main_test_rfh()->GetProcess()->bad_msg_count()); | 5055 EXPECT_EQ(1, main_test_rfh()->GetProcess()->bad_msg_count()); |
5056 } | 5056 } |
5057 | 5057 |
5058 } // namespace content | 5058 } // namespace content |
OLD | NEW |