Chromium Code Reviews| 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 "content/browser/frame_host/navigation_controller_impl.h" | 5 #include "content/browser/frame_host/navigation_controller_impl.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 #include <utility> | 9 #include <utility> |
| 10 | 10 |
| (...skipping 366 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 377 navigation_entry_committed_counter_ = 0; | 377 navigation_entry_committed_counter_ = 0; |
| 378 // Check that we can go to any valid offset into the history. | 378 // Check that we can go to any valid offset into the history. |
| 379 for (size_t j = 0; j < urls.size(); ++j) | 379 for (size_t j = 0; j < urls.size(); ++j) |
| 380 EXPECT_TRUE(controller.CanGoToOffset(j - url_index)); | 380 EXPECT_TRUE(controller.CanGoToOffset(j - url_index)); |
| 381 // Check that we can't go beyond the beginning or end of the history. | 381 // Check that we can't go beyond the beginning or end of the history. |
| 382 EXPECT_FALSE(controller.CanGoToOffset(-(url_index + 1))); | 382 EXPECT_FALSE(controller.CanGoToOffset(-(url_index + 1))); |
| 383 EXPECT_FALSE(controller.CanGoToOffset(urls.size() - url_index)); | 383 EXPECT_FALSE(controller.CanGoToOffset(urls.size() - url_index)); |
| 384 } | 384 } |
| 385 } | 385 } |
| 386 | 386 |
| 387 TEST_F(NavigationControllerTest, DontDiscardWrongPendingEntry) { | |
|
Charlie Reis
2016/02/05 19:36:11
nit: Let's add a comment with the bug number and a
Charlie Harrison
2016/02/05 23:10:23
Done.
| |
| 388 NavigationControllerImpl& controller = controller_impl(); | |
| 389 GURL initial_url("http://www.google.com"); | |
| 390 GURL url_1("http://foo.com"); | |
| 391 GURL url_2("http://foo2.com"); | |
| 392 | |
| 393 // Navigate inititally. This is the url that could erroneously be the visible | |
| 394 // entry when url_1 fails. | |
| 395 NavigateAndCommit(initial_url); | |
| 396 | |
| 397 // Set the pending entry as url_1 and receive the DidStartProvisionalLoad | |
| 398 // message, creating the NavigationHandle. | |
| 399 controller.LoadURL( | |
| 400 url_1, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); | |
| 401 main_test_rfh()->SimulateNavigationStart(url_1); | |
| 402 | |
| 403 // Navigate to url_2, aborting url_1 before the DidStartProvisionalLoad | |
| 404 // message is received for url_2. Do not discard the pending entry for url_2 | |
| 405 // here. | |
| 406 controller.LoadURL(url_2, Referrer(), ui::PAGE_TRANSITION_TYPED, | |
| 407 std::string()); | |
| 408 main_test_rfh()->SimulateNavigationError(url_1, net::ERR_ABORTED); | |
| 409 | |
| 410 // Get the DidStartProvisionalLoad message for url_2. | |
| 411 main_test_rfh()->SimulateNavigationStart(url_2); | |
| 412 | |
| 413 EXPECT_EQ(controller.GetVisibleEntry()->GetURL(), url_2); | |
|
Charlie Reis
2016/02/05 19:36:11
nit: Copy this EXPECT_EQ after the LoadURL(url_2)
Charlie Harrison
2016/02/05 23:10:23
Done.
| |
| 414 } | |
| 415 | |
| 387 TEST_F(NavigationControllerTest, LoadURL) { | 416 TEST_F(NavigationControllerTest, LoadURL) { |
| 388 NavigationControllerImpl& controller = controller_impl(); | 417 NavigationControllerImpl& controller = controller_impl(); |
| 389 TestNotificationTracker notifications; | 418 TestNotificationTracker notifications; |
| 390 RegisterForAllNavNotifications(¬ifications, &controller); | 419 RegisterForAllNavNotifications(¬ifications, &controller); |
| 391 | 420 |
| 392 const GURL url1("http://foo1"); | 421 const GURL url1("http://foo1"); |
| 393 const GURL url2("http://foo2"); | 422 const GURL url2("http://foo2"); |
| 394 | 423 |
| 395 controller.LoadURL( | 424 controller.LoadURL( |
| 396 url1, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); | 425 url1, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); |
| (...skipping 4721 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 5118 EXPECT_EQ(default_ssl_status.connection_status, | 5147 EXPECT_EQ(default_ssl_status.connection_status, |
| 5119 details.ssl_status.connection_status); | 5148 details.ssl_status.connection_status); |
| 5120 EXPECT_EQ(default_ssl_status.content_status, | 5149 EXPECT_EQ(default_ssl_status.content_status, |
| 5121 details.ssl_status.content_status); | 5150 details.ssl_status.content_status); |
| 5122 EXPECT_EQ(0u, details.ssl_status.signed_certificate_timestamp_ids.size()); | 5151 EXPECT_EQ(0u, details.ssl_status.signed_certificate_timestamp_ids.size()); |
| 5123 | 5152 |
| 5124 EXPECT_EQ(1, main_test_rfh()->GetProcess()->bad_msg_count()); | 5153 EXPECT_EQ(1, main_test_rfh()->GetProcess()->bad_msg_count()); |
| 5125 } | 5154 } |
| 5126 | 5155 |
| 5127 } // namespace content | 5156 } // namespace content |
| OLD | NEW |