| 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 17 matching lines...) Expand all Loading... |
| 28 #include "content/public/browser/render_view_host.h" | 28 #include "content/public/browser/render_view_host.h" |
| 29 #include "content/public/browser/web_contents_delegate.h" | 29 #include "content/public/browser/web_contents_delegate.h" |
| 30 #include "content/public/browser/web_contents_observer.h" | 30 #include "content/public/browser/web_contents_observer.h" |
| 31 #include "content/public/common/content_switches.h" | 31 #include "content/public/common/content_switches.h" |
| 32 #include "content/public/common/page_state.h" | 32 #include "content/public/common/page_state.h" |
| 33 #include "content/public/common/page_type.h" | 33 #include "content/public/common/page_type.h" |
| 34 #include "content/public/common/url_constants.h" | 34 #include "content/public/common/url_constants.h" |
| 35 #include "content/public/test/mock_render_process_host.h" | 35 #include "content/public/test/mock_render_process_host.h" |
| 36 #include "content/public/test/test_notification_tracker.h" | 36 #include "content/public/test/test_notification_tracker.h" |
| 37 #include "content/public/test/test_utils.h" | 37 #include "content/public/test/test_utils.h" |
| 38 #include "content/test/test_navigation_url_loader.h" |
| 38 #include "content/test/test_render_frame_host.h" | 39 #include "content/test/test_render_frame_host.h" |
| 39 #include "content/test/test_render_view_host.h" | 40 #include "content/test/test_render_view_host.h" |
| 40 #include "content/test/test_web_contents.h" | 41 #include "content/test/test_web_contents.h" |
| 41 #include "net/base/net_util.h" | 42 #include "net/base/net_util.h" |
| 42 #include "skia/ext/platform_canvas.h" | 43 #include "skia/ext/platform_canvas.h" |
| 43 #include "testing/gtest/include/gtest/gtest.h" | 44 #include "testing/gtest/include/gtest/gtest.h" |
| 44 | 45 |
| 45 using base::Time; | 46 using base::Time; |
| 46 | 47 |
| 47 namespace { | 48 namespace { |
| (...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 309 NavigationControllerImpl& controller = controller_impl(); | 310 NavigationControllerImpl& controller = controller_impl(); |
| 310 TestNotificationTracker notifications; | 311 TestNotificationTracker notifications; |
| 311 RegisterForAllNavNotifications(¬ifications, &controller); | 312 RegisterForAllNavNotifications(¬ifications, &controller); |
| 312 | 313 |
| 313 const int kNumUrls = 5; | 314 const int kNumUrls = 5; |
| 314 std::vector<GURL> urls(kNumUrls); | 315 std::vector<GURL> urls(kNumUrls); |
| 315 for (int i = 0; i < kNumUrls; ++i) { | 316 for (int i = 0; i < kNumUrls; ++i) { |
| 316 urls[i] = GURL(base::StringPrintf("http://www.a.com/%d", i)); | 317 urls[i] = GURL(base::StringPrintf("http://www.a.com/%d", i)); |
| 317 } | 318 } |
| 318 | 319 |
| 319 main_test_rfh()->PrepareForCommit(urls[0]); | 320 main_test_rfh()->SendBeginNavigationWithURL(urls[0], true); |
| 321 main_test_rfh()->PrepareForCommit(); |
| 320 main_test_rfh()->SendNavigate(0, urls[0]); | 322 main_test_rfh()->SendNavigate(0, urls[0]); |
| 321 EXPECT_EQ(1U, navigation_entry_committed_counter_); | 323 EXPECT_EQ(1U, navigation_entry_committed_counter_); |
| 322 navigation_entry_committed_counter_ = 0; | 324 navigation_entry_committed_counter_ = 0; |
| 323 EXPECT_EQ(urls[0], controller.GetVisibleEntry()->GetVirtualURL()); | 325 EXPECT_EQ(urls[0], controller.GetVisibleEntry()->GetVirtualURL()); |
| 324 EXPECT_FALSE(controller.CanGoBack()); | 326 EXPECT_FALSE(controller.CanGoBack()); |
| 325 EXPECT_FALSE(controller.CanGoForward()); | 327 EXPECT_FALSE(controller.CanGoForward()); |
| 326 EXPECT_FALSE(controller.CanGoToOffset(1)); | 328 EXPECT_FALSE(controller.CanGoToOffset(1)); |
| 327 | 329 |
| 328 for (int i = 1; i <= 4; ++i) { | 330 for (int i = 1; i <= 4; ++i) { |
| 329 main_test_rfh()->PrepareForCommit(urls[i]); | 331 main_test_rfh()->SendBeginNavigationWithURL(urls[i], true); |
| 332 main_test_rfh()->PrepareForCommit(); |
| 330 main_test_rfh()->SendNavigate(i, urls[i]); | 333 main_test_rfh()->SendNavigate(i, urls[i]); |
| 331 EXPECT_EQ(1U, navigation_entry_committed_counter_); | 334 EXPECT_EQ(1U, navigation_entry_committed_counter_); |
| 332 navigation_entry_committed_counter_ = 0; | 335 navigation_entry_committed_counter_ = 0; |
| 333 EXPECT_EQ(urls[i], controller.GetVisibleEntry()->GetVirtualURL()); | 336 EXPECT_EQ(urls[i], controller.GetVisibleEntry()->GetVirtualURL()); |
| 334 EXPECT_TRUE(controller.CanGoToOffset(-i)); | 337 EXPECT_TRUE(controller.CanGoToOffset(-i)); |
| 335 EXPECT_FALSE(controller.CanGoToOffset(-(i + 1))); | 338 EXPECT_FALSE(controller.CanGoToOffset(-(i + 1))); |
| 336 EXPECT_FALSE(controller.CanGoToOffset(1)); | 339 EXPECT_FALSE(controller.CanGoToOffset(1)); |
| 337 } | 340 } |
| 338 | 341 |
| 339 // We have loaded 5 pages, and are currently at the last-loaded page. | 342 // We have loaded 5 pages, and are currently at the last-loaded page. |
| (...skipping 15 matching lines...) Expand all Loading... |
| 355 GO_TO_BEGINNING, | 358 GO_TO_BEGINNING, |
| 356 GO_TO_END | 359 GO_TO_END |
| 357 }; | 360 }; |
| 358 | 361 |
| 359 for (int test = 0; test < NUM_TESTS; ++test) { | 362 for (int test = 0; test < NUM_TESTS; ++test) { |
| 360 int offset = test_offsets[test]; | 363 int offset = test_offsets[test]; |
| 361 controller.GoToOffset(offset); | 364 controller.GoToOffset(offset); |
| 362 url_index += offset; | 365 url_index += offset; |
| 363 // Check that the GoToOffset will land on the expected page. | 366 // Check that the GoToOffset will land on the expected page. |
| 364 EXPECT_EQ(urls[url_index], controller.GetPendingEntry()->GetVirtualURL()); | 367 EXPECT_EQ(urls[url_index], controller.GetPendingEntry()->GetVirtualURL()); |
| 365 main_test_rfh()->PrepareForCommit(urls[url_index]); | 368 main_test_rfh()->PrepareForCommit(); |
| 366 main_test_rfh()->SendNavigate(url_index, urls[url_index]); | 369 main_test_rfh()->SendNavigate(url_index, urls[url_index]); |
| 367 EXPECT_EQ(1U, navigation_entry_committed_counter_); | 370 EXPECT_EQ(1U, navigation_entry_committed_counter_); |
| 368 navigation_entry_committed_counter_ = 0; | 371 navigation_entry_committed_counter_ = 0; |
| 369 // Check that we can go to any valid offset into the history. | 372 // Check that we can go to any valid offset into the history. |
| 370 for (size_t j = 0; j < urls.size(); ++j) | 373 for (size_t j = 0; j < urls.size(); ++j) |
| 371 EXPECT_TRUE(controller.CanGoToOffset(j - url_index)); | 374 EXPECT_TRUE(controller.CanGoToOffset(j - url_index)); |
| 372 // Check that we can't go beyond the beginning or end of the history. | 375 // Check that we can't go beyond the beginning or end of the history. |
| 373 EXPECT_FALSE(controller.CanGoToOffset(-(url_index + 1))); | 376 EXPECT_FALSE(controller.CanGoToOffset(-(url_index + 1))); |
| 374 EXPECT_FALSE(controller.CanGoToOffset(urls.size() - url_index)); | 377 EXPECT_FALSE(controller.CanGoToOffset(urls.size() - url_index)); |
| 375 } | 378 } |
| (...skipping 24 matching lines...) Expand all Loading... |
| 400 EXPECT_FALSE(controller.CanGoForward()); | 403 EXPECT_FALSE(controller.CanGoForward()); |
| 401 EXPECT_EQ(contents()->GetMaxPageID(), -1); | 404 EXPECT_EQ(contents()->GetMaxPageID(), -1); |
| 402 | 405 |
| 403 // Neither the timestamp nor the status code should have been set yet. | 406 // Neither the timestamp nor the status code should have been set yet. |
| 404 EXPECT_TRUE(controller.GetPendingEntry()->GetTimestamp().is_null()); | 407 EXPECT_TRUE(controller.GetPendingEntry()->GetTimestamp().is_null()); |
| 405 EXPECT_EQ(0, controller.GetPendingEntry()->GetHttpStatusCode()); | 408 EXPECT_EQ(0, controller.GetPendingEntry()->GetHttpStatusCode()); |
| 406 | 409 |
| 407 // We should have gotten no notifications from the preceeding checks. | 410 // We should have gotten no notifications from the preceeding checks. |
| 408 EXPECT_EQ(0U, notifications.size()); | 411 EXPECT_EQ(0U, notifications.size()); |
| 409 | 412 |
| 410 main_test_rfh()->PrepareForCommit(url1); | 413 main_test_rfh()->PrepareForCommit(); |
| 411 main_test_rfh()->SendNavigate(0, url1); | 414 main_test_rfh()->SendNavigate(0, url1); |
| 412 EXPECT_EQ(1U, navigation_entry_committed_counter_); | 415 EXPECT_EQ(1U, navigation_entry_committed_counter_); |
| 413 navigation_entry_committed_counter_ = 0; | 416 navigation_entry_committed_counter_ = 0; |
| 414 | 417 |
| 415 // The load should now be committed. | 418 // The load should now be committed. |
| 416 EXPECT_EQ(controller.GetEntryCount(), 1); | 419 EXPECT_EQ(controller.GetEntryCount(), 1); |
| 417 EXPECT_EQ(controller.GetLastCommittedEntryIndex(), 0); | 420 EXPECT_EQ(controller.GetLastCommittedEntryIndex(), 0); |
| 418 EXPECT_EQ(controller.GetPendingEntryIndex(), -1); | 421 EXPECT_EQ(controller.GetPendingEntryIndex(), -1); |
| 419 EXPECT_TRUE(controller.GetLastCommittedEntry()); | 422 EXPECT_TRUE(controller.GetLastCommittedEntry()); |
| 420 EXPECT_FALSE(controller.GetPendingEntry()); | 423 EXPECT_FALSE(controller.GetPendingEntry()); |
| (...skipping 19 matching lines...) Expand all Loading... |
| 440 EXPECT_EQ(controller.GetPendingEntry(), controller.GetVisibleEntry()); | 443 EXPECT_EQ(controller.GetPendingEntry(), controller.GetVisibleEntry()); |
| 441 // TODO(darin): maybe this should really be true? | 444 // TODO(darin): maybe this should really be true? |
| 442 EXPECT_FALSE(controller.CanGoBack()); | 445 EXPECT_FALSE(controller.CanGoBack()); |
| 443 EXPECT_FALSE(controller.CanGoForward()); | 446 EXPECT_FALSE(controller.CanGoForward()); |
| 444 EXPECT_EQ(contents()->GetMaxPageID(), 0); | 447 EXPECT_EQ(contents()->GetMaxPageID(), 0); |
| 445 | 448 |
| 446 EXPECT_TRUE(controller.GetPendingEntry()->GetTimestamp().is_null()); | 449 EXPECT_TRUE(controller.GetPendingEntry()->GetTimestamp().is_null()); |
| 447 | 450 |
| 448 // Simulate the beforeunload ack for the cross-site transition, and then the | 451 // Simulate the beforeunload ack for the cross-site transition, and then the |
| 449 // commit. | 452 // commit. |
| 450 main_test_rfh()->PrepareForCommit(url2); | 453 main_test_rfh()->PrepareForCommit(); |
| 451 contents()->GetPendingMainFrame()->SendNavigate(1, url2); | 454 contents()->GetPendingMainFrame()->SendNavigate(1, url2); |
| 452 EXPECT_EQ(1U, navigation_entry_committed_counter_); | 455 EXPECT_EQ(1U, navigation_entry_committed_counter_); |
| 453 navigation_entry_committed_counter_ = 0; | 456 navigation_entry_committed_counter_ = 0; |
| 454 | 457 |
| 455 // The load should now be committed. | 458 // The load should now be committed. |
| 456 EXPECT_EQ(controller.GetEntryCount(), 2); | 459 EXPECT_EQ(controller.GetEntryCount(), 2); |
| 457 EXPECT_EQ(controller.GetLastCommittedEntryIndex(), 1); | 460 EXPECT_EQ(controller.GetLastCommittedEntryIndex(), 1); |
| 458 EXPECT_EQ(controller.GetPendingEntryIndex(), -1); | 461 EXPECT_EQ(controller.GetPendingEntryIndex(), -1); |
| 459 EXPECT_TRUE(controller.GetLastCommittedEntry()); | 462 EXPECT_TRUE(controller.GetLastCommittedEntry()); |
| 460 EXPECT_FALSE(controller.GetPendingEntry()); | 463 EXPECT_FALSE(controller.GetPendingEntry()); |
| (...skipping 21 matching lines...) Expand all Loading... |
| 482 // Set the clock to always return a timestamp of 1. | 485 // Set the clock to always return a timestamp of 1. |
| 483 controller.SetGetTimestampCallbackForTest( | 486 controller.SetGetTimestampCallbackForTest( |
| 484 base::Bind(&GetFixedTime, base::Time::FromInternalValue(1))); | 487 base::Bind(&GetFixedTime, base::Time::FromInternalValue(1))); |
| 485 | 488 |
| 486 const GURL url1("http://foo1"); | 489 const GURL url1("http://foo1"); |
| 487 const GURL url2("http://foo2"); | 490 const GURL url2("http://foo2"); |
| 488 | 491 |
| 489 controller.LoadURL( | 492 controller.LoadURL( |
| 490 url1, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); | 493 url1, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); |
| 491 | 494 |
| 492 main_test_rfh()->PrepareForCommit(url1); | 495 main_test_rfh()->PrepareForCommit(); |
| 493 main_test_rfh()->SendNavigate(0, url1); | 496 main_test_rfh()->SendNavigate(0, url1); |
| 494 EXPECT_EQ(1U, navigation_entry_committed_counter_); | 497 EXPECT_EQ(1U, navigation_entry_committed_counter_); |
| 495 navigation_entry_committed_counter_ = 0; | 498 navigation_entry_committed_counter_ = 0; |
| 496 | 499 |
| 497 // Load another... | 500 // Load another... |
| 498 controller.LoadURL( | 501 controller.LoadURL( |
| 499 url2, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); | 502 url2, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); |
| 500 | 503 |
| 501 // Simulate the beforeunload ack for the cross-site transition, and then the | 504 // Simulate the beforeunload ack for the cross-site transition, and then the |
| 502 // commit. | 505 // commit. |
| 503 main_test_rfh()->PrepareForCommit(url2); | 506 main_test_rfh()->PrepareForCommit(); |
| 504 contents()->GetPendingMainFrame()->SendNavigate(1, url2); | 507 contents()->GetPendingMainFrame()->SendNavigate(1, url2); |
| 505 EXPECT_EQ(1U, navigation_entry_committed_counter_); | 508 EXPECT_EQ(1U, navigation_entry_committed_counter_); |
| 506 navigation_entry_committed_counter_ = 0; | 509 navigation_entry_committed_counter_ = 0; |
| 507 | 510 |
| 508 // The two loads should now be committed. | 511 // The two loads should now be committed. |
| 509 ASSERT_EQ(controller.GetEntryCount(), 2); | 512 ASSERT_EQ(controller.GetEntryCount(), 2); |
| 510 | 513 |
| 511 // Timestamps should be distinct despite the clock returning the | 514 // Timestamps should be distinct despite the clock returning the |
| 512 // same value. | 515 // same value. |
| 513 EXPECT_EQ(1u, | 516 EXPECT_EQ(1u, |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 612 TEST_F(NavigationControllerTest, LoadURL_SamePage) { | 615 TEST_F(NavigationControllerTest, LoadURL_SamePage) { |
| 613 NavigationControllerImpl& controller = controller_impl(); | 616 NavigationControllerImpl& controller = controller_impl(); |
| 614 TestNotificationTracker notifications; | 617 TestNotificationTracker notifications; |
| 615 RegisterForAllNavNotifications(¬ifications, &controller); | 618 RegisterForAllNavNotifications(¬ifications, &controller); |
| 616 | 619 |
| 617 const GURL url1("http://foo1"); | 620 const GURL url1("http://foo1"); |
| 618 | 621 |
| 619 controller.LoadURL( | 622 controller.LoadURL( |
| 620 url1, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); | 623 url1, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); |
| 621 EXPECT_EQ(0U, notifications.size()); | 624 EXPECT_EQ(0U, notifications.size()); |
| 622 main_test_rfh()->PrepareForCommit(url1); | 625 main_test_rfh()->PrepareForCommit(); |
| 623 main_test_rfh()->SendNavigate(0, url1); | 626 main_test_rfh()->SendNavigate(0, url1); |
| 624 EXPECT_EQ(1U, navigation_entry_committed_counter_); | 627 EXPECT_EQ(1U, navigation_entry_committed_counter_); |
| 625 navigation_entry_committed_counter_ = 0; | 628 navigation_entry_committed_counter_ = 0; |
| 626 | 629 |
| 627 ASSERT_TRUE(controller.GetVisibleEntry()); | 630 ASSERT_TRUE(controller.GetVisibleEntry()); |
| 628 const base::Time timestamp = controller.GetVisibleEntry()->GetTimestamp(); | 631 const base::Time timestamp = controller.GetVisibleEntry()->GetTimestamp(); |
| 629 EXPECT_FALSE(timestamp.is_null()); | 632 EXPECT_FALSE(timestamp.is_null()); |
| 630 | 633 |
| 631 controller.LoadURL( | 634 controller.LoadURL( |
| 632 url1, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); | 635 url1, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); |
| 633 EXPECT_EQ(0U, notifications.size()); | 636 EXPECT_EQ(0U, notifications.size()); |
| 634 main_test_rfh()->PrepareForCommit(url1); | 637 main_test_rfh()->PrepareForCommit(); |
| 635 main_test_rfh()->SendNavigate(0, url1); | 638 main_test_rfh()->SendNavigate(0, url1); |
| 636 EXPECT_EQ(1U, navigation_entry_committed_counter_); | 639 EXPECT_EQ(1U, navigation_entry_committed_counter_); |
| 637 navigation_entry_committed_counter_ = 0; | 640 navigation_entry_committed_counter_ = 0; |
| 638 | 641 |
| 639 // We should not have produced a new session history entry. | 642 // We should not have produced a new session history entry. |
| 640 EXPECT_EQ(controller.GetEntryCount(), 1); | 643 EXPECT_EQ(controller.GetEntryCount(), 1); |
| 641 EXPECT_EQ(controller.GetLastCommittedEntryIndex(), 0); | 644 EXPECT_EQ(controller.GetLastCommittedEntryIndex(), 0); |
| 642 EXPECT_EQ(controller.GetPendingEntryIndex(), -1); | 645 EXPECT_EQ(controller.GetPendingEntryIndex(), -1); |
| 643 EXPECT_TRUE(controller.GetLastCommittedEntry()); | 646 EXPECT_TRUE(controller.GetLastCommittedEntry()); |
| 644 EXPECT_FALSE(controller.GetPendingEntry()); | 647 EXPECT_FALSE(controller.GetPendingEntry()); |
| (...skipping 19 matching lines...) Expand all Loading... |
| 664 | 667 |
| 665 controller.LoadURL( | 668 controller.LoadURL( |
| 666 url1, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); | 669 url1, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); |
| 667 FrameHostMsg_DidCommitProvisionalLoad_Params params; | 670 FrameHostMsg_DidCommitProvisionalLoad_Params params; |
| 668 params.page_id = 0; | 671 params.page_id = 0; |
| 669 params.url = url1; | 672 params.url = url1; |
| 670 params.transition = ui::PAGE_TRANSITION_TYPED; | 673 params.transition = ui::PAGE_TRANSITION_TYPED; |
| 671 params.is_post = true; | 674 params.is_post = true; |
| 672 params.post_id = 123; | 675 params.post_id = 123; |
| 673 params.page_state = PageState::CreateForTesting(url1, false, 0, 0); | 676 params.page_state = PageState::CreateForTesting(url1, false, 0, 0); |
| 674 main_test_rfh()->PrepareForCommit(url1); | 677 main_test_rfh()->PrepareForCommit(); |
| 675 main_test_rfh()->SendNavigateWithParams(¶ms); | 678 main_test_rfh()->SendNavigateWithParams(¶ms); |
| 676 | 679 |
| 677 // The post data should be visible. | 680 // The post data should be visible. |
| 678 NavigationEntry* entry = controller.GetVisibleEntry(); | 681 NavigationEntry* entry = controller.GetVisibleEntry(); |
| 679 ASSERT_TRUE(entry); | 682 ASSERT_TRUE(entry); |
| 680 EXPECT_TRUE(entry->GetHasPostData()); | 683 EXPECT_TRUE(entry->GetHasPostData()); |
| 681 EXPECT_EQ(entry->GetPostID(), 123); | 684 EXPECT_EQ(entry->GetPostID(), 123); |
| 682 | 685 |
| 683 controller.LoadURL( | 686 controller.LoadURL( |
| 684 url1, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); | 687 url1, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); |
| 685 main_test_rfh()->PrepareForCommit(url1); | 688 main_test_rfh()->PrepareForCommit(); |
| 686 main_test_rfh()->SendNavigate(0, url1); | 689 main_test_rfh()->SendNavigate(0, url1); |
| 687 | 690 |
| 688 // We should not have produced a new session history entry. | 691 // We should not have produced a new session history entry. |
| 689 ASSERT_EQ(controller.GetVisibleEntry(), entry); | 692 ASSERT_EQ(controller.GetVisibleEntry(), entry); |
| 690 | 693 |
| 691 // The post data should have been cleared due to the GET. | 694 // The post data should have been cleared due to the GET. |
| 692 EXPECT_FALSE(entry->GetHasPostData()); | 695 EXPECT_FALSE(entry->GetHasPostData()); |
| 693 EXPECT_EQ(entry->GetPostID(), 0); | 696 EXPECT_EQ(entry->GetPostID(), 0); |
| 694 } | 697 } |
| 695 | 698 |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 766 // commits. | 769 // commits. |
| 767 TEST_F(NavigationControllerTest, LoadURL_NewPending) { | 770 TEST_F(NavigationControllerTest, LoadURL_NewPending) { |
| 768 NavigationControllerImpl& controller = controller_impl(); | 771 NavigationControllerImpl& controller = controller_impl(); |
| 769 TestNotificationTracker notifications; | 772 TestNotificationTracker notifications; |
| 770 RegisterForAllNavNotifications(¬ifications, &controller); | 773 RegisterForAllNavNotifications(¬ifications, &controller); |
| 771 | 774 |
| 772 // First make an existing committed entry. | 775 // First make an existing committed entry. |
| 773 const GURL kExistingURL1("http://eh"); | 776 const GURL kExistingURL1("http://eh"); |
| 774 controller.LoadURL( | 777 controller.LoadURL( |
| 775 kExistingURL1, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); | 778 kExistingURL1, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); |
| 776 main_test_rfh()->PrepareForCommit(kExistingURL1); | 779 main_test_rfh()->PrepareForCommit(); |
| 777 main_test_rfh()->SendNavigate(0, kExistingURL1); | 780 main_test_rfh()->SendNavigate(0, kExistingURL1); |
| 778 EXPECT_EQ(1U, navigation_entry_committed_counter_); | 781 EXPECT_EQ(1U, navigation_entry_committed_counter_); |
| 779 navigation_entry_committed_counter_ = 0; | 782 navigation_entry_committed_counter_ = 0; |
| 780 | 783 |
| 781 // Make a pending entry to somewhere new. | 784 // Make a pending entry to somewhere new. |
| 782 const GURL kExistingURL2("http://bee"); | 785 const GURL kExistingURL2("http://bee"); |
| 783 controller.LoadURL( | 786 controller.LoadURL( |
| 784 kExistingURL2, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); | 787 kExistingURL2, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); |
| 785 EXPECT_EQ(0U, notifications.size()); | 788 EXPECT_EQ(0U, notifications.size()); |
| 786 | 789 |
| 787 // After the beforeunload but before it commits, do a new navigation. | 790 // After the beforeunload but before it commits, do a new navigation. |
| 788 main_test_rfh()->PrepareForCommit(kExistingURL2); | 791 main_test_rfh()->PrepareForCommit(); |
| 789 const GURL kNewURL("http://see"); | 792 const GURL kNewURL("http://see"); |
| 790 main_test_rfh()->PrepareForCommit(kNewURL); | 793 main_test_rfh()->PrepareForCommit(); |
| 791 contents()->GetMainFrame()->SendNavigate(3, kNewURL); | 794 contents()->GetMainFrame()->SendNavigate(3, kNewURL); |
| 792 | 795 |
| 793 // There should no longer be any pending entry, and the third navigation we | 796 // There should no longer be any pending entry, and the third navigation we |
| 794 // just made should be committed. | 797 // just made should be committed. |
| 795 EXPECT_EQ(1U, navigation_entry_committed_counter_); | 798 EXPECT_EQ(1U, navigation_entry_committed_counter_); |
| 796 navigation_entry_committed_counter_ = 0; | 799 navigation_entry_committed_counter_ = 0; |
| 797 EXPECT_EQ(-1, controller.GetPendingEntryIndex()); | 800 EXPECT_EQ(-1, controller.GetPendingEntryIndex()); |
| 798 EXPECT_EQ(1, controller.GetLastCommittedEntryIndex()); | 801 EXPECT_EQ(1, controller.GetLastCommittedEntryIndex()); |
| 799 EXPECT_EQ(kNewURL, controller.GetVisibleEntry()->GetURL()); | 802 EXPECT_EQ(kNewURL, controller.GetVisibleEntry()->GetURL()); |
| 800 } | 803 } |
| 801 | 804 |
| 802 // Tests navigating to a new URL when there is a pending back/forward | 805 // Tests navigating to a new URL when there is a pending back/forward |
| 803 // navigation. This will happen if the user hits back, but before that commits, | 806 // navigation. This will happen if the user hits back, but before that commits, |
| 804 // they navigate somewhere new. | 807 // they navigate somewhere new. |
| 805 TEST_F(NavigationControllerTest, LoadURL_ExistingPending) { | 808 TEST_F(NavigationControllerTest, LoadURL_ExistingPending) { |
| 806 NavigationControllerImpl& controller = controller_impl(); | 809 NavigationControllerImpl& controller = controller_impl(); |
| 807 TestNotificationTracker notifications; | 810 TestNotificationTracker notifications; |
| 808 RegisterForAllNavNotifications(¬ifications, &controller); | 811 RegisterForAllNavNotifications(¬ifications, &controller); |
| 809 | 812 |
| 810 // First make some history. | 813 // First make some history. |
| 811 const GURL kExistingURL1("http://foo/eh"); | 814 const GURL kExistingURL1("http://foo/eh"); |
| 812 controller.LoadURL( | 815 controller.LoadURL( |
| 813 kExistingURL1, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); | 816 kExistingURL1, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); |
| 814 main_test_rfh()->PrepareForCommit(kExistingURL1); | 817 main_test_rfh()->PrepareForCommit(); |
| 815 main_test_rfh()->SendNavigate(0, kExistingURL1); | 818 main_test_rfh()->SendNavigate(0, kExistingURL1); |
| 816 EXPECT_EQ(1U, navigation_entry_committed_counter_); | 819 EXPECT_EQ(1U, navigation_entry_committed_counter_); |
| 817 navigation_entry_committed_counter_ = 0; | 820 navigation_entry_committed_counter_ = 0; |
| 818 | 821 |
| 819 const GURL kExistingURL2("http://foo/bee"); | 822 const GURL kExistingURL2("http://foo/bee"); |
| 820 controller.LoadURL( | 823 controller.LoadURL( |
| 821 kExistingURL2, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); | 824 kExistingURL2, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); |
| 822 main_test_rfh()->PrepareForCommit(kExistingURL2); | 825 main_test_rfh()->PrepareForCommit(); |
| 823 main_test_rfh()->SendNavigate(1, kExistingURL2); | 826 main_test_rfh()->SendNavigate(1, kExistingURL2); |
| 824 EXPECT_EQ(1U, navigation_entry_committed_counter_); | 827 EXPECT_EQ(1U, navigation_entry_committed_counter_); |
| 825 navigation_entry_committed_counter_ = 0; | 828 navigation_entry_committed_counter_ = 0; |
| 826 | 829 |
| 827 // Now make a pending back/forward navigation. The zeroth entry should be | 830 // Now make a pending back/forward navigation. The zeroth entry should be |
| 828 // pending. | 831 // pending. |
| 829 controller.GoBack(); | 832 controller.GoBack(); |
| 830 EXPECT_EQ(0U, notifications.size()); | 833 EXPECT_EQ(0U, notifications.size()); |
| 831 EXPECT_EQ(0, controller.GetPendingEntryIndex()); | 834 EXPECT_EQ(0, controller.GetPendingEntryIndex()); |
| 832 EXPECT_EQ(1, controller.GetLastCommittedEntryIndex()); | 835 EXPECT_EQ(1, controller.GetLastCommittedEntryIndex()); |
| 833 | 836 |
| 834 // Before that commits, do a new navigation. | 837 // Before that commits, do a new navigation. |
| 835 const GURL kNewURL("http://foo/see"); | 838 const GURL kNewURL("http://foo/see"); |
| 836 main_test_rfh()->PrepareForCommit(kNewURL); | 839 main_test_rfh()->SendBeginNavigationWithURL(kNewURL, true); |
| 840 main_test_rfh()->PrepareForCommit(); |
| 837 main_test_rfh()->SendNavigate(3, kNewURL); | 841 main_test_rfh()->SendNavigate(3, kNewURL); |
| 838 | 842 |
| 839 // There should no longer be any pending entry, and the third navigation we | 843 // There should no longer be any pending entry, and the third navigation we |
| 840 // just made should be committed. | 844 // just made should be committed. |
| 841 EXPECT_EQ(1U, navigation_entry_committed_counter_); | 845 EXPECT_EQ(1U, navigation_entry_committed_counter_); |
| 842 navigation_entry_committed_counter_ = 0; | 846 navigation_entry_committed_counter_ = 0; |
| 843 EXPECT_EQ(-1, controller.GetPendingEntryIndex()); | 847 EXPECT_EQ(-1, controller.GetPendingEntryIndex()); |
| 844 EXPECT_EQ(2, controller.GetLastCommittedEntryIndex()); | 848 EXPECT_EQ(2, controller.GetLastCommittedEntryIndex()); |
| 845 EXPECT_EQ(kNewURL, controller.GetVisibleEntry()->GetURL()); | 849 EXPECT_EQ(kNewURL, controller.GetVisibleEntry()->GetURL()); |
| 846 } | 850 } |
| 847 | 851 |
| 848 // Tests navigating to a new URL when there is a pending back/forward | 852 // Tests navigating to a new URL when there is a pending back/forward |
| 849 // navigation to a cross-process, privileged URL. This will happen if the user | 853 // navigation to a cross-process, privileged URL. This will happen if the user |
| 850 // hits back, but before that commits, they navigate somewhere new. | 854 // hits back, but before that commits, they navigate somewhere new. |
| 851 TEST_F(NavigationControllerTest, LoadURL_PrivilegedPending) { | 855 TEST_F(NavigationControllerTest, LoadURL_PrivilegedPending) { |
| 852 NavigationControllerImpl& controller = controller_impl(); | 856 NavigationControllerImpl& controller = controller_impl(); |
| 853 TestNotificationTracker notifications; | 857 TestNotificationTracker notifications; |
| 854 RegisterForAllNavNotifications(¬ifications, &controller); | 858 RegisterForAllNavNotifications(¬ifications, &controller); |
| 855 | 859 |
| 856 // First make some history, starting with a privileged URL. | 860 // First make some history, starting with a privileged URL. |
| 857 const GURL kExistingURL1("http://privileged"); | 861 const GURL kExistingURL1("http://privileged"); |
| 858 controller.LoadURL( | 862 controller.LoadURL( |
| 859 kExistingURL1, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); | 863 kExistingURL1, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); |
| 860 // Pretend it has bindings so we can tell if we incorrectly copy it. | 864 // Pretend it has bindings so we can tell if we incorrectly copy it. |
| 861 main_test_rfh()->GetRenderViewHost()->AllowBindings(2); | 865 main_test_rfh()->GetRenderViewHost()->AllowBindings(2); |
| 862 main_test_rfh()->PrepareForCommit(kExistingURL1); | 866 main_test_rfh()->PrepareForCommit(); |
| 863 main_test_rfh()->SendNavigate(0, kExistingURL1); | 867 main_test_rfh()->SendNavigate(0, kExistingURL1); |
| 864 EXPECT_EQ(1U, navigation_entry_committed_counter_); | 868 EXPECT_EQ(1U, navigation_entry_committed_counter_); |
| 865 navigation_entry_committed_counter_ = 0; | 869 navigation_entry_committed_counter_ = 0; |
| 866 | 870 |
| 867 // Navigate cross-process to a second URL. | 871 // Navigate cross-process to a second URL. |
| 868 const GURL kExistingURL2("http://foo/eh"); | 872 const GURL kExistingURL2("http://foo/eh"); |
| 869 controller.LoadURL( | 873 controller.LoadURL( |
| 870 kExistingURL2, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); | 874 kExistingURL2, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); |
| 871 main_test_rfh()->PrepareForCommit(kExistingURL2); | 875 main_test_rfh()->PrepareForCommit(); |
| 872 TestRenderFrameHost* foo_rfh = contents()->GetPendingMainFrame(); | 876 TestRenderFrameHost* foo_rfh = contents()->GetPendingMainFrame(); |
| 873 foo_rfh->SendNavigate(1, kExistingURL2); | 877 foo_rfh->SendNavigate(1, kExistingURL2); |
| 874 EXPECT_EQ(1U, navigation_entry_committed_counter_); | 878 EXPECT_EQ(1U, navigation_entry_committed_counter_); |
| 875 navigation_entry_committed_counter_ = 0; | 879 navigation_entry_committed_counter_ = 0; |
| 876 | 880 |
| 877 // Now make a pending back/forward navigation to a privileged entry. | 881 // Now make a pending back/forward navigation to a privileged entry. |
| 878 // The zeroth entry should be pending. | 882 // The zeroth entry should be pending. |
| 879 controller.GoBack(); | 883 controller.GoBack(); |
| 880 foo_rfh->SendBeforeUnloadACK(true); | 884 foo_rfh->SendBeforeUnloadACK(true); |
| 881 EXPECT_EQ(0U, notifications.size()); | 885 EXPECT_EQ(0U, notifications.size()); |
| 882 EXPECT_EQ(0, controller.GetPendingEntryIndex()); | 886 EXPECT_EQ(0, controller.GetPendingEntryIndex()); |
| 883 EXPECT_EQ(1, controller.GetLastCommittedEntryIndex()); | 887 EXPECT_EQ(1, controller.GetLastCommittedEntryIndex()); |
| 884 EXPECT_EQ(2, controller.GetPendingEntry()->bindings()); | 888 EXPECT_EQ(2, controller.GetPendingEntry()->bindings()); |
| 885 | 889 |
| 886 // Before that commits, do a new navigation. | 890 // Before that commits, do a new navigation. |
| 887 const GURL kNewURL("http://foo/bee"); | 891 const GURL kNewURL("http://foo/bee"); |
| 888 foo_rfh->PrepareForCommit(kNewURL); | 892 foo_rfh->SendBeginNavigationWithURL(kNewURL, true); |
| 893 foo_rfh->PrepareForCommit(); |
| 889 foo_rfh->SendNavigate(3, kNewURL); | 894 foo_rfh->SendNavigate(3, kNewURL); |
| 890 | 895 |
| 891 // There should no longer be any pending entry, and the third navigation we | 896 // There should no longer be any pending entry, and the third navigation we |
| 892 // just made should be committed. | 897 // just made should be committed. |
| 893 EXPECT_EQ(1U, navigation_entry_committed_counter_); | 898 EXPECT_EQ(1U, navigation_entry_committed_counter_); |
| 894 navigation_entry_committed_counter_ = 0; | 899 navigation_entry_committed_counter_ = 0; |
| 895 EXPECT_EQ(-1, controller.GetPendingEntryIndex()); | 900 EXPECT_EQ(-1, controller.GetPendingEntryIndex()); |
| 896 EXPECT_EQ(2, controller.GetLastCommittedEntryIndex()); | 901 EXPECT_EQ(2, controller.GetLastCommittedEntryIndex()); |
| 897 EXPECT_EQ(kNewURL, controller.GetVisibleEntry()->GetURL()); | 902 EXPECT_EQ(kNewURL, controller.GetVisibleEntry()->GetURL()); |
| 898 EXPECT_EQ(0, controller.GetLastCommittedEntry()->bindings()); | 903 EXPECT_EQ(0, controller.GetLastCommittedEntry()->bindings()); |
| 899 } | 904 } |
| 900 | 905 |
| 901 // Tests navigating to an existing URL when there is a pending new navigation. | 906 // Tests navigating to an existing URL when there is a pending new navigation. |
| 902 // This will happen if the user enters a URL, but before that commits, the | 907 // This will happen if the user enters a URL, but before that commits, the |
| 903 // current page fires history.back(). | 908 // current page fires history.back(). |
| 904 TEST_F(NavigationControllerTest, LoadURL_BackPreemptsPending) { | 909 TEST_F(NavigationControllerTest, LoadURL_BackPreemptsPending) { |
| 905 NavigationControllerImpl& controller = controller_impl(); | 910 NavigationControllerImpl& controller = controller_impl(); |
| 906 TestNotificationTracker notifications; | 911 TestNotificationTracker notifications; |
| 907 RegisterForAllNavNotifications(¬ifications, &controller); | 912 RegisterForAllNavNotifications(¬ifications, &controller); |
| 908 | 913 |
| 909 // First make some history. | 914 // First make some history. |
| 910 const GURL kExistingURL1("http://foo/eh"); | 915 const GURL kExistingURL1("http://foo/eh"); |
| 911 controller.LoadURL( | 916 controller.LoadURL( |
| 912 kExistingURL1, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); | 917 kExistingURL1, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); |
| 913 main_test_rfh()->PrepareForCommit(kExistingURL1); | 918 main_test_rfh()->PrepareForCommit(); |
| 914 main_test_rfh()->SendNavigate(0, kExistingURL1); | 919 main_test_rfh()->SendNavigate(0, kExistingURL1); |
| 915 EXPECT_EQ(1U, navigation_entry_committed_counter_); | 920 EXPECT_EQ(1U, navigation_entry_committed_counter_); |
| 916 navigation_entry_committed_counter_ = 0; | 921 navigation_entry_committed_counter_ = 0; |
| 917 | 922 |
| 918 const GURL kExistingURL2("http://foo/bee"); | 923 const GURL kExistingURL2("http://foo/bee"); |
| 919 controller.LoadURL( | 924 controller.LoadURL( |
| 920 kExistingURL2, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); | 925 kExistingURL2, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); |
| 921 main_test_rfh()->PrepareForCommit(kExistingURL2); | 926 main_test_rfh()->PrepareForCommit(); |
| 922 main_test_rfh()->SendNavigate(1, kExistingURL2); | 927 main_test_rfh()->SendNavigate(1, kExistingURL2); |
| 923 EXPECT_EQ(1U, navigation_entry_committed_counter_); | 928 EXPECT_EQ(1U, navigation_entry_committed_counter_); |
| 924 navigation_entry_committed_counter_ = 0; | 929 navigation_entry_committed_counter_ = 0; |
| 925 | 930 |
| 926 // Now make a pending new navigation. | 931 // Now make a pending new navigation. |
| 927 const GURL kNewURL("http://foo/see"); | 932 const GURL kNewURL("http://foo/see"); |
| 928 controller.LoadURL( | 933 controller.LoadURL( |
| 929 kNewURL, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); | 934 kNewURL, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); |
| 930 EXPECT_EQ(0U, notifications.size()); | 935 EXPECT_EQ(0U, notifications.size()); |
| 931 EXPECT_EQ(-1, controller.GetPendingEntryIndex()); | 936 EXPECT_EQ(-1, controller.GetPendingEntryIndex()); |
| 932 EXPECT_EQ(1, controller.GetLastCommittedEntryIndex()); | 937 EXPECT_EQ(1, controller.GetLastCommittedEntryIndex()); |
| 933 | 938 |
| 934 // Before that commits, a back navigation from the renderer commits. | 939 // Before that commits, a back navigation from the renderer commits. |
| 935 main_test_rfh()->PrepareForCommit(kExistingURL1); | 940 main_test_rfh()->SendBeginNavigationWithURL(kExistingURL1, true); |
| 941 main_test_rfh()->PrepareForCommit(); |
| 936 main_test_rfh()->SendNavigate(0, kExistingURL1); | 942 main_test_rfh()->SendNavigate(0, kExistingURL1); |
| 937 | 943 |
| 938 // There should no longer be any pending entry, and the back navigation we | 944 // There should no longer be any pending entry, and the back navigation we |
| 939 // just made should be committed. | 945 // just made should be committed. |
| 940 EXPECT_EQ(1U, navigation_entry_committed_counter_); | 946 EXPECT_EQ(1U, navigation_entry_committed_counter_); |
| 941 navigation_entry_committed_counter_ = 0; | 947 navigation_entry_committed_counter_ = 0; |
| 942 EXPECT_EQ(-1, controller.GetPendingEntryIndex()); | 948 EXPECT_EQ(-1, controller.GetPendingEntryIndex()); |
| 943 EXPECT_EQ(0, controller.GetLastCommittedEntryIndex()); | 949 EXPECT_EQ(0, controller.GetLastCommittedEntryIndex()); |
| 944 EXPECT_EQ(kExistingURL1, controller.GetVisibleEntry()->GetURL()); | 950 EXPECT_EQ(kExistingURL1, controller.GetVisibleEntry()->GetURL()); |
| 945 } | 951 } |
| (...skipping 19 matching lines...) Expand all Loading... |
| 965 controller.LoadURL( | 971 controller.LoadURL( |
| 966 kNewURL, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); | 972 kNewURL, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); |
| 967 EXPECT_EQ(0U, notifications.size()); | 973 EXPECT_EQ(0U, notifications.size()); |
| 968 EXPECT_EQ(-1, controller.GetPendingEntryIndex()); | 974 EXPECT_EQ(-1, controller.GetPendingEntryIndex()); |
| 969 EXPECT_TRUE(controller.GetPendingEntry()); | 975 EXPECT_TRUE(controller.GetPendingEntry()); |
| 970 EXPECT_EQ(-1, controller.GetLastCommittedEntryIndex()); | 976 EXPECT_EQ(-1, controller.GetLastCommittedEntryIndex()); |
| 971 EXPECT_EQ(1, delegate->navigation_state_change_count()); | 977 EXPECT_EQ(1, delegate->navigation_state_change_count()); |
| 972 | 978 |
| 973 // Before that commits, a document.write and location.reload can cause the | 979 // Before that commits, a document.write and location.reload can cause the |
| 974 // renderer to send a FrameNavigate with page_id -1. | 980 // renderer to send a FrameNavigate with page_id -1. |
| 975 main_test_rfh()->PrepareForCommit(kExistingURL); | 981 main_test_rfh()->SendBeginNavigationWithURL(kExistingURL, true); |
| 982 main_test_rfh()->PrepareForCommit(); |
| 976 main_test_rfh()->SendNavigate(-1, kExistingURL); | 983 main_test_rfh()->SendNavigate(-1, kExistingURL); |
| 977 | 984 |
| 978 // This should clear the pending entry and notify of a navigation state | 985 // This should clear the pending entry and notify of a navigation state |
| 979 // change, so that we do not keep displaying kNewURL. | 986 // change, so that we do not keep displaying kNewURL. |
| 980 EXPECT_EQ(-1, controller.GetPendingEntryIndex()); | 987 EXPECT_EQ(-1, controller.GetPendingEntryIndex()); |
| 981 EXPECT_FALSE(controller.GetPendingEntry()); | 988 EXPECT_FALSE(controller.GetPendingEntry()); |
| 982 EXPECT_EQ(-1, controller.GetLastCommittedEntryIndex()); | 989 EXPECT_EQ(-1, controller.GetLastCommittedEntryIndex()); |
| 983 EXPECT_EQ(2, delegate->navigation_state_change_count()); | 990 EXPECT_EQ(2, delegate->navigation_state_change_count()); |
| 984 | 991 |
| 985 contents()->SetDelegate(NULL); | 992 contents()->SetDelegate(NULL); |
| (...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1116 const GURL url2("http://foo2"); | 1123 const GURL url2("http://foo2"); |
| 1117 | 1124 |
| 1118 // Navigate to a first, unprivileged URL. | 1125 // Navigate to a first, unprivileged URL. |
| 1119 controller.LoadURL( | 1126 controller.LoadURL( |
| 1120 url1, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); | 1127 url1, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); |
| 1121 EXPECT_EQ(NavigationEntryImpl::kInvalidBindings, | 1128 EXPECT_EQ(NavigationEntryImpl::kInvalidBindings, |
| 1122 controller.GetPendingEntry()->bindings()); | 1129 controller.GetPendingEntry()->bindings()); |
| 1123 | 1130 |
| 1124 // Commit. | 1131 // Commit. |
| 1125 TestRenderFrameHost* orig_rfh = contents()->GetMainFrame(); | 1132 TestRenderFrameHost* orig_rfh = contents()->GetMainFrame(); |
| 1126 orig_rfh->PrepareForCommit(url1); | 1133 orig_rfh->PrepareForCommit(); |
| 1127 orig_rfh->SendNavigate(0, url1); | 1134 orig_rfh->SendNavigate(0, url1); |
| 1128 EXPECT_EQ(controller.GetEntryCount(), 1); | 1135 EXPECT_EQ(controller.GetEntryCount(), 1); |
| 1129 EXPECT_EQ(0, controller.GetLastCommittedEntryIndex()); | 1136 EXPECT_EQ(0, controller.GetLastCommittedEntryIndex()); |
| 1130 EXPECT_EQ(0, controller.GetLastCommittedEntry()->bindings()); | 1137 EXPECT_EQ(0, controller.GetLastCommittedEntry()->bindings()); |
| 1131 | 1138 |
| 1132 // Manually increase the number of active frames in the SiteInstance | 1139 // Manually increase the number of active frames in the SiteInstance |
| 1133 // that orig_rfh belongs to, to prevent it from being destroyed when | 1140 // that orig_rfh belongs to, to prevent it from being destroyed when |
| 1134 // it gets swapped out, so that we can reuse orig_rfh when the | 1141 // it gets swapped out, so that we can reuse orig_rfh when the |
| 1135 // controller goes back. | 1142 // controller goes back. |
| 1136 orig_rfh->GetSiteInstance()->increment_active_frame_count(); | 1143 orig_rfh->GetSiteInstance()->increment_active_frame_count(); |
| 1137 | 1144 |
| 1138 // Navigate to a second URL, simulate the beforeunload ack for the cross-site | 1145 // Navigate to a second URL, simulate the beforeunload ack for the cross-site |
| 1139 // transition, and set bindings on the pending RenderViewHost to simulate a | 1146 // transition, and set bindings on the pending RenderViewHost to simulate a |
| 1140 // privileged url. | 1147 // privileged url. |
| 1141 controller.LoadURL( | 1148 controller.LoadURL( |
| 1142 url2, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); | 1149 url2, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); |
| 1143 orig_rfh->PrepareForCommit(url2); | 1150 orig_rfh->PrepareForCommit(); |
| 1144 TestRenderFrameHost* new_rfh = contents()->GetPendingMainFrame(); | 1151 TestRenderFrameHost* new_rfh = contents()->GetPendingMainFrame(); |
| 1145 new_rfh->GetRenderViewHost()->AllowBindings(1); | 1152 new_rfh->GetRenderViewHost()->AllowBindings(1); |
| 1146 new_rfh->SendNavigate(1, url2); | 1153 new_rfh->SendNavigate(1, url2); |
| 1147 | 1154 |
| 1148 // The second load should be committed, and bindings should be remembered. | 1155 // The second load should be committed, and bindings should be remembered. |
| 1149 EXPECT_EQ(controller.GetEntryCount(), 2); | 1156 EXPECT_EQ(controller.GetEntryCount(), 2); |
| 1150 EXPECT_EQ(1, controller.GetLastCommittedEntryIndex()); | 1157 EXPECT_EQ(1, controller.GetLastCommittedEntryIndex()); |
| 1151 EXPECT_TRUE(controller.CanGoBack()); | 1158 EXPECT_TRUE(controller.CanGoBack()); |
| 1152 EXPECT_EQ(1, controller.GetLastCommittedEntry()->bindings()); | 1159 EXPECT_EQ(1, controller.GetLastCommittedEntry()->bindings()); |
| 1153 | 1160 |
| 1154 // Going back, the first entry should still appear unprivileged. | 1161 // Going back, the first entry should still appear unprivileged. |
| 1155 controller.GoBack(); | 1162 controller.GoBack(); |
| 1156 new_rfh->PrepareForCommit(url1); | 1163 new_rfh->PrepareForCommit(); |
| 1157 orig_rfh->SendNavigate(0, url1); | 1164 orig_rfh->SendNavigate(0, url1); |
| 1158 EXPECT_EQ(0, controller.GetLastCommittedEntryIndex()); | 1165 EXPECT_EQ(0, controller.GetLastCommittedEntryIndex()); |
| 1159 EXPECT_EQ(0, controller.GetLastCommittedEntry()->bindings()); | 1166 EXPECT_EQ(0, controller.GetLastCommittedEntry()->bindings()); |
| 1160 } | 1167 } |
| 1161 | 1168 |
| 1162 TEST_F(NavigationControllerTest, Reload) { | 1169 TEST_F(NavigationControllerTest, Reload) { |
| 1163 NavigationControllerImpl& controller = controller_impl(); | 1170 NavigationControllerImpl& controller = controller_impl(); |
| 1164 TestNotificationTracker notifications; | 1171 TestNotificationTracker notifications; |
| 1165 RegisterForAllNavNotifications(¬ifications, &controller); | 1172 RegisterForAllNavNotifications(¬ifications, &controller); |
| 1166 | 1173 |
| 1167 const GURL url1("http://foo1"); | 1174 const GURL url1("http://foo1"); |
| 1168 | 1175 |
| 1169 controller.LoadURL( | 1176 controller.LoadURL( |
| 1170 url1, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); | 1177 url1, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); |
| 1171 EXPECT_EQ(0U, notifications.size()); | 1178 EXPECT_EQ(0U, notifications.size()); |
| 1172 main_test_rfh()->PrepareForCommit(url1); | 1179 main_test_rfh()->PrepareForCommit(); |
| 1173 main_test_rfh()->SendNavigate(0, url1); | 1180 main_test_rfh()->SendNavigate(0, url1); |
| 1174 EXPECT_EQ(1U, navigation_entry_committed_counter_); | 1181 EXPECT_EQ(1U, navigation_entry_committed_counter_); |
| 1175 navigation_entry_committed_counter_ = 0; | 1182 navigation_entry_committed_counter_ = 0; |
| 1176 ASSERT_TRUE(controller.GetVisibleEntry()); | 1183 ASSERT_TRUE(controller.GetVisibleEntry()); |
| 1177 controller.GetVisibleEntry()->SetTitle(base::ASCIIToUTF16("Title")); | 1184 controller.GetVisibleEntry()->SetTitle(base::ASCIIToUTF16("Title")); |
| 1178 controller.Reload(true); | 1185 controller.Reload(true); |
| 1179 EXPECT_EQ(0U, notifications.size()); | 1186 EXPECT_EQ(0U, notifications.size()); |
| 1180 | 1187 |
| 1181 const base::Time timestamp = controller.GetVisibleEntry()->GetTimestamp(); | 1188 const base::Time timestamp = controller.GetVisibleEntry()->GetTimestamp(); |
| 1182 EXPECT_FALSE(timestamp.is_null()); | 1189 EXPECT_FALSE(timestamp.is_null()); |
| 1183 | 1190 |
| 1184 // The reload is pending. | 1191 // The reload is pending. |
| 1185 EXPECT_EQ(controller.GetEntryCount(), 1); | 1192 EXPECT_EQ(controller.GetEntryCount(), 1); |
| 1186 EXPECT_EQ(controller.GetLastCommittedEntryIndex(), 0); | 1193 EXPECT_EQ(controller.GetLastCommittedEntryIndex(), 0); |
| 1187 EXPECT_EQ(controller.GetPendingEntryIndex(), 0); | 1194 EXPECT_EQ(controller.GetPendingEntryIndex(), 0); |
| 1188 EXPECT_TRUE(controller.GetLastCommittedEntry()); | 1195 EXPECT_TRUE(controller.GetLastCommittedEntry()); |
| 1189 EXPECT_TRUE(controller.GetPendingEntry()); | 1196 EXPECT_TRUE(controller.GetPendingEntry()); |
| 1190 EXPECT_FALSE(controller.CanGoBack()); | 1197 EXPECT_FALSE(controller.CanGoBack()); |
| 1191 EXPECT_FALSE(controller.CanGoForward()); | 1198 EXPECT_FALSE(controller.CanGoForward()); |
| 1192 // Make sure the title has been cleared (will be redrawn just after reload). | 1199 // Make sure the title has been cleared (will be redrawn just after reload). |
| 1193 // Avoids a stale cached title when the new page being reloaded has no title. | 1200 // Avoids a stale cached title when the new page being reloaded has no title. |
| 1194 // See http://crbug.com/96041. | 1201 // See http://crbug.com/96041. |
| 1195 EXPECT_TRUE(controller.GetVisibleEntry()->GetTitle().empty()); | 1202 EXPECT_TRUE(controller.GetVisibleEntry()->GetTitle().empty()); |
| 1196 | 1203 |
| 1197 main_test_rfh()->PrepareForCommit(url1); | 1204 main_test_rfh()->PrepareForCommit(); |
| 1198 main_test_rfh()->SendNavigate(0, url1); | 1205 main_test_rfh()->SendNavigate(0, url1); |
| 1199 EXPECT_EQ(1U, navigation_entry_committed_counter_); | 1206 EXPECT_EQ(1U, navigation_entry_committed_counter_); |
| 1200 navigation_entry_committed_counter_ = 0; | 1207 navigation_entry_committed_counter_ = 0; |
| 1201 | 1208 |
| 1202 // Now the reload is committed. | 1209 // Now the reload is committed. |
| 1203 EXPECT_EQ(controller.GetEntryCount(), 1); | 1210 EXPECT_EQ(controller.GetEntryCount(), 1); |
| 1204 EXPECT_EQ(controller.GetLastCommittedEntryIndex(), 0); | 1211 EXPECT_EQ(controller.GetLastCommittedEntryIndex(), 0); |
| 1205 EXPECT_EQ(controller.GetPendingEntryIndex(), -1); | 1212 EXPECT_EQ(controller.GetPendingEntryIndex(), -1); |
| 1206 EXPECT_TRUE(controller.GetLastCommittedEntry()); | 1213 EXPECT_TRUE(controller.GetLastCommittedEntry()); |
| 1207 EXPECT_FALSE(controller.GetPendingEntry()); | 1214 EXPECT_FALSE(controller.GetPendingEntry()); |
| 1208 EXPECT_FALSE(controller.CanGoBack()); | 1215 EXPECT_FALSE(controller.CanGoBack()); |
| 1209 EXPECT_FALSE(controller.CanGoForward()); | 1216 EXPECT_FALSE(controller.CanGoForward()); |
| 1210 | 1217 |
| 1211 // The timestamp should have been updated. | 1218 // The timestamp should have been updated. |
| 1212 ASSERT_TRUE(controller.GetVisibleEntry()); | 1219 ASSERT_TRUE(controller.GetVisibleEntry()); |
| 1213 EXPECT_GE(controller.GetVisibleEntry()->GetTimestamp(), timestamp); | 1220 EXPECT_GE(controller.GetVisibleEntry()->GetTimestamp(), timestamp); |
| 1214 } | 1221 } |
| 1215 | 1222 |
| 1216 // Tests what happens when a reload navigation produces a new page. | 1223 // Tests what happens when a reload navigation produces a new page. |
| 1217 TEST_F(NavigationControllerTest, Reload_GeneratesNewPage) { | 1224 TEST_F(NavigationControllerTest, Reload_GeneratesNewPage) { |
| 1218 NavigationControllerImpl& controller = controller_impl(); | 1225 NavigationControllerImpl& controller = controller_impl(); |
| 1219 TestNotificationTracker notifications; | 1226 TestNotificationTracker notifications; |
| 1220 RegisterForAllNavNotifications(¬ifications, &controller); | 1227 RegisterForAllNavNotifications(¬ifications, &controller); |
| 1221 | 1228 |
| 1222 const GURL url1("http://foo1"); | 1229 const GURL url1("http://foo1"); |
| 1223 const GURL url2("http://foo2"); | 1230 const GURL url2("http://foo2"); |
| 1224 | 1231 |
| 1225 controller.LoadURL( | 1232 controller.LoadURL( |
| 1226 url1, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); | 1233 url1, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); |
| 1227 main_test_rfh()->PrepareForCommit(url1); | 1234 main_test_rfh()->PrepareForCommit(); |
| 1228 main_test_rfh()->SendNavigate(0, url1); | 1235 main_test_rfh()->SendNavigate(0, url1); |
| 1229 EXPECT_EQ(1U, navigation_entry_committed_counter_); | 1236 EXPECT_EQ(1U, navigation_entry_committed_counter_); |
| 1230 navigation_entry_committed_counter_ = 0; | 1237 navigation_entry_committed_counter_ = 0; |
| 1231 | 1238 |
| 1232 controller.Reload(true); | 1239 controller.Reload(true); |
| 1233 EXPECT_EQ(0U, notifications.size()); | 1240 EXPECT_EQ(0U, notifications.size()); |
| 1234 | 1241 |
| 1235 main_test_rfh()->PrepareForCommit(url2); | 1242 main_test_rfh()->PrepareForCommitWithServerRedirect(url2); |
| 1236 main_test_rfh()->SendNavigate(1, url2); | 1243 main_test_rfh()->SendNavigate(1, url2); |
| 1237 EXPECT_EQ(1U, navigation_entry_committed_counter_); | 1244 EXPECT_EQ(1U, navigation_entry_committed_counter_); |
| 1238 navigation_entry_committed_counter_ = 0; | 1245 navigation_entry_committed_counter_ = 0; |
| 1239 | 1246 |
| 1240 // Now the reload is committed. | 1247 // Now the reload is committed. |
| 1241 EXPECT_EQ(controller.GetEntryCount(), 2); | 1248 EXPECT_EQ(controller.GetEntryCount(), 2); |
| 1242 EXPECT_EQ(controller.GetLastCommittedEntryIndex(), 1); | 1249 EXPECT_EQ(controller.GetLastCommittedEntryIndex(), 1); |
| 1243 EXPECT_EQ(controller.GetPendingEntryIndex(), -1); | 1250 EXPECT_EQ(controller.GetPendingEntryIndex(), -1); |
| 1244 EXPECT_TRUE(controller.GetLastCommittedEntry()); | 1251 EXPECT_TRUE(controller.GetLastCommittedEntry()); |
| 1245 EXPECT_FALSE(controller.GetPendingEntry()); | 1252 EXPECT_FALSE(controller.GetPendingEntry()); |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1283 TestNotificationTracker notifications; | 1290 TestNotificationTracker notifications; |
| 1284 RegisterForAllNavNotifications(¬ifications, &controller); | 1291 RegisterForAllNavNotifications(¬ifications, &controller); |
| 1285 | 1292 |
| 1286 const GURL original_url("http://foo1"); | 1293 const GURL original_url("http://foo1"); |
| 1287 const GURL final_url("http://foo2"); | 1294 const GURL final_url("http://foo2"); |
| 1288 | 1295 |
| 1289 // Load up the original URL, but get redirected. | 1296 // Load up the original URL, but get redirected. |
| 1290 controller.LoadURL( | 1297 controller.LoadURL( |
| 1291 original_url, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); | 1298 original_url, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); |
| 1292 EXPECT_EQ(0U, notifications.size()); | 1299 EXPECT_EQ(0U, notifications.size()); |
| 1293 main_test_rfh()->PrepareForCommit(final_url); | 1300 main_test_rfh()->PrepareForCommitWithServerRedirect(final_url); |
| 1294 main_test_rfh()->SendNavigateWithOriginalRequestURL( | 1301 main_test_rfh()->SendNavigateWithOriginalRequestURL( |
| 1295 0, final_url, original_url); | 1302 0, final_url, original_url); |
| 1296 EXPECT_EQ(1U, navigation_entry_committed_counter_); | 1303 EXPECT_EQ(1U, navigation_entry_committed_counter_); |
| 1297 navigation_entry_committed_counter_ = 0; | 1304 navigation_entry_committed_counter_ = 0; |
| 1298 | 1305 |
| 1299 // The NavigationEntry should save both the original URL and the final | 1306 // The NavigationEntry should save both the original URL and the final |
| 1300 // redirected URL. | 1307 // redirected URL. |
| 1301 EXPECT_EQ( | 1308 EXPECT_EQ( |
| 1302 original_url, controller.GetVisibleEntry()->GetOriginalRequestURL()); | 1309 original_url, controller.GetVisibleEntry()->GetOriginalRequestURL()); |
| 1303 EXPECT_EQ(final_url, controller.GetVisibleEntry()->GetURL()); | 1310 EXPECT_EQ(final_url, controller.GetVisibleEntry()->GetURL()); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 1316 EXPECT_TRUE(controller.GetPendingEntry()); | 1323 EXPECT_TRUE(controller.GetPendingEntry()); |
| 1317 EXPECT_FALSE(controller.CanGoBack()); | 1324 EXPECT_FALSE(controller.CanGoBack()); |
| 1318 EXPECT_FALSE(controller.CanGoForward()); | 1325 EXPECT_FALSE(controller.CanGoForward()); |
| 1319 | 1326 |
| 1320 // Make sure the title has been cleared (will be redrawn just after reload). | 1327 // Make sure the title has been cleared (will be redrawn just after reload). |
| 1321 // Avoids a stale cached title when the new page being reloaded has no title. | 1328 // Avoids a stale cached title when the new page being reloaded has no title. |
| 1322 // See http://crbug.com/96041. | 1329 // See http://crbug.com/96041. |
| 1323 EXPECT_TRUE(controller.GetVisibleEntry()->GetTitle().empty()); | 1330 EXPECT_TRUE(controller.GetVisibleEntry()->GetTitle().empty()); |
| 1324 | 1331 |
| 1325 // Send that the navigation has proceeded; say it got redirected again. | 1332 // Send that the navigation has proceeded; say it got redirected again. |
| 1326 main_test_rfh()->PrepareForCommit(final_url); | 1333 main_test_rfh()->PrepareForCommitWithServerRedirect(final_url); |
| 1327 main_test_rfh()->SendNavigate(0, final_url); | 1334 main_test_rfh()->SendNavigate(0, final_url); |
| 1328 EXPECT_EQ(1U, navigation_entry_committed_counter_); | 1335 EXPECT_EQ(1U, navigation_entry_committed_counter_); |
| 1329 navigation_entry_committed_counter_ = 0; | 1336 navigation_entry_committed_counter_ = 0; |
| 1330 | 1337 |
| 1331 // Now the reload is committed. | 1338 // Now the reload is committed. |
| 1332 EXPECT_EQ(controller.GetEntryCount(), 1); | 1339 EXPECT_EQ(controller.GetEntryCount(), 1); |
| 1333 EXPECT_EQ(controller.GetLastCommittedEntryIndex(), 0); | 1340 EXPECT_EQ(controller.GetLastCommittedEntryIndex(), 0); |
| 1334 EXPECT_EQ(controller.GetPendingEntryIndex(), -1); | 1341 EXPECT_EQ(controller.GetPendingEntryIndex(), -1); |
| 1335 EXPECT_TRUE(controller.GetLastCommittedEntry()); | 1342 EXPECT_TRUE(controller.GetLastCommittedEntry()); |
| 1336 EXPECT_FALSE(controller.GetPendingEntry()); | 1343 EXPECT_FALSE(controller.GetPendingEntry()); |
| (...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1480 NavigationControllerImpl& controller = controller_impl(); | 1487 NavigationControllerImpl& controller = controller_impl(); |
| 1481 TestNotificationTracker notifications; | 1488 TestNotificationTracker notifications; |
| 1482 RegisterForAllNavNotifications(¬ifications, &controller); | 1489 RegisterForAllNavNotifications(¬ifications, &controller); |
| 1483 | 1490 |
| 1484 const GURL url1("http://foo/1"); | 1491 const GURL url1("http://foo/1"); |
| 1485 const GURL url2("http://foo/2"); | 1492 const GURL url2("http://foo/2"); |
| 1486 const GURL url3("http://foo/3"); | 1493 const GURL url3("http://foo/3"); |
| 1487 | 1494 |
| 1488 controller.LoadURL( | 1495 controller.LoadURL( |
| 1489 url1, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); | 1496 url1, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); |
| 1490 main_test_rfh()->PrepareForCommit(url1); | 1497 main_test_rfh()->PrepareForCommit(); |
| 1491 main_test_rfh()->SendNavigate(0, url1); | 1498 main_test_rfh()->SendNavigate(0, url1); |
| 1492 EXPECT_EQ(1U, navigation_entry_committed_counter_); | 1499 EXPECT_EQ(1U, navigation_entry_committed_counter_); |
| 1493 navigation_entry_committed_counter_ = 0; | 1500 navigation_entry_committed_counter_ = 0; |
| 1494 | 1501 |
| 1495 controller.LoadURL( | 1502 controller.LoadURL( |
| 1496 url2, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); | 1503 url2, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); |
| 1497 main_test_rfh()->PrepareForCommit(url2); | 1504 main_test_rfh()->PrepareForCommit(); |
| 1498 main_test_rfh()->SendNavigate(1, url2); | 1505 main_test_rfh()->SendNavigate(1, url2); |
| 1499 EXPECT_EQ(1U, navigation_entry_committed_counter_); | 1506 EXPECT_EQ(1U, navigation_entry_committed_counter_); |
| 1500 navigation_entry_committed_counter_ = 0; | 1507 navigation_entry_committed_counter_ = 0; |
| 1501 | 1508 |
| 1502 controller.GoBack(); | 1509 controller.GoBack(); |
| 1503 EXPECT_EQ(0U, notifications.size()); | 1510 EXPECT_EQ(0U, notifications.size()); |
| 1504 | 1511 |
| 1505 // We should now have a pending navigation to go back. | 1512 // We should now have a pending navigation to go back. |
| 1506 EXPECT_EQ(controller.GetEntryCount(), 2); | 1513 EXPECT_EQ(controller.GetEntryCount(), 2); |
| 1507 EXPECT_EQ(controller.GetLastCommittedEntryIndex(), 1); | 1514 EXPECT_EQ(controller.GetLastCommittedEntryIndex(), 1); |
| 1508 EXPECT_EQ(controller.GetPendingEntryIndex(), 0); | 1515 EXPECT_EQ(controller.GetPendingEntryIndex(), 0); |
| 1509 EXPECT_TRUE(controller.GetLastCommittedEntry()); | 1516 EXPECT_TRUE(controller.GetLastCommittedEntry()); |
| 1510 EXPECT_TRUE(controller.GetPendingEntry()); | 1517 EXPECT_TRUE(controller.GetPendingEntry()); |
| 1511 EXPECT_FALSE(controller.CanGoBack()); | 1518 EXPECT_FALSE(controller.CanGoBack()); |
| 1512 EXPECT_TRUE(controller.CanGoForward()); | 1519 EXPECT_TRUE(controller.CanGoForward()); |
| 1513 | 1520 |
| 1514 main_test_rfh()->PrepareForCommit(url3); | 1521 main_test_rfh()->PrepareForCommitWithServerRedirect(url3); |
| 1515 main_test_rfh()->SendNavigate(2, url3); | 1522 main_test_rfh()->SendNavigate(2, url3); |
| 1516 EXPECT_EQ(1U, navigation_entry_committed_counter_); | 1523 EXPECT_EQ(1U, navigation_entry_committed_counter_); |
| 1517 navigation_entry_committed_counter_ = 0; | 1524 navigation_entry_committed_counter_ = 0; |
| 1518 | 1525 |
| 1519 // The back navigation resulted in a completely new navigation. | 1526 // The back navigation resulted in a completely new navigation. |
| 1520 // TODO(darin): perhaps this behavior will be confusing to users? | 1527 // TODO(darin): perhaps this behavior will be confusing to users? |
| 1521 EXPECT_EQ(controller.GetEntryCount(), 3); | 1528 EXPECT_EQ(controller.GetEntryCount(), 3); |
| 1522 EXPECT_EQ(controller.GetLastCommittedEntryIndex(), 2); | 1529 EXPECT_EQ(controller.GetLastCommittedEntryIndex(), 2); |
| 1523 EXPECT_EQ(controller.GetPendingEntryIndex(), -1); | 1530 EXPECT_EQ(controller.GetPendingEntryIndex(), -1); |
| 1524 EXPECT_TRUE(controller.GetLastCommittedEntry()); | 1531 EXPECT_TRUE(controller.GetLastCommittedEntry()); |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1562 | 1569 |
| 1563 // Receives a back message when there is a different renavigation already | 1570 // Receives a back message when there is a different renavigation already |
| 1564 // pending. | 1571 // pending. |
| 1565 TEST_F(NavigationControllerTest, Back_OtherBackPending) { | 1572 TEST_F(NavigationControllerTest, Back_OtherBackPending) { |
| 1566 NavigationControllerImpl& controller = controller_impl(); | 1573 NavigationControllerImpl& controller = controller_impl(); |
| 1567 const GURL kUrl1("http://foo/1"); | 1574 const GURL kUrl1("http://foo/1"); |
| 1568 const GURL kUrl2("http://foo/2"); | 1575 const GURL kUrl2("http://foo/2"); |
| 1569 const GURL kUrl3("http://foo/3"); | 1576 const GURL kUrl3("http://foo/3"); |
| 1570 | 1577 |
| 1571 // First navigate three places so we have some back history. | 1578 // First navigate three places so we have some back history. |
| 1572 main_test_rfh()->PrepareForCommit(kUrl1); | 1579 main_test_rfh()->SendBeginNavigationWithURL(kUrl1, true); |
| 1580 main_test_rfh()->PrepareForCommit(); |
| 1573 main_test_rfh()->SendNavigate(0, kUrl1); | 1581 main_test_rfh()->SendNavigate(0, kUrl1); |
| 1574 main_test_rfh()->PrepareForCommit(kUrl2); | 1582 main_test_rfh()->SendBeginNavigationWithURL(kUrl2, true); |
| 1583 main_test_rfh()->PrepareForCommit(); |
| 1575 main_test_rfh()->SendNavigate(1, kUrl2); | 1584 main_test_rfh()->SendNavigate(1, kUrl2); |
| 1576 main_test_rfh()->PrepareForCommit(kUrl3); | 1585 main_test_rfh()->SendBeginNavigationWithURL(kUrl3, true); |
| 1586 main_test_rfh()->PrepareForCommit(); |
| 1577 main_test_rfh()->SendNavigate(2, kUrl3); | 1587 main_test_rfh()->SendNavigate(2, kUrl3); |
| 1578 | 1588 |
| 1579 // With nothing pending, say we get a navigation to the second entry. | 1589 // With nothing pending, say we get a navigation to the second entry. |
| 1580 main_test_rfh()->PrepareForCommit(kUrl2); | 1590 main_test_rfh()->SendBeginNavigationWithURL(kUrl2, true); |
| 1591 main_test_rfh()->PrepareForCommit(); |
| 1581 main_test_rfh()->SendNavigate(1, kUrl2); | 1592 main_test_rfh()->SendNavigate(1, kUrl2); |
| 1582 | 1593 |
| 1583 // We know all the entries have the same site instance, so we can just grab | 1594 // We know all the entries have the same site instance, so we can just grab |
| 1584 // a random one for looking up other entries. | 1595 // a random one for looking up other entries. |
| 1585 SiteInstance* site_instance = | 1596 SiteInstance* site_instance = |
| 1586 controller.GetLastCommittedEntry()->site_instance(); | 1597 controller.GetLastCommittedEntry()->site_instance(); |
| 1587 | 1598 |
| 1588 // That second URL should be the last committed and it should have gotten the | 1599 // That second URL should be the last committed and it should have gotten the |
| 1589 // new title. | 1600 // new title. |
| 1590 EXPECT_EQ(kUrl2, controller.GetEntryWithPageID(site_instance, 1)->GetURL()); | 1601 EXPECT_EQ(kUrl2, controller.GetEntryWithPageID(site_instance, 1)->GetURL()); |
| 1591 EXPECT_EQ(1, controller.GetLastCommittedEntryIndex()); | 1602 EXPECT_EQ(1, controller.GetLastCommittedEntryIndex()); |
| 1592 EXPECT_EQ(-1, controller.GetPendingEntryIndex()); | 1603 EXPECT_EQ(-1, controller.GetPendingEntryIndex()); |
| 1593 | 1604 |
| 1594 // Now go forward to the last item again and say it was committed. | 1605 // Now go forward to the last item again and say it was committed. |
| 1595 controller.GoForward(); | 1606 controller.GoForward(); |
| 1596 main_test_rfh()->PrepareForCommit(kUrl3); | 1607 main_test_rfh()->PrepareForCommit(); |
| 1597 main_test_rfh()->SendNavigate(2, kUrl3); | 1608 main_test_rfh()->SendNavigate(2, kUrl3); |
| 1598 | 1609 |
| 1599 // Now start going back one to the second page. It will be pending. | 1610 // Now start going back one to the second page. It will be pending. |
| 1600 controller.GoBack(); | 1611 controller.GoBack(); |
| 1601 EXPECT_EQ(1, controller.GetPendingEntryIndex()); | 1612 EXPECT_EQ(1, controller.GetPendingEntryIndex()); |
| 1602 EXPECT_EQ(2, controller.GetLastCommittedEntryIndex()); | 1613 EXPECT_EQ(2, controller.GetLastCommittedEntryIndex()); |
| 1603 | 1614 |
| 1604 // Not synthesize a totally new back event to the first page. This will not | 1615 // Now synthesize a totally new back event to the first page. This will not |
| 1605 // match the pending one. | 1616 // match the pending one. |
| 1606 main_test_rfh()->PrepareForCommit(kUrl1); | 1617 main_test_rfh()->SendBeginNavigationWithURL(kUrl1, true); |
| 1618 main_test_rfh()->PrepareForCommit(); |
| 1607 main_test_rfh()->SendNavigate(0, kUrl1); | 1619 main_test_rfh()->SendNavigate(0, kUrl1); |
| 1608 | 1620 |
| 1609 // The committed navigation should clear the pending entry. | 1621 // The committed navigation should clear the pending entry. |
| 1610 EXPECT_EQ(-1, controller.GetPendingEntryIndex()); | 1622 EXPECT_EQ(-1, controller.GetPendingEntryIndex()); |
| 1611 | 1623 |
| 1612 // But the navigated entry should be the last committed. | 1624 // But the navigated entry should be the last committed. |
| 1613 EXPECT_EQ(0, controller.GetLastCommittedEntryIndex()); | 1625 EXPECT_EQ(0, controller.GetLastCommittedEntryIndex()); |
| 1614 EXPECT_EQ(kUrl1, controller.GetLastCommittedEntry()->GetURL()); | 1626 EXPECT_EQ(kUrl1, controller.GetLastCommittedEntry()->GetURL()); |
| 1615 } | 1627 } |
| 1616 | 1628 |
| 1617 // Tests what happens when we navigate forward successfully. | 1629 // Tests what happens when we navigate forward successfully. |
| 1618 TEST_F(NavigationControllerTest, Forward) { | 1630 TEST_F(NavigationControllerTest, Forward) { |
| 1619 NavigationControllerImpl& controller = controller_impl(); | 1631 NavigationControllerImpl& controller = controller_impl(); |
| 1620 TestNotificationTracker notifications; | 1632 TestNotificationTracker notifications; |
| 1621 RegisterForAllNavNotifications(¬ifications, &controller); | 1633 RegisterForAllNavNotifications(¬ifications, &controller); |
| 1622 | 1634 |
| 1623 const GURL url1("http://foo1"); | 1635 const GURL url1("http://foo1"); |
| 1624 const GURL url2("http://foo2"); | 1636 const GURL url2("http://foo2"); |
| 1625 | 1637 |
| 1626 main_test_rfh()->PrepareForCommit(url1); | 1638 main_test_rfh()->PrepareForCommit(); |
| 1627 main_test_rfh()->SendNavigate(0, url1); | 1639 main_test_rfh()->SendNavigate(0, url1); |
| 1628 EXPECT_EQ(1U, navigation_entry_committed_counter_); | 1640 EXPECT_EQ(1U, navigation_entry_committed_counter_); |
| 1629 navigation_entry_committed_counter_ = 0; | 1641 navigation_entry_committed_counter_ = 0; |
| 1630 | 1642 |
| 1631 main_test_rfh()->PrepareForCommit(url2); | 1643 main_test_rfh()->PrepareForCommit(); |
| 1632 main_test_rfh()->SendNavigate(1, url2); | 1644 main_test_rfh()->SendNavigate(1, url2); |
| 1633 EXPECT_EQ(1U, navigation_entry_committed_counter_); | 1645 EXPECT_EQ(1U, navigation_entry_committed_counter_); |
| 1634 navigation_entry_committed_counter_ = 0; | 1646 navigation_entry_committed_counter_ = 0; |
| 1635 | 1647 |
| 1636 controller.GoBack(); | 1648 controller.GoBack(); |
| 1637 main_test_rfh()->PrepareForCommit(url1); | 1649 main_test_rfh()->PrepareForCommit(); |
| 1638 main_test_rfh()->SendNavigate(0, url1); | 1650 main_test_rfh()->SendNavigate(0, url1); |
| 1639 EXPECT_EQ(1U, navigation_entry_committed_counter_); | 1651 EXPECT_EQ(1U, navigation_entry_committed_counter_); |
| 1640 navigation_entry_committed_counter_ = 0; | 1652 navigation_entry_committed_counter_ = 0; |
| 1641 | 1653 |
| 1642 controller.GoForward(); | 1654 controller.GoForward(); |
| 1643 | 1655 |
| 1644 // We should now have a pending navigation to go forward. | 1656 // We should now have a pending navigation to go forward. |
| 1645 EXPECT_EQ(controller.GetEntryCount(), 2); | 1657 EXPECT_EQ(controller.GetEntryCount(), 2); |
| 1646 EXPECT_EQ(controller.GetLastCommittedEntryIndex(), 0); | 1658 EXPECT_EQ(controller.GetLastCommittedEntryIndex(), 0); |
| 1647 EXPECT_EQ(controller.GetPendingEntryIndex(), 1); | 1659 EXPECT_EQ(controller.GetPendingEntryIndex(), 1); |
| 1648 EXPECT_TRUE(controller.GetLastCommittedEntry()); | 1660 EXPECT_TRUE(controller.GetLastCommittedEntry()); |
| 1649 EXPECT_TRUE(controller.GetPendingEntry()); | 1661 EXPECT_TRUE(controller.GetPendingEntry()); |
| 1650 EXPECT_TRUE(controller.CanGoBack()); | 1662 EXPECT_TRUE(controller.CanGoBack()); |
| 1651 EXPECT_TRUE(controller.CanGoToOffset(-1)); | 1663 EXPECT_TRUE(controller.CanGoToOffset(-1)); |
| 1652 EXPECT_FALSE(controller.CanGoToOffset(-2)); // Cannot go back 2 steps. | 1664 EXPECT_FALSE(controller.CanGoToOffset(-2)); // Cannot go back 2 steps. |
| 1653 EXPECT_FALSE(controller.CanGoForward()); | 1665 EXPECT_FALSE(controller.CanGoForward()); |
| 1654 EXPECT_FALSE(controller.CanGoToOffset(1)); | 1666 EXPECT_FALSE(controller.CanGoToOffset(1)); |
| 1655 | 1667 |
| 1656 // Timestamp for entry 0 should be on or after that of entry 1 | 1668 // Timestamp for entry 0 should be on or after that of entry 1 |
| 1657 // (since we went back to it). | 1669 // (since we went back to it). |
| 1658 EXPECT_FALSE(controller.GetEntryAtIndex(0)->GetTimestamp().is_null()); | 1670 EXPECT_FALSE(controller.GetEntryAtIndex(0)->GetTimestamp().is_null()); |
| 1659 EXPECT_GE(controller.GetEntryAtIndex(0)->GetTimestamp(), | 1671 EXPECT_GE(controller.GetEntryAtIndex(0)->GetTimestamp(), |
| 1660 controller.GetEntryAtIndex(1)->GetTimestamp()); | 1672 controller.GetEntryAtIndex(1)->GetTimestamp()); |
| 1661 | 1673 |
| 1662 main_test_rfh()->PrepareForCommit(url2); | 1674 main_test_rfh()->PrepareForCommit(); |
| 1663 main_test_rfh()->SendNavigate(1, url2); | 1675 main_test_rfh()->SendNavigate(1, url2); |
| 1664 EXPECT_EQ(1U, navigation_entry_committed_counter_); | 1676 EXPECT_EQ(1U, navigation_entry_committed_counter_); |
| 1665 navigation_entry_committed_counter_ = 0; | 1677 navigation_entry_committed_counter_ = 0; |
| 1666 | 1678 |
| 1667 // The forward navigation completed successfully. | 1679 // The forward navigation completed successfully. |
| 1668 EXPECT_EQ(controller.GetEntryCount(), 2); | 1680 EXPECT_EQ(controller.GetEntryCount(), 2); |
| 1669 EXPECT_EQ(controller.GetLastCommittedEntryIndex(), 1); | 1681 EXPECT_EQ(controller.GetLastCommittedEntryIndex(), 1); |
| 1670 EXPECT_EQ(controller.GetPendingEntryIndex(), -1); | 1682 EXPECT_EQ(controller.GetPendingEntryIndex(), -1); |
| 1671 EXPECT_TRUE(controller.GetLastCommittedEntry()); | 1683 EXPECT_TRUE(controller.GetLastCommittedEntry()); |
| 1672 EXPECT_FALSE(controller.GetPendingEntry()); | 1684 EXPECT_FALSE(controller.GetPendingEntry()); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 1685 // Tests what happens when a forward navigation produces a new page. | 1697 // Tests what happens when a forward navigation produces a new page. |
| 1686 TEST_F(NavigationControllerTest, Forward_GeneratesNewPage) { | 1698 TEST_F(NavigationControllerTest, Forward_GeneratesNewPage) { |
| 1687 NavigationControllerImpl& controller = controller_impl(); | 1699 NavigationControllerImpl& controller = controller_impl(); |
| 1688 TestNotificationTracker notifications; | 1700 TestNotificationTracker notifications; |
| 1689 RegisterForAllNavNotifications(¬ifications, &controller); | 1701 RegisterForAllNavNotifications(¬ifications, &controller); |
| 1690 | 1702 |
| 1691 const GURL url1("http://foo1"); | 1703 const GURL url1("http://foo1"); |
| 1692 const GURL url2("http://foo2"); | 1704 const GURL url2("http://foo2"); |
| 1693 const GURL url3("http://foo3"); | 1705 const GURL url3("http://foo3"); |
| 1694 | 1706 |
| 1695 main_test_rfh()->PrepareForCommit(url1); | 1707 main_test_rfh()->PrepareForCommit(); |
| 1696 main_test_rfh()->SendNavigate(0, url1); | 1708 main_test_rfh()->SendNavigate(0, url1); |
| 1697 EXPECT_EQ(1U, navigation_entry_committed_counter_); | 1709 EXPECT_EQ(1U, navigation_entry_committed_counter_); |
| 1698 navigation_entry_committed_counter_ = 0; | 1710 navigation_entry_committed_counter_ = 0; |
| 1699 main_test_rfh()->PrepareForCommit(url2); | 1711 main_test_rfh()->PrepareForCommit(); |
| 1700 main_test_rfh()->SendNavigate(1, url2); | 1712 main_test_rfh()->SendNavigate(1, url2); |
| 1701 EXPECT_EQ(1U, navigation_entry_committed_counter_); | 1713 EXPECT_EQ(1U, navigation_entry_committed_counter_); |
| 1702 navigation_entry_committed_counter_ = 0; | 1714 navigation_entry_committed_counter_ = 0; |
| 1703 | 1715 |
| 1704 controller.GoBack(); | 1716 controller.GoBack(); |
| 1705 main_test_rfh()->PrepareForCommit(url1); | 1717 main_test_rfh()->PrepareForCommit(); |
| 1706 main_test_rfh()->SendNavigate(0, url1); | 1718 main_test_rfh()->SendNavigate(0, url1); |
| 1707 EXPECT_EQ(1U, navigation_entry_committed_counter_); | 1719 EXPECT_EQ(1U, navigation_entry_committed_counter_); |
| 1708 navigation_entry_committed_counter_ = 0; | 1720 navigation_entry_committed_counter_ = 0; |
| 1709 | 1721 |
| 1710 controller.GoForward(); | 1722 controller.GoForward(); |
| 1711 EXPECT_EQ(0U, notifications.size()); | 1723 EXPECT_EQ(0U, notifications.size()); |
| 1712 | 1724 |
| 1713 // Should now have a pending navigation to go forward. | 1725 // Should now have a pending navigation to go forward. |
| 1714 EXPECT_EQ(controller.GetEntryCount(), 2); | 1726 EXPECT_EQ(controller.GetEntryCount(), 2); |
| 1715 EXPECT_EQ(controller.GetLastCommittedEntryIndex(), 0); | 1727 EXPECT_EQ(controller.GetLastCommittedEntryIndex(), 0); |
| 1716 EXPECT_EQ(controller.GetPendingEntryIndex(), 1); | 1728 EXPECT_EQ(controller.GetPendingEntryIndex(), 1); |
| 1717 EXPECT_TRUE(controller.GetLastCommittedEntry()); | 1729 EXPECT_TRUE(controller.GetLastCommittedEntry()); |
| 1718 EXPECT_TRUE(controller.GetPendingEntry()); | 1730 EXPECT_TRUE(controller.GetPendingEntry()); |
| 1719 EXPECT_TRUE(controller.CanGoBack()); | 1731 EXPECT_TRUE(controller.CanGoBack()); |
| 1720 EXPECT_FALSE(controller.CanGoForward()); | 1732 EXPECT_FALSE(controller.CanGoForward()); |
| 1721 | 1733 |
| 1722 main_test_rfh()->PrepareForCommit(url3); | 1734 main_test_rfh()->PrepareForCommit(); |
| 1723 main_test_rfh()->SendNavigate(2, url3); | 1735 main_test_rfh()->SendNavigate(2, url3); |
| 1724 EXPECT_EQ(1U, navigation_entry_committed_counter_); | 1736 EXPECT_EQ(1U, navigation_entry_committed_counter_); |
| 1725 navigation_entry_committed_counter_ = 0; | 1737 navigation_entry_committed_counter_ = 0; |
| 1726 EXPECT_TRUE(notifications.Check1AndReset(NOTIFICATION_NAV_LIST_PRUNED)); | 1738 EXPECT_TRUE(notifications.Check1AndReset(NOTIFICATION_NAV_LIST_PRUNED)); |
| 1727 | 1739 |
| 1728 EXPECT_EQ(controller.GetEntryCount(), 2); | 1740 EXPECT_EQ(controller.GetEntryCount(), 2); |
| 1729 EXPECT_EQ(controller.GetLastCommittedEntryIndex(), 1); | 1741 EXPECT_EQ(controller.GetLastCommittedEntryIndex(), 1); |
| 1730 EXPECT_EQ(controller.GetPendingEntryIndex(), -1); | 1742 EXPECT_EQ(controller.GetPendingEntryIndex(), -1); |
| 1731 EXPECT_TRUE(controller.GetLastCommittedEntry()); | 1743 EXPECT_TRUE(controller.GetLastCommittedEntry()); |
| 1732 EXPECT_FALSE(controller.GetPendingEntry()); | 1744 EXPECT_FALSE(controller.GetPendingEntry()); |
| (...skipping 644 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2377 const int kMaxEntryCount = 5; | 2389 const int kMaxEntryCount = 5; |
| 2378 | 2390 |
| 2379 NavigationControllerImpl::set_max_entry_count_for_testing(kMaxEntryCount); | 2391 NavigationControllerImpl::set_max_entry_count_for_testing(kMaxEntryCount); |
| 2380 | 2392 |
| 2381 int url_index; | 2393 int url_index; |
| 2382 // Load up to the max count, all entries should be there. | 2394 // Load up to the max count, all entries should be there. |
| 2383 for (url_index = 0; url_index < kMaxEntryCount; url_index++) { | 2395 for (url_index = 0; url_index < kMaxEntryCount; url_index++) { |
| 2384 GURL url(base::StringPrintf("http://www.a.com/%d", url_index)); | 2396 GURL url(base::StringPrintf("http://www.a.com/%d", url_index)); |
| 2385 controller.LoadURL( | 2397 controller.LoadURL( |
| 2386 url, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); | 2398 url, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); |
| 2387 main_test_rfh()->PrepareForCommit(url); | 2399 main_test_rfh()->PrepareForCommit(); |
| 2388 main_test_rfh()->SendNavigate(url_index, url); | 2400 main_test_rfh()->SendNavigate(url_index, url); |
| 2389 } | 2401 } |
| 2390 | 2402 |
| 2391 EXPECT_EQ(controller.GetEntryCount(), kMaxEntryCount); | 2403 EXPECT_EQ(controller.GetEntryCount(), kMaxEntryCount); |
| 2392 | 2404 |
| 2393 // Created a PrunedListener to observe prune notifications. | 2405 // Created a PrunedListener to observe prune notifications. |
| 2394 PrunedListener listener(&controller); | 2406 PrunedListener listener(&controller); |
| 2395 | 2407 |
| 2396 // Navigate some more. | 2408 // Navigate some more. |
| 2397 GURL url(base::StringPrintf("http://www.a.com/%d", url_index)); | 2409 GURL url(base::StringPrintf("http://www.a.com/%d", url_index)); |
| 2398 controller.LoadURL( | 2410 controller.LoadURL( |
| 2399 url, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); | 2411 url, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); |
| 2400 main_test_rfh()->PrepareForCommit(url); | 2412 main_test_rfh()->PrepareForCommit(); |
| 2401 main_test_rfh()->SendNavigate(url_index, url); | 2413 main_test_rfh()->SendNavigate(url_index, url); |
| 2402 url_index++; | 2414 url_index++; |
| 2403 | 2415 |
| 2404 // We should have got a pruned navigation. | 2416 // We should have got a pruned navigation. |
| 2405 EXPECT_EQ(1, listener.notification_count_); | 2417 EXPECT_EQ(1, listener.notification_count_); |
| 2406 EXPECT_TRUE(listener.details_.from_front); | 2418 EXPECT_TRUE(listener.details_.from_front); |
| 2407 EXPECT_EQ(1, listener.details_.count); | 2419 EXPECT_EQ(1, listener.details_.count); |
| 2408 | 2420 |
| 2409 // We expect http://www.a.com/0 to be gone. | 2421 // We expect http://www.a.com/0 to be gone. |
| 2410 EXPECT_EQ(controller.GetEntryCount(), kMaxEntryCount); | 2422 EXPECT_EQ(controller.GetEntryCount(), kMaxEntryCount); |
| 2411 EXPECT_EQ(controller.GetEntryAtIndex(0)->GetURL(), | 2423 EXPECT_EQ(controller.GetEntryAtIndex(0)->GetURL(), |
| 2412 GURL("http:////www.a.com/1")); | 2424 GURL("http:////www.a.com/1")); |
| 2413 | 2425 |
| 2414 // More navigations. | 2426 // More navigations. |
| 2415 for (int i = 0; i < 3; i++) { | 2427 for (int i = 0; i < 3; i++) { |
| 2416 url = GURL(base::StringPrintf("http:////www.a.com/%d", url_index)); | 2428 url = GURL(base::StringPrintf("http:////www.a.com/%d", url_index)); |
| 2417 controller.LoadURL( | 2429 controller.LoadURL( |
| 2418 url, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); | 2430 url, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); |
| 2419 main_test_rfh()->PrepareForCommit(url); | 2431 main_test_rfh()->PrepareForCommit(); |
| 2420 main_test_rfh()->SendNavigate(url_index, url); | 2432 main_test_rfh()->SendNavigate(url_index, url); |
| 2421 url_index++; | 2433 url_index++; |
| 2422 } | 2434 } |
| 2423 EXPECT_EQ(controller.GetEntryCount(), kMaxEntryCount); | 2435 EXPECT_EQ(controller.GetEntryCount(), kMaxEntryCount); |
| 2424 EXPECT_EQ(controller.GetEntryAtIndex(0)->GetURL(), | 2436 EXPECT_EQ(controller.GetEntryAtIndex(0)->GetURL(), |
| 2425 GURL("http:////www.a.com/4")); | 2437 GURL("http:////www.a.com/4")); |
| 2426 | 2438 |
| 2427 NavigationControllerImpl::set_max_entry_count_for_testing(original_count); | 2439 NavigationControllerImpl::set_max_entry_count_for_testing(original_count); |
| 2428 } | 2440 } |
| 2429 | 2441 |
| (...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2574 our_controller.GetEntryAtIndex(0)->restore_type()); | 2586 our_controller.GetEntryAtIndex(0)->restore_type()); |
| 2575 } | 2587 } |
| 2576 | 2588 |
| 2577 // Make sure that the page type and stuff is correct after an interstitial. | 2589 // Make sure that the page type and stuff is correct after an interstitial. |
| 2578 TEST_F(NavigationControllerTest, Interstitial) { | 2590 TEST_F(NavigationControllerTest, Interstitial) { |
| 2579 NavigationControllerImpl& controller = controller_impl(); | 2591 NavigationControllerImpl& controller = controller_impl(); |
| 2580 // First navigate somewhere normal. | 2592 // First navigate somewhere normal. |
| 2581 const GURL url1("http://foo"); | 2593 const GURL url1("http://foo"); |
| 2582 controller.LoadURL( | 2594 controller.LoadURL( |
| 2583 url1, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); | 2595 url1, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); |
| 2584 main_test_rfh()->PrepareForCommit(url1); | 2596 main_test_rfh()->PrepareForCommit(); |
| 2585 main_test_rfh()->SendNavigate(0, url1); | 2597 main_test_rfh()->SendNavigate(0, url1); |
| 2586 | 2598 |
| 2587 // Now navigate somewhere with an interstitial. | 2599 // Now navigate somewhere with an interstitial. |
| 2588 const GURL url2("http://bar"); | 2600 const GURL url2("http://bar"); |
| 2589 controller.LoadURL( | 2601 controller.LoadURL(url2, Referrer(), ui::PAGE_TRANSITION_TYPED, |
| 2590 url1, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); | 2602 std::string()); |
| 2591 controller.GetPendingEntry()->set_page_type(PAGE_TYPE_INTERSTITIAL); | 2603 controller.GetPendingEntry()->set_page_type(PAGE_TYPE_INTERSTITIAL); |
| 2592 | 2604 |
| 2593 // At this point the interstitial will be displayed and the load will still | 2605 // At this point the interstitial will be displayed and the load will still |
| 2594 // be pending. If the user continues, the load will commit. | 2606 // be pending. If the user continues, the load will commit. |
| 2595 main_test_rfh()->PrepareForCommit(url2); | 2607 main_test_rfh()->PrepareForCommit(); |
| 2596 main_test_rfh()->SendNavigate(1, url2); | 2608 main_test_rfh()->SendNavigate(1, url2); |
| 2597 | 2609 |
| 2598 // The page should be a normal page again. | 2610 // The page should be a normal page again. |
| 2599 EXPECT_EQ(url2, controller.GetLastCommittedEntry()->GetURL()); | 2611 EXPECT_EQ(url2, controller.GetLastCommittedEntry()->GetURL()); |
| 2600 EXPECT_EQ(PAGE_TYPE_NORMAL, | 2612 EXPECT_EQ(PAGE_TYPE_NORMAL, |
| 2601 controller.GetLastCommittedEntry()->GetPageType()); | 2613 controller.GetLastCommittedEntry()->GetPageType()); |
| 2602 } | 2614 } |
| 2603 | 2615 |
| 2604 TEST_F(NavigationControllerTest, RemoveEntry) { | 2616 TEST_F(NavigationControllerTest, RemoveEntry) { |
| 2605 NavigationControllerImpl& controller = controller_impl(); | 2617 NavigationControllerImpl& controller = controller_impl(); |
| 2606 const GURL url1("http://foo/1"); | 2618 const GURL url1("http://foo/1"); |
| 2607 const GURL url2("http://foo/2"); | 2619 const GURL url2("http://foo/2"); |
| 2608 const GURL url3("http://foo/3"); | 2620 const GURL url3("http://foo/3"); |
| 2609 const GURL url4("http://foo/4"); | 2621 const GURL url4("http://foo/4"); |
| 2610 const GURL url5("http://foo/5"); | 2622 const GURL url5("http://foo/5"); |
| 2611 const GURL pending_url("http://foo/pending"); | 2623 const GURL pending_url("http://foo/pending"); |
| 2612 const GURL default_url("http://foo/default"); | 2624 const GURL default_url("http://foo/default"); |
| 2613 | 2625 |
| 2614 controller.LoadURL( | 2626 controller.LoadURL( |
| 2615 url1, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); | 2627 url1, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); |
| 2616 main_test_rfh()->PrepareForCommit(url1); | 2628 main_test_rfh()->PrepareForCommit(); |
| 2617 main_test_rfh()->SendNavigate(0, url1); | 2629 main_test_rfh()->SendNavigate(0, url1); |
| 2618 controller.LoadURL( | 2630 controller.LoadURL( |
| 2619 url2, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); | 2631 url2, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); |
| 2620 main_test_rfh()->PrepareForCommit(url2); | 2632 main_test_rfh()->PrepareForCommit(); |
| 2621 main_test_rfh()->SendNavigate(1, url2); | 2633 main_test_rfh()->SendNavigate(1, url2); |
| 2622 controller.LoadURL( | 2634 controller.LoadURL( |
| 2623 url3, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); | 2635 url3, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); |
| 2624 main_test_rfh()->PrepareForCommit(url3); | 2636 main_test_rfh()->PrepareForCommit(); |
| 2625 main_test_rfh()->SendNavigate(2, url3); | 2637 main_test_rfh()->SendNavigate(2, url3); |
| 2626 controller.LoadURL( | 2638 controller.LoadURL( |
| 2627 url4, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); | 2639 url4, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); |
| 2628 main_test_rfh()->PrepareForCommit(url4); | 2640 main_test_rfh()->PrepareForCommit(); |
| 2629 main_test_rfh()->SendNavigate(3, url4); | 2641 main_test_rfh()->SendNavigate(3, url4); |
| 2630 controller.LoadURL( | 2642 controller.LoadURL( |
| 2631 url5, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); | 2643 url5, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); |
| 2632 main_test_rfh()->PrepareForCommit(url5); | 2644 main_test_rfh()->PrepareForCommit(); |
| 2633 main_test_rfh()->SendNavigate(4, url5); | 2645 main_test_rfh()->SendNavigate(4, url5); |
| 2634 | 2646 |
| 2635 // Try to remove the last entry. Will fail because it is the current entry. | 2647 // Try to remove the last entry. Will fail because it is the current entry. |
| 2636 EXPECT_FALSE(controller.RemoveEntryAtIndex(controller.GetEntryCount() - 1)); | 2648 EXPECT_FALSE(controller.RemoveEntryAtIndex(controller.GetEntryCount() - 1)); |
| 2637 EXPECT_EQ(5, controller.GetEntryCount()); | 2649 EXPECT_EQ(5, controller.GetEntryCount()); |
| 2638 EXPECT_EQ(4, controller.GetLastCommittedEntryIndex()); | 2650 EXPECT_EQ(4, controller.GetLastCommittedEntryIndex()); |
| 2639 | 2651 |
| 2640 // Go back, but don't commit yet. Check that we can't delete the current | 2652 // Go back, but don't commit yet. Check that we can't delete the current |
| 2641 // and pending entries. | 2653 // and pending entries. |
| 2642 controller.GoBack(); | 2654 controller.GoBack(); |
| 2643 EXPECT_FALSE(controller.RemoveEntryAtIndex(controller.GetEntryCount() - 1)); | 2655 EXPECT_FALSE(controller.RemoveEntryAtIndex(controller.GetEntryCount() - 1)); |
| 2644 EXPECT_FALSE(controller.RemoveEntryAtIndex(controller.GetEntryCount() - 2)); | 2656 EXPECT_FALSE(controller.RemoveEntryAtIndex(controller.GetEntryCount() - 2)); |
| 2645 | 2657 |
| 2646 // Now commit and delete the last entry. | 2658 // Now commit and delete the last entry. |
| 2647 main_test_rfh()->PrepareForCommit(url4); | 2659 main_test_rfh()->PrepareForCommit(); |
| 2648 main_test_rfh()->SendNavigate(3, url4); | 2660 main_test_rfh()->SendNavigate(3, url4); |
| 2649 EXPECT_TRUE(controller.RemoveEntryAtIndex(controller.GetEntryCount() - 1)); | 2661 EXPECT_TRUE(controller.RemoveEntryAtIndex(controller.GetEntryCount() - 1)); |
| 2650 EXPECT_EQ(4, controller.GetEntryCount()); | 2662 EXPECT_EQ(4, controller.GetEntryCount()); |
| 2651 EXPECT_EQ(3, controller.GetLastCommittedEntryIndex()); | 2663 EXPECT_EQ(3, controller.GetLastCommittedEntryIndex()); |
| 2652 EXPECT_FALSE(controller.GetPendingEntry()); | 2664 EXPECT_FALSE(controller.GetPendingEntry()); |
| 2653 | 2665 |
| 2654 // Remove an entry which is not the last committed one. | 2666 // Remove an entry which is not the last committed one. |
| 2655 EXPECT_TRUE(controller.RemoveEntryAtIndex(0)); | 2667 EXPECT_TRUE(controller.RemoveEntryAtIndex(0)); |
| 2656 EXPECT_EQ(3, controller.GetEntryCount()); | 2668 EXPECT_EQ(3, controller.GetEntryCount()); |
| 2657 EXPECT_EQ(2, controller.GetLastCommittedEntryIndex()); | 2669 EXPECT_EQ(2, controller.GetLastCommittedEntryIndex()); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 2668 | 2680 |
| 2669 TEST_F(NavigationControllerTest, RemoveEntryWithPending) { | 2681 TEST_F(NavigationControllerTest, RemoveEntryWithPending) { |
| 2670 NavigationControllerImpl& controller = controller_impl(); | 2682 NavigationControllerImpl& controller = controller_impl(); |
| 2671 const GURL url1("http://foo/1"); | 2683 const GURL url1("http://foo/1"); |
| 2672 const GURL url2("http://foo/2"); | 2684 const GURL url2("http://foo/2"); |
| 2673 const GURL url3("http://foo/3"); | 2685 const GURL url3("http://foo/3"); |
| 2674 const GURL default_url("http://foo/default"); | 2686 const GURL default_url("http://foo/default"); |
| 2675 | 2687 |
| 2676 controller.LoadURL( | 2688 controller.LoadURL( |
| 2677 url1, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); | 2689 url1, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); |
| 2678 main_test_rfh()->PrepareForCommit(url1); | 2690 main_test_rfh()->PrepareForCommit(); |
| 2679 main_test_rfh()->SendNavigate(0, url1); | 2691 main_test_rfh()->SendNavigate(0, url1); |
| 2680 controller.LoadURL( | 2692 controller.LoadURL( |
| 2681 url2, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); | 2693 url2, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); |
| 2682 main_test_rfh()->PrepareForCommit(url2); | 2694 main_test_rfh()->PrepareForCommit(); |
| 2683 main_test_rfh()->SendNavigate(1, url2); | 2695 main_test_rfh()->SendNavigate(1, url2); |
| 2684 controller.LoadURL( | 2696 controller.LoadURL( |
| 2685 url3, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); | 2697 url3, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); |
| 2686 main_test_rfh()->PrepareForCommit(url3); | 2698 main_test_rfh()->PrepareForCommit(); |
| 2687 main_test_rfh()->SendNavigate(2, url3); | 2699 main_test_rfh()->SendNavigate(2, url3); |
| 2688 | 2700 |
| 2689 // Go back, but don't commit yet. Check that we can't delete the current | 2701 // Go back, but don't commit yet. Check that we can't delete the current |
| 2690 // and pending entries. | 2702 // and pending entries. |
| 2691 controller.GoBack(); | 2703 controller.GoBack(); |
| 2692 EXPECT_FALSE(controller.RemoveEntryAtIndex(2)); | 2704 EXPECT_FALSE(controller.RemoveEntryAtIndex(2)); |
| 2693 EXPECT_FALSE(controller.RemoveEntryAtIndex(1)); | 2705 EXPECT_FALSE(controller.RemoveEntryAtIndex(1)); |
| 2694 | 2706 |
| 2695 // Remove the first entry, while there is a pending entry. This is expected | 2707 // Remove the first entry, while there is a pending entry. This is expected |
| 2696 // to discard the pending entry. | 2708 // to discard the pending entry. |
| 2697 EXPECT_TRUE(controller.RemoveEntryAtIndex(0)); | 2709 EXPECT_TRUE(controller.RemoveEntryAtIndex(0)); |
| 2698 EXPECT_FALSE(controller.GetPendingEntry()); | 2710 EXPECT_FALSE(controller.GetPendingEntry()); |
| 2699 EXPECT_EQ(-1, controller.GetPendingEntryIndex()); | 2711 EXPECT_EQ(-1, controller.GetPendingEntryIndex()); |
| 2700 | 2712 |
| 2701 // We should update the last committed entry index. | 2713 // We should update the last committed entry index. |
| 2702 EXPECT_EQ(1, controller.GetLastCommittedEntryIndex()); | 2714 EXPECT_EQ(1, controller.GetLastCommittedEntryIndex()); |
| 2703 | 2715 |
| 2704 // Now commit and ensure we land on the right entry. | 2716 // Now commit and ensure we land on the right entry. |
| 2705 main_test_rfh()->PrepareForCommit(url2); | 2717 main_test_rfh()->PrepareForCommit(); |
| 2706 main_test_rfh()->SendNavigate(1, url2); | 2718 main_test_rfh()->SendNavigate(1, url2); |
| 2707 EXPECT_EQ(2, controller.GetEntryCount()); | 2719 EXPECT_EQ(2, controller.GetEntryCount()); |
| 2708 EXPECT_EQ(0, controller.GetLastCommittedEntryIndex()); | 2720 EXPECT_EQ(0, controller.GetLastCommittedEntryIndex()); |
| 2709 EXPECT_FALSE(controller.GetPendingEntry()); | 2721 EXPECT_FALSE(controller.GetPendingEntry()); |
| 2710 } | 2722 } |
| 2711 | 2723 |
| 2712 // Tests the transient entry, making sure it goes away with all navigations. | 2724 // Tests the transient entry, making sure it goes away with all navigations. |
| 2713 TEST_F(NavigationControllerTest, TransientEntry) { | 2725 TEST_F(NavigationControllerTest, TransientEntry) { |
| 2714 NavigationControllerImpl& controller = controller_impl(); | 2726 NavigationControllerImpl& controller = controller_impl(); |
| 2715 TestNotificationTracker notifications; | 2727 TestNotificationTracker notifications; |
| 2716 RegisterForAllNavNotifications(¬ifications, &controller); | 2728 RegisterForAllNavNotifications(¬ifications, &controller); |
| 2717 | 2729 |
| 2718 const GURL url0("http://foo/0"); | 2730 const GURL url0("http://foo/0"); |
| 2719 const GURL url1("http://foo/1"); | 2731 const GURL url1("http://foo/1"); |
| 2720 const GURL url2("http://foo/2"); | 2732 const GURL url2("http://foo/2"); |
| 2721 const GURL url3("http://foo/3"); | 2733 const GURL url3("http://foo/3"); |
| 2722 const GURL url3_ref("http://foo/3#bar"); | 2734 const GURL url3_ref("http://foo/3#bar"); |
| 2723 const GURL url4("http://foo/4"); | 2735 const GURL url4("http://foo/4"); |
| 2724 const GURL transient_url("http://foo/transient"); | 2736 const GURL transient_url("http://foo/transient"); |
| 2725 | 2737 |
| 2726 controller.LoadURL( | 2738 controller.LoadURL( |
| 2727 url0, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); | 2739 url0, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); |
| 2728 main_test_rfh()->PrepareForCommit(url0); | 2740 main_test_rfh()->PrepareForCommit(); |
| 2729 main_test_rfh()->SendNavigate(0, url0); | 2741 main_test_rfh()->SendNavigate(0, url0); |
| 2730 controller.LoadURL( | 2742 controller.LoadURL( |
| 2731 url1, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); | 2743 url1, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); |
| 2732 main_test_rfh()->PrepareForCommit(url1); | 2744 main_test_rfh()->PrepareForCommit(); |
| 2733 main_test_rfh()->SendNavigate(1, url1); | 2745 main_test_rfh()->SendNavigate(1, url1); |
| 2734 | 2746 |
| 2735 notifications.Reset(); | 2747 notifications.Reset(); |
| 2736 | 2748 |
| 2737 // Adding a transient with no pending entry. | 2749 // Adding a transient with no pending entry. |
| 2738 NavigationEntryImpl* transient_entry = new NavigationEntryImpl; | 2750 NavigationEntryImpl* transient_entry = new NavigationEntryImpl; |
| 2739 transient_entry->SetURL(transient_url); | 2751 transient_entry->SetURL(transient_url); |
| 2740 controller.SetTransientEntry(transient_entry); | 2752 controller.SetTransientEntry(transient_entry); |
| 2741 | 2753 |
| 2742 // We should not have received any notifications. | 2754 // We should not have received any notifications. |
| 2743 EXPECT_EQ(0U, notifications.size()); | 2755 EXPECT_EQ(0U, notifications.size()); |
| 2744 | 2756 |
| 2745 // Check our state. | 2757 // Check our state. |
| 2746 EXPECT_EQ(transient_url, controller.GetVisibleEntry()->GetURL()); | 2758 EXPECT_EQ(transient_url, controller.GetVisibleEntry()->GetURL()); |
| 2747 EXPECT_EQ(controller.GetEntryCount(), 3); | 2759 EXPECT_EQ(controller.GetEntryCount(), 3); |
| 2748 EXPECT_EQ(controller.GetLastCommittedEntryIndex(), 1); | 2760 EXPECT_EQ(controller.GetLastCommittedEntryIndex(), 1); |
| 2749 EXPECT_EQ(controller.GetPendingEntryIndex(), -1); | 2761 EXPECT_EQ(controller.GetPendingEntryIndex(), -1); |
| 2750 EXPECT_TRUE(controller.GetLastCommittedEntry()); | 2762 EXPECT_TRUE(controller.GetLastCommittedEntry()); |
| 2751 EXPECT_FALSE(controller.GetPendingEntry()); | 2763 EXPECT_FALSE(controller.GetPendingEntry()); |
| 2752 EXPECT_TRUE(controller.CanGoBack()); | 2764 EXPECT_TRUE(controller.CanGoBack()); |
| 2753 EXPECT_FALSE(controller.CanGoForward()); | 2765 EXPECT_FALSE(controller.CanGoForward()); |
| 2754 EXPECT_EQ(contents()->GetMaxPageID(), 1); | 2766 EXPECT_EQ(contents()->GetMaxPageID(), 1); |
| 2755 | 2767 |
| 2756 // Navigate. | 2768 // Navigate. |
| 2757 controller.LoadURL( | 2769 controller.LoadURL( |
| 2758 url2, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); | 2770 url2, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); |
| 2759 main_test_rfh()->PrepareForCommit(url2); | 2771 main_test_rfh()->PrepareForCommit(); |
| 2760 main_test_rfh()->SendNavigate(2, url2); | 2772 main_test_rfh()->SendNavigate(2, url2); |
| 2761 | 2773 |
| 2762 // We should have navigated, transient entry should be gone. | 2774 // We should have navigated, transient entry should be gone. |
| 2763 EXPECT_EQ(url2, controller.GetVisibleEntry()->GetURL()); | 2775 EXPECT_EQ(url2, controller.GetVisibleEntry()->GetURL()); |
| 2764 EXPECT_EQ(controller.GetEntryCount(), 3); | 2776 EXPECT_EQ(controller.GetEntryCount(), 3); |
| 2765 | 2777 |
| 2766 // Add a transient again, then navigate with no pending entry this time. | 2778 // Add a transient again, then navigate with no pending entry this time. |
| 2767 transient_entry = new NavigationEntryImpl; | 2779 transient_entry = new NavigationEntryImpl; |
| 2768 transient_entry->SetURL(transient_url); | 2780 transient_entry->SetURL(transient_url); |
| 2769 controller.SetTransientEntry(transient_entry); | 2781 controller.SetTransientEntry(transient_entry); |
| 2770 EXPECT_EQ(transient_url, controller.GetVisibleEntry()->GetURL()); | 2782 EXPECT_EQ(transient_url, controller.GetVisibleEntry()->GetURL()); |
| 2771 main_test_rfh()->PrepareForCommit(url3); | 2783 main_test_rfh()->SendBeginNavigationWithURL(url3, true); |
| 2784 main_test_rfh()->PrepareForCommit(); |
| 2772 main_test_rfh()->SendNavigate(3, url3); | 2785 main_test_rfh()->SendNavigate(3, url3); |
| 2773 // Transient entry should be gone. | 2786 // Transient entry should be gone. |
| 2774 EXPECT_EQ(url3, controller.GetVisibleEntry()->GetURL()); | 2787 EXPECT_EQ(url3, controller.GetVisibleEntry()->GetURL()); |
| 2775 EXPECT_EQ(controller.GetEntryCount(), 4); | 2788 EXPECT_EQ(controller.GetEntryCount(), 4); |
| 2776 | 2789 |
| 2777 // Initiate a navigation, add a transient then commit navigation. | 2790 // Initiate a navigation, add a transient then commit navigation. |
| 2778 controller.LoadURL( | 2791 controller.LoadURL( |
| 2779 url4, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); | 2792 url4, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); |
| 2780 transient_entry = new NavigationEntryImpl; | 2793 transient_entry = new NavigationEntryImpl; |
| 2781 transient_entry->SetURL(transient_url); | 2794 transient_entry->SetURL(transient_url); |
| 2782 controller.SetTransientEntry(transient_entry); | 2795 controller.SetTransientEntry(transient_entry); |
| 2783 EXPECT_EQ(transient_url, controller.GetVisibleEntry()->GetURL()); | 2796 EXPECT_EQ(transient_url, controller.GetVisibleEntry()->GetURL()); |
| 2784 main_test_rfh()->PrepareForCommit(url4); | 2797 main_test_rfh()->PrepareForCommit(); |
| 2785 main_test_rfh()->SendNavigate(4, url4); | 2798 main_test_rfh()->SendNavigate(4, url4); |
| 2786 EXPECT_EQ(url4, controller.GetVisibleEntry()->GetURL()); | 2799 EXPECT_EQ(url4, controller.GetVisibleEntry()->GetURL()); |
| 2787 EXPECT_EQ(controller.GetEntryCount(), 5); | 2800 EXPECT_EQ(controller.GetEntryCount(), 5); |
| 2788 | 2801 |
| 2789 // Add a transient and go back. This should simply remove the transient. | 2802 // Add a transient and go back. This should simply remove the transient. |
| 2790 transient_entry = new NavigationEntryImpl; | 2803 transient_entry = new NavigationEntryImpl; |
| 2791 transient_entry->SetURL(transient_url); | 2804 transient_entry->SetURL(transient_url); |
| 2792 controller.SetTransientEntry(transient_entry); | 2805 controller.SetTransientEntry(transient_entry); |
| 2793 EXPECT_EQ(transient_url, controller.GetVisibleEntry()->GetURL()); | 2806 EXPECT_EQ(transient_url, controller.GetVisibleEntry()->GetURL()); |
| 2794 EXPECT_TRUE(controller.CanGoBack()); | 2807 EXPECT_TRUE(controller.CanGoBack()); |
| 2795 EXPECT_FALSE(controller.CanGoForward()); | 2808 EXPECT_FALSE(controller.CanGoForward()); |
| 2796 controller.GoBack(); | 2809 controller.GoBack(); |
| 2797 // Transient entry should be gone. | 2810 // Transient entry should be gone. |
| 2798 EXPECT_EQ(url4, controller.GetVisibleEntry()->GetURL()); | 2811 EXPECT_EQ(url4, controller.GetVisibleEntry()->GetURL()); |
| 2799 EXPECT_EQ(controller.GetEntryCount(), 5); | 2812 EXPECT_EQ(controller.GetEntryCount(), 5); |
| 2800 main_test_rfh()->PrepareForCommit(url3); | 2813 |
| 2814 main_test_rfh()->SendBeginNavigationWithURL(url3, false); |
| 2815 main_test_rfh()->PrepareForCommit(); |
| 2801 main_test_rfh()->SendNavigate(3, url3); | 2816 main_test_rfh()->SendNavigate(3, url3); |
| 2802 | 2817 |
| 2803 // Add a transient and go to an entry before the current one. | 2818 // Add a transient and go to an entry before the current one. |
| 2804 transient_entry = new NavigationEntryImpl; | 2819 transient_entry = new NavigationEntryImpl; |
| 2805 transient_entry->SetURL(transient_url); | 2820 transient_entry->SetURL(transient_url); |
| 2806 controller.SetTransientEntry(transient_entry); | 2821 controller.SetTransientEntry(transient_entry); |
| 2807 EXPECT_EQ(transient_url, controller.GetVisibleEntry()->GetURL()); | 2822 EXPECT_EQ(transient_url, controller.GetVisibleEntry()->GetURL()); |
| 2808 controller.GoToIndex(1); | 2823 controller.GoToIndex(1); |
| 2809 // The navigation should have been initiated, transient entry should be gone. | 2824 // The navigation should have been initiated, transient entry should be gone. |
| 2810 EXPECT_FALSE(controller.GetTransientEntry()); | 2825 EXPECT_FALSE(controller.GetTransientEntry()); |
| 2811 EXPECT_EQ(url1, controller.GetPendingEntry()->GetURL()); | 2826 EXPECT_EQ(url1, controller.GetPendingEntry()->GetURL()); |
| 2812 // Visible entry does not update for history navigations until commit. | 2827 // Visible entry does not update for history navigations until commit. |
| 2813 EXPECT_EQ(url3, controller.GetVisibleEntry()->GetURL()); | 2828 EXPECT_EQ(url3, controller.GetVisibleEntry()->GetURL()); |
| 2814 main_test_rfh()->PrepareForCommit(url1); | 2829 main_test_rfh()->PrepareForCommit(); |
| 2815 main_test_rfh()->SendNavigate(1, url1); | 2830 main_test_rfh()->SendNavigate(1, url1); |
| 2816 EXPECT_EQ(url1, controller.GetVisibleEntry()->GetURL()); | 2831 EXPECT_EQ(url1, controller.GetVisibleEntry()->GetURL()); |
| 2817 | 2832 |
| 2818 // Add a transient and go to an entry after the current one. | 2833 // Add a transient and go to an entry after the current one. |
| 2819 transient_entry = new NavigationEntryImpl; | 2834 transient_entry = new NavigationEntryImpl; |
| 2820 transient_entry->SetURL(transient_url); | 2835 transient_entry->SetURL(transient_url); |
| 2821 controller.SetTransientEntry(transient_entry); | 2836 controller.SetTransientEntry(transient_entry); |
| 2822 EXPECT_EQ(transient_url, controller.GetVisibleEntry()->GetURL()); | 2837 EXPECT_EQ(transient_url, controller.GetVisibleEntry()->GetURL()); |
| 2823 controller.GoToIndex(3); | 2838 controller.GoToIndex(3); |
| 2824 // The navigation should have been initiated, transient entry should be gone. | 2839 // The navigation should have been initiated, transient entry should be gone. |
| 2825 // Because of the transient entry that is removed, going to index 3 makes us | 2840 // Because of the transient entry that is removed, going to index 3 makes us |
| 2826 // land on url2 (which is visible after the commit). | 2841 // land on url2 (which is visible after the commit). |
| 2827 EXPECT_EQ(url2, controller.GetPendingEntry()->GetURL()); | 2842 EXPECT_EQ(url2, controller.GetPendingEntry()->GetURL()); |
| 2828 EXPECT_EQ(url1, controller.GetVisibleEntry()->GetURL()); | 2843 EXPECT_EQ(url1, controller.GetVisibleEntry()->GetURL()); |
| 2829 main_test_rfh()->PrepareForCommit(url2); | 2844 main_test_rfh()->PrepareForCommit(); |
| 2830 main_test_rfh()->SendNavigate(2, url2); | 2845 main_test_rfh()->SendNavigate(2, url2); |
| 2831 EXPECT_EQ(url2, controller.GetVisibleEntry()->GetURL()); | 2846 EXPECT_EQ(url2, controller.GetVisibleEntry()->GetURL()); |
| 2832 | 2847 |
| 2833 // Add a transient and go forward. | 2848 // Add a transient and go forward. |
| 2834 transient_entry = new NavigationEntryImpl; | 2849 transient_entry = new NavigationEntryImpl; |
| 2835 transient_entry->SetURL(transient_url); | 2850 transient_entry->SetURL(transient_url); |
| 2836 controller.SetTransientEntry(transient_entry); | 2851 controller.SetTransientEntry(transient_entry); |
| 2837 EXPECT_EQ(transient_url, controller.GetVisibleEntry()->GetURL()); | 2852 EXPECT_EQ(transient_url, controller.GetVisibleEntry()->GetURL()); |
| 2838 EXPECT_TRUE(controller.CanGoForward()); | 2853 EXPECT_TRUE(controller.CanGoForward()); |
| 2839 controller.GoForward(); | 2854 controller.GoForward(); |
| 2840 // We should have navigated, transient entry should be gone. | 2855 // We should have navigated, transient entry should be gone. |
| 2841 EXPECT_FALSE(controller.GetTransientEntry()); | 2856 EXPECT_FALSE(controller.GetTransientEntry()); |
| 2842 EXPECT_EQ(url3, controller.GetPendingEntry()->GetURL()); | 2857 EXPECT_EQ(url3, controller.GetPendingEntry()->GetURL()); |
| 2843 EXPECT_EQ(url2, controller.GetVisibleEntry()->GetURL()); | 2858 EXPECT_EQ(url2, controller.GetVisibleEntry()->GetURL()); |
| 2844 main_test_rfh()->PrepareForCommit(url3); | 2859 main_test_rfh()->PrepareForCommit(); |
| 2845 main_test_rfh()->SendNavigate(3, url3); | 2860 main_test_rfh()->SendNavigate(3, url3); |
| 2846 EXPECT_EQ(url3, controller.GetVisibleEntry()->GetURL()); | 2861 EXPECT_EQ(url3, controller.GetVisibleEntry()->GetURL()); |
| 2847 | 2862 |
| 2848 // Add a transient and do an in-page navigation, replacing the current entry. | 2863 // Add a transient and do an in-page navigation, replacing the current entry. |
| 2849 transient_entry = new NavigationEntryImpl; | 2864 transient_entry = new NavigationEntryImpl; |
| 2850 transient_entry->SetURL(transient_url); | 2865 transient_entry->SetURL(transient_url); |
| 2851 controller.SetTransientEntry(transient_entry); | 2866 controller.SetTransientEntry(transient_entry); |
| 2852 EXPECT_EQ(transient_url, controller.GetVisibleEntry()->GetURL()); | 2867 EXPECT_EQ(transient_url, controller.GetVisibleEntry()->GetURL()); |
| 2853 main_test_rfh()->PrepareForCommit(url3_ref); | 2868 |
| 2869 main_test_rfh()->SendBeginNavigationWithURL(url3_ref, false); |
| 2870 main_test_rfh()->PrepareForCommit(); |
| 2854 main_test_rfh()->SendNavigate(3, url3_ref); | 2871 main_test_rfh()->SendNavigate(3, url3_ref); |
| 2855 // Transient entry should be gone. | 2872 // Transient entry should be gone. |
| 2856 EXPECT_FALSE(controller.GetTransientEntry()); | 2873 EXPECT_FALSE(controller.GetTransientEntry()); |
| 2857 EXPECT_EQ(url3_ref, controller.GetVisibleEntry()->GetURL()); | 2874 EXPECT_EQ(url3_ref, controller.GetVisibleEntry()->GetURL()); |
| 2858 | 2875 |
| 2859 // Ensure the URLs are correct. | 2876 // Ensure the URLs are correct. |
| 2860 EXPECT_EQ(controller.GetEntryCount(), 5); | 2877 EXPECT_EQ(controller.GetEntryCount(), 5); |
| 2861 EXPECT_EQ(controller.GetEntryAtIndex(0)->GetURL(), url0); | 2878 EXPECT_EQ(controller.GetEntryAtIndex(0)->GetURL(), url0); |
| 2862 EXPECT_EQ(controller.GetEntryAtIndex(1)->GetURL(), url1); | 2879 EXPECT_EQ(controller.GetEntryAtIndex(1)->GetURL(), url1); |
| 2863 EXPECT_EQ(controller.GetEntryAtIndex(2)->GetURL(), url2); | 2880 EXPECT_EQ(controller.GetEntryAtIndex(2)->GetURL(), url2); |
| 2864 EXPECT_EQ(controller.GetEntryAtIndex(3)->GetURL(), url3_ref); | 2881 EXPECT_EQ(controller.GetEntryAtIndex(3)->GetURL(), url3_ref); |
| 2865 EXPECT_EQ(controller.GetEntryAtIndex(4)->GetURL(), url4); | 2882 EXPECT_EQ(controller.GetEntryAtIndex(4)->GetURL(), url4); |
| 2866 } | 2883 } |
| 2867 | 2884 |
| 2868 // Test that Reload initiates a new navigation to a transient entry's URL. | 2885 // Test that Reload initiates a new navigation to a transient entry's URL. |
| 2869 TEST_F(NavigationControllerTest, ReloadTransient) { | 2886 TEST_F(NavigationControllerTest, ReloadTransient) { |
| 2870 NavigationControllerImpl& controller = controller_impl(); | 2887 NavigationControllerImpl& controller = controller_impl(); |
| 2871 const GURL url0("http://foo/0"); | 2888 const GURL url0("http://foo/0"); |
| 2872 const GURL url1("http://foo/1"); | 2889 const GURL url1("http://foo/1"); |
| 2873 const GURL transient_url("http://foo/transient"); | 2890 const GURL transient_url("http://foo/transient"); |
| 2874 | 2891 |
| 2875 // Load |url0|, and start a pending navigation to |url1|. | 2892 // Load |url0|, and start a pending navigation to |url1|. |
| 2876 controller.LoadURL( | 2893 controller.LoadURL( |
| 2877 url0, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); | 2894 url0, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); |
| 2878 main_test_rfh()->PrepareForCommit(url0); | 2895 main_test_rfh()->PrepareForCommit(); |
| 2879 main_test_rfh()->SendNavigate(0, url0); | 2896 main_test_rfh()->SendNavigate(0, url0); |
| 2880 controller.LoadURL( | 2897 controller.LoadURL( |
| 2881 url1, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); | 2898 url1, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); |
| 2882 | 2899 |
| 2883 // A transient entry is added, interrupting the navigation. | 2900 // A transient entry is added, interrupting the navigation. |
| 2884 NavigationEntryImpl* transient_entry = new NavigationEntryImpl; | 2901 NavigationEntryImpl* transient_entry = new NavigationEntryImpl; |
| 2885 transient_entry->SetURL(transient_url); | 2902 transient_entry->SetURL(transient_url); |
| 2886 controller.SetTransientEntry(transient_entry); | 2903 controller.SetTransientEntry(transient_entry); |
| 2887 EXPECT_TRUE(controller.GetTransientEntry()); | 2904 EXPECT_TRUE(controller.GetTransientEntry()); |
| 2888 EXPECT_EQ(transient_url, controller.GetVisibleEntry()->GetURL()); | 2905 EXPECT_EQ(transient_url, controller.GetVisibleEntry()->GetURL()); |
| 2889 | 2906 |
| 2890 // The page is reloaded, which should remove the pending entry for |url1| and | 2907 // The page is reloaded, which should remove the pending entry for |url1| and |
| 2891 // the transient entry for |transient_url|, and start a navigation to | 2908 // the transient entry for |transient_url|, and start a navigation to |
| 2892 // |transient_url|. | 2909 // |transient_url|. |
| 2893 controller.Reload(true); | 2910 controller.Reload(true); |
| 2894 EXPECT_FALSE(controller.GetTransientEntry()); | 2911 EXPECT_FALSE(controller.GetTransientEntry()); |
| 2895 EXPECT_TRUE(controller.GetPendingEntry()); | 2912 EXPECT_TRUE(controller.GetPendingEntry()); |
| 2896 EXPECT_EQ(transient_url, controller.GetVisibleEntry()->GetURL()); | 2913 EXPECT_EQ(transient_url, controller.GetVisibleEntry()->GetURL()); |
| 2897 ASSERT_EQ(controller.GetEntryCount(), 1); | 2914 ASSERT_EQ(controller.GetEntryCount(), 1); |
| 2898 EXPECT_EQ(controller.GetEntryAtIndex(0)->GetURL(), url0); | 2915 EXPECT_EQ(controller.GetEntryAtIndex(0)->GetURL(), url0); |
| 2899 | 2916 |
| 2900 // Load of |transient_url| completes. | 2917 // Load of |transient_url| completes. |
| 2901 main_test_rfh()->PrepareForCommit(transient_url); | 2918 main_test_rfh()->PrepareForCommit(); |
| 2902 main_test_rfh()->SendNavigate(1, transient_url); | 2919 main_test_rfh()->SendNavigate(1, transient_url); |
| 2903 ASSERT_EQ(controller.GetEntryCount(), 2); | 2920 ASSERT_EQ(controller.GetEntryCount(), 2); |
| 2904 EXPECT_EQ(controller.GetEntryAtIndex(0)->GetURL(), url0); | 2921 EXPECT_EQ(controller.GetEntryAtIndex(0)->GetURL(), url0); |
| 2905 EXPECT_EQ(controller.GetEntryAtIndex(1)->GetURL(), transient_url); | 2922 EXPECT_EQ(controller.GetEntryAtIndex(1)->GetURL(), transient_url); |
| 2906 } | 2923 } |
| 2907 | 2924 |
| 2908 // Ensure that renderer initiated pending entries get replaced, so that we | 2925 // Ensure that renderer initiated pending entries get replaced, so that we |
| 2909 // don't show a stale virtual URL when a navigation commits. | 2926 // don't show a stale virtual URL when a navigation commits. |
| 2910 // See http://crbug.com/266922. | 2927 // See http://crbug.com/266922. |
| 2911 TEST_F(NavigationControllerTest, RendererInitiatedPendingEntries) { | 2928 TEST_F(NavigationControllerTest, RendererInitiatedPendingEntries) { |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2970 | 2987 |
| 2971 const GURL url0("http://foo/0"); | 2988 const GURL url0("http://foo/0"); |
| 2972 const GURL url1("http://foo/1"); | 2989 const GURL url1("http://foo/1"); |
| 2973 | 2990 |
| 2974 // For typed navigations (browser-initiated), both pending and visible entries | 2991 // For typed navigations (browser-initiated), both pending and visible entries |
| 2975 // should update before commit. | 2992 // should update before commit. |
| 2976 controller.LoadURL( | 2993 controller.LoadURL( |
| 2977 url0, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); | 2994 url0, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); |
| 2978 EXPECT_EQ(url0, controller.GetPendingEntry()->GetURL()); | 2995 EXPECT_EQ(url0, controller.GetPendingEntry()->GetURL()); |
| 2979 EXPECT_EQ(url0, controller.GetVisibleEntry()->GetURL()); | 2996 EXPECT_EQ(url0, controller.GetVisibleEntry()->GetURL()); |
| 2980 main_test_rfh()->PrepareForCommit(url0); | 2997 main_test_rfh()->PrepareForCommit(); |
| 2981 main_test_rfh()->SendNavigate(0, url0); | 2998 main_test_rfh()->SendNavigate(0, url0); |
| 2982 | 2999 |
| 2983 // For link clicks (renderer-initiated navigations), the pending entry should | 3000 // For link clicks (renderer-initiated navigations), the pending entry should |
| 2984 // update before commit but the visible should not. | 3001 // update before commit but the visible should not. |
| 2985 NavigationController::LoadURLParams load_url_params(url1); | 3002 NavigationController::LoadURLParams load_url_params(url1); |
| 2986 load_url_params.is_renderer_initiated = true; | 3003 load_url_params.is_renderer_initiated = true; |
| 2987 controller.LoadURLWithParams(load_url_params); | 3004 controller.LoadURLWithParams(load_url_params); |
| 2988 EXPECT_EQ(url0, controller.GetVisibleEntry()->GetURL()); | 3005 EXPECT_EQ(url0, controller.GetVisibleEntry()->GetURL()); |
| 2989 EXPECT_EQ(url1, controller.GetPendingEntry()->GetURL()); | 3006 EXPECT_EQ(url1, controller.GetPendingEntry()->GetURL()); |
| 2990 EXPECT_TRUE(controller.GetPendingEntry()->is_renderer_initiated()); | 3007 EXPECT_TRUE(controller.GetPendingEntry()->is_renderer_initiated()); |
| 2991 | 3008 |
| 2992 // After commit, both visible should be updated, there should be no pending | 3009 // After commit, both visible should be updated, there should be no pending |
| 2993 // entry, and we should no longer treat the entry as renderer-initiated. | 3010 // entry, and we should no longer treat the entry as renderer-initiated. |
| 2994 main_test_rfh()->PrepareForCommit(url1); | 3011 main_test_rfh()->PrepareForCommit(); |
| 2995 main_test_rfh()->SendNavigate(1, url1); | 3012 main_test_rfh()->SendNavigate(1, url1); |
| 2996 EXPECT_EQ(url1, controller.GetVisibleEntry()->GetURL()); | 3013 EXPECT_EQ(url1, controller.GetVisibleEntry()->GetURL()); |
| 2997 EXPECT_FALSE(controller.GetPendingEntry()); | 3014 EXPECT_FALSE(controller.GetPendingEntry()); |
| 2998 EXPECT_FALSE(controller.GetLastCommittedEntry()->is_renderer_initiated()); | 3015 EXPECT_FALSE(controller.GetLastCommittedEntry()->is_renderer_initiated()); |
| 2999 | 3016 |
| 3000 notifications.Reset(); | 3017 notifications.Reset(); |
| 3001 } | 3018 } |
| 3002 | 3019 |
| 3003 // Tests that the URLs for renderer-initiated navigations in new tabs are | 3020 // Tests that the URLs for renderer-initiated navigations in new tabs are |
| 3004 // displayed to the user before commit, as long as the initial about:blank | 3021 // displayed to the user before commit, as long as the initial about:blank |
| (...skipping 1113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4118 | 4135 |
| 4119 // We should only have the last committed and pending entries at this point, | 4136 // We should only have the last committed and pending entries at this point, |
| 4120 // and the pending entry should still not be in the entry list. | 4137 // and the pending entry should still not be in the entry list. |
| 4121 EXPECT_EQ(0, controller.GetLastCommittedEntryIndex()); | 4138 EXPECT_EQ(0, controller.GetLastCommittedEntryIndex()); |
| 4122 EXPECT_EQ(url2, controller.GetEntryAtIndex(0)->GetURL()); | 4139 EXPECT_EQ(url2, controller.GetEntryAtIndex(0)->GetURL()); |
| 4123 EXPECT_EQ(-1, controller.GetPendingEntryIndex()); | 4140 EXPECT_EQ(-1, controller.GetPendingEntryIndex()); |
| 4124 EXPECT_TRUE(controller.GetPendingEntry()); | 4141 EXPECT_TRUE(controller.GetPendingEntry()); |
| 4125 EXPECT_EQ(1, controller.GetEntryCount()); | 4142 EXPECT_EQ(1, controller.GetEntryCount()); |
| 4126 | 4143 |
| 4127 // Try to commit the pending entry. | 4144 // Try to commit the pending entry. |
| 4128 main_test_rfh()->PrepareForCommit(url3); | 4145 main_test_rfh()->PrepareForCommit(); |
| 4129 main_test_rfh()->SendNavigate(2, url3); | 4146 main_test_rfh()->SendNavigate(2, url3); |
| 4130 EXPECT_EQ(-1, controller.GetPendingEntryIndex()); | 4147 EXPECT_EQ(-1, controller.GetPendingEntryIndex()); |
| 4131 EXPECT_FALSE(controller.GetPendingEntry()); | 4148 EXPECT_FALSE(controller.GetPendingEntry()); |
| 4132 EXPECT_EQ(2, controller.GetEntryCount()); | 4149 EXPECT_EQ(2, controller.GetEntryCount()); |
| 4133 EXPECT_EQ(url3, controller.GetEntryAtIndex(1)->GetURL()); | 4150 EXPECT_EQ(url3, controller.GetEntryAtIndex(1)->GetURL()); |
| 4134 } | 4151 } |
| 4135 | 4152 |
| 4136 // Test to ensure that when we do a history navigation back to the current | 4153 // Test to ensure that when we do a history navigation back to the current |
| 4137 // committed page (e.g., going forward to a slow-loading page, then pressing | 4154 // committed page (e.g., going forward to a slow-loading page, then pressing |
| 4138 // the back button), we just stop the navigation to prevent the throbber from | 4155 // the back button), we just stop the navigation to prevent the throbber from |
| (...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4407 | 4424 |
| 4408 // Verify that the pending entry correctly indicates that the session history | 4425 // Verify that the pending entry correctly indicates that the session history |
| 4409 // should be cleared. | 4426 // should be cleared. |
| 4410 NavigationEntryImpl* entry = controller.GetPendingEntry(); | 4427 NavigationEntryImpl* entry = controller.GetPendingEntry(); |
| 4411 ASSERT_TRUE(entry); | 4428 ASSERT_TRUE(entry); |
| 4412 EXPECT_TRUE(entry->should_clear_history_list()); | 4429 EXPECT_TRUE(entry->should_clear_history_list()); |
| 4413 | 4430 |
| 4414 // Assume that the RF correctly cleared its history and commit the navigation. | 4431 // Assume that the RF correctly cleared its history and commit the navigation. |
| 4415 if (base::CommandLine::ForCurrentProcess()->HasSwitch( | 4432 if (base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 4416 switches::kEnableBrowserSideNavigation)) { | 4433 switches::kEnableBrowserSideNavigation)) { |
| 4417 contents()->GetMainFrame()->PrepareForCommit(entry->GetURL()); | 4434 contents()->GetMainFrame()->PrepareForCommit(); |
| 4418 } | 4435 } |
| 4419 contents()->GetPendingMainFrame()-> | 4436 contents()->GetPendingMainFrame()-> |
| 4420 set_simulate_history_list_was_cleared(true); | 4437 set_simulate_history_list_was_cleared(true); |
| 4421 contents()->CommitPendingNavigation(); | 4438 contents()->CommitPendingNavigation(); |
| 4422 | 4439 |
| 4423 // Verify that the NavigationController's session history was correctly | 4440 // Verify that the NavigationController's session history was correctly |
| 4424 // cleared. | 4441 // cleared. |
| 4425 EXPECT_EQ(1, controller.GetEntryCount()); | 4442 EXPECT_EQ(1, controller.GetEntryCount()); |
| 4426 EXPECT_EQ(0, controller.GetCurrentEntryIndex()); | 4443 EXPECT_EQ(0, controller.GetCurrentEntryIndex()); |
| 4427 EXPECT_EQ(0, controller.GetLastCommittedEntryIndex()); | 4444 EXPECT_EQ(0, controller.GetLastCommittedEntryIndex()); |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4518 { | 4535 { |
| 4519 LoadCommittedDetails details; | 4536 LoadCommittedDetails details; |
| 4520 controller_impl().RendererDidNavigate(main_test_rfh(), params, &details); | 4537 controller_impl().RendererDidNavigate(main_test_rfh(), params, &details); |
| 4521 EXPECT_EQ(PAGE_TYPE_ERROR, | 4538 EXPECT_EQ(PAGE_TYPE_ERROR, |
| 4522 controller_impl().GetLastCommittedEntry()->GetPageType()); | 4539 controller_impl().GetLastCommittedEntry()->GetPageType()); |
| 4523 EXPECT_EQ(NAVIGATION_TYPE_IN_PAGE, details.type); | 4540 EXPECT_EQ(NAVIGATION_TYPE_IN_PAGE, details.type); |
| 4524 } | 4541 } |
| 4525 } | 4542 } |
| 4526 | 4543 |
| 4527 } // namespace content | 4544 } // namespace content |
| OLD | NEW |