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 // This test case was added to reproduce crbug.com/513742. The repro steps are | |
388 // as follows: | |
389 // 1. Pending entry for A is created. | |
390 // 2. DidStartProvisionalLoad message for A arrives. | |
391 // 3. Pending entry for B is created. | |
392 // 4. DidFailProvisionalLoad message for A arrives. The logic here discards. | |
393 // 5. DidStartProvisionalLoad message for B arrives. | |
394 // | |
395 // At step (4), the pending entry for B is discarded, when A is the one that | |
Charlie Reis
2016/02/16 21:55:07
s/is/used to be/
Charlie Harrison
2016/02/16 22:55:22
Done.
| |
396 // is being aborted. This caused the last committed entry to be displayed in | |
397 // the omnibox, which is the entry before A was created. | |
398 TEST_F(NavigationControllerTest, DontDiscardWrongPendingEntry) { | |
399 NavigationControllerImpl& controller = controller_impl(); | |
400 GURL initial_url("http://www.google.com"); | |
401 GURL url_1("http://foo.com"); | |
402 GURL url_2("http://foo2.com"); | |
403 | |
404 // Navigate inititally. This is the url that could erroneously be the visible | |
405 // entry when url_1 fails. | |
406 NavigateAndCommit(initial_url); | |
407 | |
408 // Set the pending entry as url_1 and receive the DidStartProvisionalLoad | |
409 // message, creating the NavigationHandle. | |
410 controller.LoadURL(url_1, Referrer(), ui::PAGE_TRANSITION_TYPED, | |
411 std::string()); | |
412 EXPECT_EQ(controller.GetVisibleEntry()->GetURL(), url_1); | |
413 main_test_rfh()->SimulateNavigationStart(url_1); | |
414 EXPECT_EQ(controller.GetVisibleEntry()->GetURL(), url_1); | |
415 | |
416 // Navigate to url_2, aborting url_1 before the DidStartProvisionalLoad | |
417 // message is received for url_2. Do not discard the pending entry for url_2 | |
418 // here. | |
419 controller.LoadURL(url_2, Referrer(), ui::PAGE_TRANSITION_TYPED, | |
420 std::string()); | |
421 EXPECT_EQ(controller.GetVisibleEntry()->GetURL(), url_2); | |
422 main_test_rfh()->SimulateNavigationError(url_1, net::ERR_ABORTED); | |
423 EXPECT_EQ(controller.GetVisibleEntry()->GetURL(), url_2); | |
424 | |
425 // Get the DidStartProvisionalLoad message for url_2. | |
426 main_test_rfh()->SimulateNavigationStart(url_2); | |
427 | |
428 EXPECT_EQ(controller.GetVisibleEntry()->GetURL(), url_2); | |
429 } | |
430 | |
387 TEST_F(NavigationControllerTest, LoadURL) { | 431 TEST_F(NavigationControllerTest, LoadURL) { |
388 NavigationControllerImpl& controller = controller_impl(); | 432 NavigationControllerImpl& controller = controller_impl(); |
389 TestNotificationTracker notifications; | 433 TestNotificationTracker notifications; |
390 RegisterForAllNavNotifications(¬ifications, &controller); | 434 RegisterForAllNavNotifications(¬ifications, &controller); |
391 | 435 |
392 const GURL url1("http://foo1"); | 436 const GURL url1("http://foo1"); |
393 const GURL url2("http://foo2"); | 437 const GURL url2("http://foo2"); |
394 | 438 |
395 controller.LoadURL( | 439 controller.LoadURL( |
396 url1, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); | 440 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, | 5162 EXPECT_EQ(default_ssl_status.connection_status, |
5119 details.ssl_status.connection_status); | 5163 details.ssl_status.connection_status); |
5120 EXPECT_EQ(default_ssl_status.content_status, | 5164 EXPECT_EQ(default_ssl_status.content_status, |
5121 details.ssl_status.content_status); | 5165 details.ssl_status.content_status); |
5122 EXPECT_EQ(0u, details.ssl_status.signed_certificate_timestamp_ids.size()); | 5166 EXPECT_EQ(0u, details.ssl_status.signed_certificate_timestamp_ids.size()); |
5123 | 5167 |
5124 EXPECT_EQ(1, main_test_rfh()->GetProcess()->bad_msg_count()); | 5168 EXPECT_EQ(1, main_test_rfh()->GetProcess()->bad_msg_count()); |
5125 } | 5169 } |
5126 | 5170 |
5127 } // namespace content | 5171 } // namespace content |
OLD | NEW |