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, |
| 3284 base::TimeTicks::Now()); |
3284 | 3285 |
3285 // Simulate what happens if a BrowserURLHandler rewrites the URL, causing | 3286 // Simulate what happens if a BrowserURLHandler rewrites the URL, causing |
3286 // the virtual URL to differ from the URL. | 3287 // the virtual URL to differ from the URL. |
3287 controller.GetPendingEntry()->SetURL(url1_fixed); | 3288 controller.GetPendingEntry()->SetURL(url1_fixed); |
3288 controller.GetPendingEntry()->SetVirtualURL(url1); | 3289 controller.GetPendingEntry()->SetVirtualURL(url1); |
3289 | 3290 |
3290 EXPECT_EQ(url1_fixed, controller.GetPendingEntry()->GetURL()); | 3291 EXPECT_EQ(url1_fixed, controller.GetPendingEntry()->GetURL()); |
3291 EXPECT_EQ(url1, controller.GetPendingEntry()->GetVirtualURL()); | 3292 EXPECT_EQ(url1, controller.GetPendingEntry()->GetVirtualURL()); |
3292 EXPECT_TRUE(controller.GetPendingEntry()->is_renderer_initiated()); | 3293 EXPECT_TRUE(controller.GetPendingEntry()->is_renderer_initiated()); |
3293 | 3294 |
3294 // If the user clicks another link, we should replace the pending entry. | 3295 // If the user clicks another link, we should replace the pending entry. |
3295 main_test_rfh()->SendRendererInitiatedNavigationRequest(url2, false); | 3296 main_test_rfh()->SendRendererInitiatedNavigationRequest(url2, false); |
3296 main_test_rfh()->PrepareForCommit(); | 3297 main_test_rfh()->PrepareForCommit(); |
3297 navigator->DidStartProvisionalLoad(main_test_rfh(), url2); | 3298 navigator->DidStartProvisionalLoad(main_test_rfh(), url2, |
| 3299 base::TimeTicks::Now()); |
3298 EXPECT_EQ(url2, controller.GetPendingEntry()->GetURL()); | 3300 EXPECT_EQ(url2, controller.GetPendingEntry()->GetURL()); |
3299 EXPECT_EQ(url2, controller.GetPendingEntry()->GetVirtualURL()); | 3301 EXPECT_EQ(url2, controller.GetPendingEntry()->GetVirtualURL()); |
3300 | 3302 |
3301 // Once it commits, the URL and virtual URL should reflect the actual page. | 3303 // Once it commits, the URL and virtual URL should reflect the actual page. |
3302 main_test_rfh()->SendNavigate(0, 0, true, url2); | 3304 main_test_rfh()->SendNavigate(0, 0, true, url2); |
3303 EXPECT_EQ(url2, controller.GetLastCommittedEntry()->GetURL()); | 3305 EXPECT_EQ(url2, controller.GetLastCommittedEntry()->GetURL()); |
3304 EXPECT_EQ(url2, controller.GetLastCommittedEntry()->GetVirtualURL()); | 3306 EXPECT_EQ(url2, controller.GetLastCommittedEntry()->GetVirtualURL()); |
3305 | 3307 |
3306 // We should not replace the pending entry for an error URL. | 3308 // We should not replace the pending entry for an error URL. |
3307 navigator->DidStartProvisionalLoad(main_test_rfh(), url1); | 3309 navigator->DidStartProvisionalLoad(main_test_rfh(), url1, |
| 3310 base::TimeTicks::Now()); |
3308 EXPECT_EQ(url1, controller.GetPendingEntry()->GetURL()); | 3311 EXPECT_EQ(url1, controller.GetPendingEntry()->GetURL()); |
3309 navigator->DidStartProvisionalLoad(main_test_rfh(), | 3312 navigator->DidStartProvisionalLoad( |
3310 GURL(kUnreachableWebDataURL)); | 3313 main_test_rfh(), GURL(kUnreachableWebDataURL), base::TimeTicks::Now()); |
3311 EXPECT_EQ(url1, controller.GetPendingEntry()->GetURL()); | 3314 EXPECT_EQ(url1, controller.GetPendingEntry()->GetURL()); |
3312 | 3315 |
3313 // We should remember if the pending entry will replace the current one. | 3316 // We should remember if the pending entry will replace the current one. |
3314 // http://crbug.com/308444. | 3317 // http://crbug.com/308444. |
3315 navigator->DidStartProvisionalLoad(main_test_rfh(), url1); | 3318 navigator->DidStartProvisionalLoad(main_test_rfh(), url1, |
| 3319 base::TimeTicks::Now()); |
3316 controller.GetPendingEntry()->set_should_replace_entry(true); | 3320 controller.GetPendingEntry()->set_should_replace_entry(true); |
3317 | 3321 |
3318 main_test_rfh()->SendRendererInitiatedNavigationRequest(url2, false); | 3322 main_test_rfh()->SendRendererInitiatedNavigationRequest(url2, false); |
3319 main_test_rfh()->PrepareForCommit(); | 3323 main_test_rfh()->PrepareForCommit(); |
3320 navigator->DidStartProvisionalLoad(main_test_rfh(), url2); | 3324 navigator->DidStartProvisionalLoad(main_test_rfh(), url2, |
| 3325 base::TimeTicks::Now()); |
3321 EXPECT_TRUE(controller.GetPendingEntry()->should_replace_entry()); | 3326 EXPECT_TRUE(controller.GetPendingEntry()->should_replace_entry()); |
3322 main_test_rfh()->SendNavigate(0, 0, false, url2); | 3327 main_test_rfh()->SendNavigate(0, 0, false, url2); |
3323 EXPECT_EQ(url2, controller.GetLastCommittedEntry()->GetURL()); | 3328 EXPECT_EQ(url2, controller.GetLastCommittedEntry()->GetURL()); |
3324 } | 3329 } |
3325 | 3330 |
3326 // Tests that the URLs for renderer-initiated navigations are not displayed to | 3331 // Tests that the URLs for renderer-initiated navigations are not displayed to |
3327 // the user until the navigation commits, to prevent URL spoof attacks. | 3332 // the user until the navigation commits, to prevent URL spoof attacks. |
3328 // See http://crbug.com/99016. | 3333 // See http://crbug.com/99016. |
3329 TEST_F(NavigationControllerTest, DontShowRendererURLUntilCommit) { | 3334 TEST_F(NavigationControllerTest, DontShowRendererURLUntilCommit) { |
3330 NavigationControllerImpl& controller = controller_impl(); | 3335 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, | 5054 EXPECT_EQ(default_ssl_status.connection_status, |
5050 details.ssl_status.connection_status); | 5055 details.ssl_status.connection_status); |
5051 EXPECT_EQ(default_ssl_status.content_status, | 5056 EXPECT_EQ(default_ssl_status.content_status, |
5052 details.ssl_status.content_status); | 5057 details.ssl_status.content_status); |
5053 EXPECT_EQ(0u, details.ssl_status.signed_certificate_timestamp_ids.size()); | 5058 EXPECT_EQ(0u, details.ssl_status.signed_certificate_timestamp_ids.size()); |
5054 | 5059 |
5055 EXPECT_EQ(1, main_test_rfh()->GetProcess()->bad_msg_count()); | 5060 EXPECT_EQ(1, main_test_rfh()->GetProcess()->bad_msg_count()); |
5056 } | 5061 } |
5057 | 5062 |
5058 } // namespace content | 5063 } // namespace content |
OLD | NEW |