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 365 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
376 navigation_entry_committed_counter_ = 0; | 376 navigation_entry_committed_counter_ = 0; |
377 // Check that we can go to any valid offset into the history. | 377 // Check that we can go to any valid offset into the history. |
378 for (size_t j = 0; j < urls.size(); ++j) | 378 for (size_t j = 0; j < urls.size(); ++j) |
379 EXPECT_TRUE(controller.CanGoToOffset(j - url_index)); | 379 EXPECT_TRUE(controller.CanGoToOffset(j - url_index)); |
380 // Check that we can't go beyond the beginning or end of the history. | 380 // Check that we can't go beyond the beginning or end of the history. |
381 EXPECT_FALSE(controller.CanGoToOffset(-(url_index + 1))); | 381 EXPECT_FALSE(controller.CanGoToOffset(-(url_index + 1))); |
382 EXPECT_FALSE(controller.CanGoToOffset(urls.size() - url_index)); | 382 EXPECT_FALSE(controller.CanGoToOffset(urls.size() - url_index)); |
383 } | 383 } |
384 } | 384 } |
385 | 385 |
386 // This test case was added to reproduce crbug.com/513742. The repro steps are | |
387 // as follows: | |
388 // 1. Pending entry for A is created. | |
389 // 2. DidStartProvisionalLoad message for A arrives. | |
390 // 3. Pending entry for B is created. | |
391 // 4. DidFailProvisionalLoad message for A arrives. The logic here discards. | |
392 // 5. DidStartProvisionalLoad message for B arrives. | |
393 // | |
394 // At step (4), the pending entry for B is discarded, when A is the one that | |
395 // is being aborted. This caused the last committed entry to be displayed in | |
396 // the omnibox, which is the entry before A was created. | |
397 TEST_F(NavigationControllerTest, DontDiscardWrongPendingEntry) { | |
398 NavigationControllerImpl& controller = controller_impl(); | |
399 GURL initial_url("http://www.google.com"); | |
400 GURL url_1("http://foo.com"); | |
401 GURL url_2("http://foo2.com"); | |
402 | |
403 // Navigate inititally. This is the url that could erroneously be the visible | |
404 // entry when url_1 fails. | |
405 NavigateAndCommit(initial_url); | |
406 | |
407 // Set the pending entry as url_1 and receive the DidStartProvisionalLoad | |
408 // message, creating the NavigationHandle. | |
409 controller.LoadURL(url_1, Referrer(), ui::PAGE_TRANSITION_TYPED, | |
410 std::string()); | |
411 EXPECT_EQ(controller.GetVisibleEntry()->GetURL(), url_1); | |
412 main_test_rfh()->SimulateNavigationStart(url_1); | |
413 EXPECT_EQ(controller.GetVisibleEntry()->GetURL(), url_1); | |
414 | |
415 // Navigate to url_2, aborting url_1 before the DidStartProvisionalLoad | |
416 // message is received for url_2. Do not discard the pending entry for url_2 | |
417 // here. | |
418 controller.LoadURL(url_2, Referrer(), ui::PAGE_TRANSITION_TYPED, | |
419 std::string()); | |
420 EXPECT_EQ(controller.GetVisibleEntry()->GetURL(), url_2); | |
421 main_test_rfh()->SimulateNavigationError(url_1, net::ERR_ABORTED); | |
422 EXPECT_EQ(controller.GetVisibleEntry()->GetURL(), url_2); | |
423 | |
424 // Get the DidStartProvisionalLoad message for url_2. | |
425 main_test_rfh()->SimulateNavigationStart(url_2); | |
426 | |
427 EXPECT_EQ(controller.GetVisibleEntry()->GetURL(), url_2); | |
428 } | |
429 | |
430 TEST_F(NavigationControllerTest, LoadURL) { | 386 TEST_F(NavigationControllerTest, LoadURL) { |
431 NavigationControllerImpl& controller = controller_impl(); | 387 NavigationControllerImpl& controller = controller_impl(); |
432 TestNotificationTracker notifications; | 388 TestNotificationTracker notifications; |
433 RegisterForAllNavNotifications(¬ifications, &controller); | 389 RegisterForAllNavNotifications(¬ifications, &controller); |
434 | 390 |
435 const GURL url1("http://foo1"); | 391 const GURL url1("http://foo1"); |
436 const GURL url2("http://foo2"); | 392 const GURL url2("http://foo2"); |
437 | 393 |
438 controller.LoadURL( | 394 controller.LoadURL( |
439 url1, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); | 395 url1, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); |
(...skipping 4726 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5166 EXPECT_EQ(default_ssl_status.connection_status, | 5122 EXPECT_EQ(default_ssl_status.connection_status, |
5167 details.ssl_status.connection_status); | 5123 details.ssl_status.connection_status); |
5168 EXPECT_EQ(default_ssl_status.content_status, | 5124 EXPECT_EQ(default_ssl_status.content_status, |
5169 details.ssl_status.content_status); | 5125 details.ssl_status.content_status); |
5170 EXPECT_EQ(0u, details.ssl_status.signed_certificate_timestamp_ids.size()); | 5126 EXPECT_EQ(0u, details.ssl_status.signed_certificate_timestamp_ids.size()); |
5171 | 5127 |
5172 EXPECT_EQ(1, main_test_rfh()->GetProcess()->bad_msg_count()); | 5128 EXPECT_EQ(1, main_test_rfh()->GetProcess()->bad_msg_count()); |
5173 } | 5129 } |
5174 | 5130 |
5175 } // namespace content | 5131 } // namespace content |
OLD | NEW |