| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "content/browser/frame_host/navigation_controller_impl.h" | 5 #include "content/browser/frame_host/navigation_controller_impl.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <memory> | 10 #include <memory> |
| (...skipping 2613 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2624 // Ensure main page navigation to same url respects the was_within_same_page | 2624 // Ensure main page navigation to same url respects the was_within_same_page |
| 2625 // hint provided in the params. | 2625 // hint provided in the params. |
| 2626 FrameHostMsg_DidCommitProvisionalLoad_Params self_params; | 2626 FrameHostMsg_DidCommitProvisionalLoad_Params self_params; |
| 2627 self_params.nav_entry_id = 0; | 2627 self_params.nav_entry_id = 0; |
| 2628 self_params.did_create_new_entry = false; | 2628 self_params.did_create_new_entry = false; |
| 2629 self_params.url = url1; | 2629 self_params.url = url1; |
| 2630 self_params.transition = ui::PAGE_TRANSITION_LINK; | 2630 self_params.transition = ui::PAGE_TRANSITION_LINK; |
| 2631 self_params.should_update_history = false; | 2631 self_params.should_update_history = false; |
| 2632 self_params.gesture = NavigationGestureUser; | 2632 self_params.gesture = NavigationGestureUser; |
| 2633 self_params.method = "GET"; | 2633 self_params.method = "GET"; |
| 2634 self_params.page_state = PageState::CreateFromURL(url1); | 2634 self_params.item_sequence_number = GenerateSequenceNumber(); |
| 2635 self_params.document_sequence_number = GenerateSequenceNumber(); |
| 2636 self_params.page_state = PageState::CreateForTestingWithSequenceNumbers( |
| 2637 url1, self_params.item_sequence_number, |
| 2638 self_params.document_sequence_number); |
| 2635 self_params.was_within_same_page = true; | 2639 self_params.was_within_same_page = true; |
| 2636 | 2640 |
| 2637 LoadCommittedDetailsObserver observer(contents()); | 2641 LoadCommittedDetailsObserver observer(contents()); |
| 2638 main_test_rfh()->SendRendererInitiatedNavigationRequest(url1, false); | 2642 main_test_rfh()->SendRendererInitiatedNavigationRequest(url1, false); |
| 2639 main_test_rfh()->PrepareForCommit(); | 2643 main_test_rfh()->PrepareForCommit(); |
| 2640 main_test_rfh()->SendNavigateWithParams(&self_params); | 2644 main_test_rfh()->SendNavigateWithParams(&self_params); |
| 2641 NavigationEntry* entry1 = controller.GetLastCommittedEntry(); | 2645 NavigationEntry* entry1 = controller.GetLastCommittedEntry(); |
| 2642 EXPECT_EQ(1U, navigation_entry_committed_counter_); | 2646 EXPECT_EQ(1U, navigation_entry_committed_counter_); |
| 2643 navigation_entry_committed_counter_ = 0; | 2647 navigation_entry_committed_counter_ = 0; |
| 2644 EXPECT_TRUE(observer.details().is_in_page); | 2648 EXPECT_TRUE(observer.details().is_in_page); |
| 2645 EXPECT_TRUE(observer.details().did_replace_entry); | 2649 EXPECT_TRUE(observer.details().did_replace_entry); |
| 2646 EXPECT_EQ(1, controller.GetEntryCount()); | 2650 EXPECT_EQ(1, controller.GetEntryCount()); |
| 2647 | 2651 |
| 2648 // Fragment navigation to a new page. | 2652 // Fragment navigation to a new page. |
| 2649 const GURL url2("http://foo#a"); | 2653 const GURL url2("http://foo#a"); |
| 2650 FrameHostMsg_DidCommitProvisionalLoad_Params params; | 2654 FrameHostMsg_DidCommitProvisionalLoad_Params params; |
| 2651 params.nav_entry_id = 0; | 2655 params.nav_entry_id = 0; |
| 2652 params.did_create_new_entry = true; | 2656 params.did_create_new_entry = true; |
| 2653 params.url = url2; | 2657 params.url = url2; |
| 2654 params.transition = ui::PAGE_TRANSITION_LINK; | 2658 params.transition = ui::PAGE_TRANSITION_LINK; |
| 2655 params.should_update_history = false; | 2659 params.should_update_history = false; |
| 2656 params.gesture = NavigationGestureUser; | 2660 params.gesture = NavigationGestureUser; |
| 2657 params.method = "GET"; | 2661 params.method = "GET"; |
| 2658 params.page_state = PageState::CreateFromURL(url2); | 2662 params.item_sequence_number = GenerateSequenceNumber(); |
| 2663 params.document_sequence_number = self_params.document_sequence_number; |
| 2664 params.page_state = PageState::CreateForTestingWithSequenceNumbers( |
| 2665 url2, params.item_sequence_number, params.document_sequence_number); |
| 2659 params.was_within_same_page = true; | 2666 params.was_within_same_page = true; |
| 2660 | 2667 |
| 2661 // This should generate a new entry. | 2668 // This should generate a new entry. |
| 2662 main_test_rfh()->SendRendererInitiatedNavigationRequest(url2, false); | |
| 2663 main_test_rfh()->PrepareForCommit(); | |
| 2664 main_test_rfh()->SendNavigateWithParams(¶ms); | 2669 main_test_rfh()->SendNavigateWithParams(¶ms); |
| 2665 NavigationEntry* entry2 = controller.GetLastCommittedEntry(); | 2670 NavigationEntry* entry2 = controller.GetLastCommittedEntry(); |
| 2666 EXPECT_EQ(1U, navigation_entry_committed_counter_); | 2671 EXPECT_EQ(1U, navigation_entry_committed_counter_); |
| 2667 navigation_entry_committed_counter_ = 0; | 2672 navigation_entry_committed_counter_ = 0; |
| 2668 EXPECT_TRUE(observer.details().is_in_page); | 2673 EXPECT_TRUE(observer.details().is_in_page); |
| 2669 EXPECT_FALSE(observer.details().did_replace_entry); | 2674 EXPECT_FALSE(observer.details().did_replace_entry); |
| 2670 EXPECT_EQ(2, controller.GetEntryCount()); | 2675 EXPECT_EQ(2, controller.GetEntryCount()); |
| 2671 | 2676 |
| 2672 // Go back one. | 2677 // Go back one. |
| 2673 FrameHostMsg_DidCommitProvisionalLoad_Params back_params(params); | 2678 FrameHostMsg_DidCommitProvisionalLoad_Params back_params(self_params); |
| 2674 controller.GoBack(); | 2679 controller.GoBack(); |
| 2675 back_params.url = url1; | |
| 2676 back_params.nav_entry_id = entry1->GetUniqueID(); | 2680 back_params.nav_entry_id = entry1->GetUniqueID(); |
| 2677 back_params.did_create_new_entry = false; | 2681 back_params.did_create_new_entry = false; |
| 2678 main_test_rfh()->PrepareForCommit(); | |
| 2679 main_test_rfh()->SendNavigateWithParams(&back_params); | 2682 main_test_rfh()->SendNavigateWithParams(&back_params); |
| 2680 EXPECT_EQ(1U, navigation_entry_committed_counter_); | 2683 EXPECT_EQ(1U, navigation_entry_committed_counter_); |
| 2681 navigation_entry_committed_counter_ = 0; | 2684 navigation_entry_committed_counter_ = 0; |
| 2682 EXPECT_TRUE(observer.details().is_in_page); | 2685 EXPECT_TRUE(observer.details().is_in_page); |
| 2683 EXPECT_EQ(2, controller.GetEntryCount()); | 2686 EXPECT_EQ(2, controller.GetEntryCount()); |
| 2684 EXPECT_EQ(0, controller.GetCurrentEntryIndex()); | 2687 EXPECT_EQ(0, controller.GetCurrentEntryIndex()); |
| 2685 EXPECT_EQ(back_params.url, controller.GetVisibleEntry()->GetURL()); | 2688 EXPECT_EQ(back_params.url, controller.GetVisibleEntry()->GetURL()); |
| 2686 | 2689 |
| 2687 // Go forward. | 2690 // Go forward. |
| 2688 FrameHostMsg_DidCommitProvisionalLoad_Params forward_params(params); | 2691 FrameHostMsg_DidCommitProvisionalLoad_Params forward_params(params); |
| 2689 controller.GoForward(); | 2692 controller.GoForward(); |
| 2690 forward_params.url = url2; | |
| 2691 forward_params.nav_entry_id = entry2->GetUniqueID(); | 2693 forward_params.nav_entry_id = entry2->GetUniqueID(); |
| 2692 forward_params.did_create_new_entry = false; | 2694 forward_params.did_create_new_entry = false; |
| 2693 main_test_rfh()->PrepareForCommit(); | |
| 2694 main_test_rfh()->SendNavigateWithParams(&forward_params); | 2695 main_test_rfh()->SendNavigateWithParams(&forward_params); |
| 2695 EXPECT_EQ(1U, navigation_entry_committed_counter_); | 2696 EXPECT_EQ(1U, navigation_entry_committed_counter_); |
| 2696 navigation_entry_committed_counter_ = 0; | 2697 navigation_entry_committed_counter_ = 0; |
| 2697 EXPECT_TRUE(observer.details().is_in_page); | 2698 EXPECT_TRUE(observer.details().is_in_page); |
| 2698 EXPECT_EQ(2, controller.GetEntryCount()); | 2699 EXPECT_EQ(2, controller.GetEntryCount()); |
| 2699 EXPECT_EQ(1, controller.GetCurrentEntryIndex()); | 2700 EXPECT_EQ(1, controller.GetCurrentEntryIndex()); |
| 2700 EXPECT_EQ(forward_params.url, | 2701 EXPECT_EQ(forward_params.url, |
| 2701 controller.GetVisibleEntry()->GetURL()); | 2702 controller.GetVisibleEntry()->GetURL()); |
| 2702 | 2703 |
| 2703 // Now go back and forward again. This is to work around a bug where we would | 2704 // Now go back and forward again. This is to work around a bug where we would |
| 2704 // compare the incoming URL with the last committed entry rather than the | 2705 // compare the incoming URL with the last committed entry rather than the |
| 2705 // one identified by an existing page ID. This would result in the second URL | 2706 // one identified by an existing page ID. This would result in the second URL |
| 2706 // losing the reference fragment when you navigate away from it and then back. | 2707 // losing the reference fragment when you navigate away from it and then back. |
| 2707 controller.GoBack(); | 2708 controller.GoBack(); |
| 2708 main_test_rfh()->PrepareForCommit(); | |
| 2709 main_test_rfh()->SendNavigateWithParams(&back_params); | 2709 main_test_rfh()->SendNavigateWithParams(&back_params); |
| 2710 controller.GoForward(); | 2710 controller.GoForward(); |
| 2711 main_test_rfh()->PrepareForCommit(); | |
| 2712 main_test_rfh()->SendNavigateWithParams(&forward_params); | 2711 main_test_rfh()->SendNavigateWithParams(&forward_params); |
| 2713 EXPECT_EQ(forward_params.url, | 2712 EXPECT_EQ(forward_params.url, |
| 2714 controller.GetVisibleEntry()->GetURL()); | 2713 controller.GetVisibleEntry()->GetURL()); |
| 2715 | 2714 |
| 2716 // Finally, navigate to an unrelated URL to make sure in_page is not sticky. | 2715 // Finally, navigate to an unrelated URL to make sure in_page is not sticky. |
| 2717 const GURL url3("http://bar"); | 2716 const GURL url3("http://bar"); |
| 2718 params.nav_entry_id = 0; | 2717 params.nav_entry_id = 0; |
| 2719 params.did_create_new_entry = true; | 2718 params.did_create_new_entry = true; |
| 2720 params.url = url3; | 2719 params.url = url3; |
| 2720 params.item_sequence_number = 0; |
| 2721 params.document_sequence_number = 0; |
| 2722 params.page_state = PageState::CreateFromURL(url3); |
| 2723 params.was_within_same_page = false; |
| 2721 navigation_entry_committed_counter_ = 0; | 2724 navigation_entry_committed_counter_ = 0; |
| 2722 main_test_rfh()->SendRendererInitiatedNavigationRequest(url3, false); | 2725 main_test_rfh()->SendRendererInitiatedNavigationRequest(url3, false); |
| 2723 main_test_rfh()->PrepareForCommit(); | 2726 main_test_rfh()->PrepareForCommit(); |
| 2724 main_test_rfh()->SendNavigateWithParams(¶ms); | 2727 main_test_rfh()->SendNavigateWithParams(¶ms); |
| 2725 EXPECT_EQ(1U, navigation_entry_committed_counter_); | 2728 EXPECT_EQ(1U, navigation_entry_committed_counter_); |
| 2726 navigation_entry_committed_counter_ = 0; | 2729 navigation_entry_committed_counter_ = 0; |
| 2727 EXPECT_FALSE(observer.details().is_in_page); | 2730 EXPECT_FALSE(observer.details().is_in_page); |
| 2728 EXPECT_EQ(3, controller.GetEntryCount()); | 2731 EXPECT_EQ(3, controller.GetEntryCount()); |
| 2729 EXPECT_EQ(2, controller.GetCurrentEntryIndex()); | 2732 EXPECT_EQ(2, controller.GetCurrentEntryIndex()); |
| 2730 } | 2733 } |
| (...skipping 17 matching lines...) Expand all Loading... |
| 2748 params.url = url2; | 2751 params.url = url2; |
| 2749 params.transition = ui::PAGE_TRANSITION_LINK; | 2752 params.transition = ui::PAGE_TRANSITION_LINK; |
| 2750 params.should_update_history = false; | 2753 params.should_update_history = false; |
| 2751 params.gesture = NavigationGestureUser; | 2754 params.gesture = NavigationGestureUser; |
| 2752 params.method = "GET"; | 2755 params.method = "GET"; |
| 2753 params.page_state = PageState::CreateFromURL(url2); | 2756 params.page_state = PageState::CreateFromURL(url2); |
| 2754 params.was_within_same_page = true; | 2757 params.was_within_same_page = true; |
| 2755 | 2758 |
| 2756 // This should NOT generate a new entry, nor prune the list. | 2759 // This should NOT generate a new entry, nor prune the list. |
| 2757 LoadCommittedDetailsObserver observer(contents()); | 2760 LoadCommittedDetailsObserver observer(contents()); |
| 2758 main_test_rfh()->SendRendererInitiatedNavigationRequest(url2, false); | |
| 2759 main_test_rfh()->PrepareForCommit(); | |
| 2760 main_test_rfh()->SendNavigateWithParams(¶ms); | 2761 main_test_rfh()->SendNavigateWithParams(¶ms); |
| 2761 EXPECT_EQ(1U, navigation_entry_committed_counter_); | 2762 EXPECT_EQ(1U, navigation_entry_committed_counter_); |
| 2762 navigation_entry_committed_counter_ = 0; | 2763 navigation_entry_committed_counter_ = 0; |
| 2763 EXPECT_TRUE(observer.details().is_in_page); | 2764 EXPECT_TRUE(observer.details().is_in_page); |
| 2764 EXPECT_TRUE(observer.details().did_replace_entry); | 2765 EXPECT_TRUE(observer.details().did_replace_entry); |
| 2765 EXPECT_EQ(1, controller.GetEntryCount()); | 2766 EXPECT_EQ(1, controller.GetEntryCount()); |
| 2766 } | 2767 } |
| 2767 | 2768 |
| 2768 // Tests for http://crbug.com/40395 | 2769 // Tests for http://crbug.com/40395 |
| 2769 // Simulates this: | 2770 // Simulates this: |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2802 params.transition = ui::PAGE_TRANSITION_LINK; | 2803 params.transition = ui::PAGE_TRANSITION_LINK; |
| 2803 params.redirects.push_back(url); | 2804 params.redirects.push_back(url); |
| 2804 params.should_update_history = true; | 2805 params.should_update_history = true; |
| 2805 params.gesture = NavigationGestureUnknown; | 2806 params.gesture = NavigationGestureUnknown; |
| 2806 params.method = "GET"; | 2807 params.method = "GET"; |
| 2807 params.page_state = PageState::CreateFromURL(url); | 2808 params.page_state = PageState::CreateFromURL(url); |
| 2808 params.was_within_same_page = true; | 2809 params.was_within_same_page = true; |
| 2809 | 2810 |
| 2810 // This should NOT generate a new entry, nor prune the list. | 2811 // This should NOT generate a new entry, nor prune the list. |
| 2811 LoadCommittedDetailsObserver observer(contents()); | 2812 LoadCommittedDetailsObserver observer(contents()); |
| 2812 main_test_rfh()->SendRendererInitiatedNavigationRequest(url, false); | |
| 2813 main_test_rfh()->PrepareForCommit(); | |
| 2814 main_test_rfh()->SendNavigateWithParams(¶ms); | 2813 main_test_rfh()->SendNavigateWithParams(¶ms); |
| 2815 EXPECT_EQ(1U, navigation_entry_committed_counter_); | 2814 EXPECT_EQ(1U, navigation_entry_committed_counter_); |
| 2816 navigation_entry_committed_counter_ = 0; | 2815 navigation_entry_committed_counter_ = 0; |
| 2817 EXPECT_TRUE(observer.details().is_in_page); | 2816 EXPECT_TRUE(observer.details().is_in_page); |
| 2818 EXPECT_TRUE(observer.details().did_replace_entry); | 2817 EXPECT_TRUE(observer.details().did_replace_entry); |
| 2819 EXPECT_EQ(2, controller.GetEntryCount()); | 2818 EXPECT_EQ(2, controller.GetEntryCount()); |
| 2820 } | 2819 } |
| 2821 | 2820 |
| 2822 // Perform a client redirect to a new page. | 2821 // Perform a client redirect to a new page. |
| 2823 { | 2822 { |
| (...skipping 577 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3401 main_test_rfh()->PrepareForCommit(); | 3400 main_test_rfh()->PrepareForCommit(); |
| 3402 main_test_rfh()->SendNavigate(entry_id, false, url3); | 3401 main_test_rfh()->SendNavigate(entry_id, false, url3); |
| 3403 EXPECT_EQ(url3, controller.GetVisibleEntry()->GetURL()); | 3402 EXPECT_EQ(url3, controller.GetVisibleEntry()->GetURL()); |
| 3404 | 3403 |
| 3405 // Add a transient and do an in-page navigation, replacing the current entry. | 3404 // Add a transient and do an in-page navigation, replacing the current entry. |
| 3406 transient_entry.reset(new NavigationEntryImpl); | 3405 transient_entry.reset(new NavigationEntryImpl); |
| 3407 transient_entry->SetURL(transient_url); | 3406 transient_entry->SetURL(transient_url); |
| 3408 controller.SetTransientEntry(std::move(transient_entry)); | 3407 controller.SetTransientEntry(std::move(transient_entry)); |
| 3409 EXPECT_EQ(transient_url, controller.GetVisibleEntry()->GetURL()); | 3408 EXPECT_EQ(transient_url, controller.GetVisibleEntry()->GetURL()); |
| 3410 | 3409 |
| 3411 main_test_rfh()->SendRendererInitiatedNavigationRequest(url3_ref, false); | |
| 3412 main_test_rfh()->PrepareForCommit(); | |
| 3413 main_test_rfh()->SendNavigate(0, false, url3_ref); | 3410 main_test_rfh()->SendNavigate(0, false, url3_ref); |
| 3414 // Transient entry should be gone. | 3411 // Transient entry should be gone. |
| 3415 EXPECT_FALSE(controller.GetTransientEntry()); | 3412 EXPECT_FALSE(controller.GetTransientEntry()); |
| 3416 EXPECT_EQ(url3_ref, controller.GetVisibleEntry()->GetURL()); | 3413 EXPECT_EQ(url3_ref, controller.GetVisibleEntry()->GetURL()); |
| 3417 | 3414 |
| 3418 // Ensure the URLs are correct. | 3415 // Ensure the URLs are correct. |
| 3419 EXPECT_EQ(controller.GetEntryCount(), 5); | 3416 EXPECT_EQ(controller.GetEntryCount(), 5); |
| 3420 EXPECT_EQ(controller.GetEntryAtIndex(0)->GetURL(), url0); | 3417 EXPECT_EQ(controller.GetEntryAtIndex(0)->GetURL(), url0); |
| 3421 EXPECT_EQ(controller.GetEntryAtIndex(1)->GetURL(), url1); | 3418 EXPECT_EQ(controller.GetEntryAtIndex(1)->GetURL(), url1); |
| 3422 EXPECT_EQ(controller.GetEntryAtIndex(2)->GetURL(), url2); | 3419 EXPECT_EQ(controller.GetEntryAtIndex(2)->GetURL(), url2); |
| (...skipping 1535 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4958 controller().GetLastCommittedEntry()->GetFavicon() = favicon; | 4955 controller().GetLastCommittedEntry()->GetFavicon() = favicon; |
| 4959 | 4956 |
| 4960 // history.pushState() is called. | 4957 // history.pushState() is called. |
| 4961 FrameHostMsg_DidCommitProvisionalLoad_Params params; | 4958 FrameHostMsg_DidCommitProvisionalLoad_Params params; |
| 4962 GURL kUrl2("http://foo#foo"); | 4959 GURL kUrl2("http://foo#foo"); |
| 4963 params.nav_entry_id = 0; | 4960 params.nav_entry_id = 0; |
| 4964 params.did_create_new_entry = true; | 4961 params.did_create_new_entry = true; |
| 4965 params.url = kUrl2; | 4962 params.url = kUrl2; |
| 4966 params.page_state = PageState::CreateFromURL(kUrl2); | 4963 params.page_state = PageState::CreateFromURL(kUrl2); |
| 4967 params.was_within_same_page = true; | 4964 params.was_within_same_page = true; |
| 4968 main_test_rfh()->SendRendererInitiatedNavigationRequest(kUrl2, false); | |
| 4969 main_test_rfh()->PrepareForCommit(); | |
| 4970 main_test_rfh()->SendNavigateWithParams(¶ms); | 4965 main_test_rfh()->SendNavigateWithParams(¶ms); |
| 4971 | 4966 |
| 4972 // The title should immediately be visible on the new NavigationEntry. | 4967 // The title should immediately be visible on the new NavigationEntry. |
| 4973 base::string16 new_title = | 4968 base::string16 new_title = |
| 4974 controller().GetLastCommittedEntry()->GetTitleForDisplay(); | 4969 controller().GetLastCommittedEntry()->GetTitleForDisplay(); |
| 4975 EXPECT_EQ(title, new_title); | 4970 EXPECT_EQ(title, new_title); |
| 4976 FaviconStatus new_favicon = | 4971 FaviconStatus new_favicon = |
| 4977 controller().GetLastCommittedEntry()->GetFavicon(); | 4972 controller().GetLastCommittedEntry()->GetFavicon(); |
| 4978 EXPECT_EQ(favicon.valid, new_favicon.valid); | 4973 EXPECT_EQ(favicon.valid, new_favicon.valid); |
| 4979 EXPECT_EQ(favicon.url, new_favicon.url); | 4974 EXPECT_EQ(favicon.url, new_favicon.url); |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5055 GURL replace_url("http://foo#foo"); | 5050 GURL replace_url("http://foo#foo"); |
| 5056 params.nav_entry_id = 0; | 5051 params.nav_entry_id = 0; |
| 5057 params.did_create_new_entry = false; | 5052 params.did_create_new_entry = false; |
| 5058 params.url = replace_url; | 5053 params.url = replace_url; |
| 5059 params.transition = ui::PAGE_TRANSITION_LINK; | 5054 params.transition = ui::PAGE_TRANSITION_LINK; |
| 5060 params.gesture = NavigationGestureUser; | 5055 params.gesture = NavigationGestureUser; |
| 5061 params.page_state = PageState::CreateFromURL(replace_url); | 5056 params.page_state = PageState::CreateFromURL(replace_url); |
| 5062 params.was_within_same_page = true; | 5057 params.was_within_same_page = true; |
| 5063 params.method = "GET"; | 5058 params.method = "GET"; |
| 5064 params.post_id = -1; | 5059 params.post_id = -1; |
| 5065 main_test_rfh()->SendRendererInitiatedNavigationRequest(replace_url, false); | |
| 5066 main_test_rfh()->PrepareForCommit(); | |
| 5067 contents()->GetMainFrame()->SendNavigateWithParams(¶ms); | 5060 contents()->GetMainFrame()->SendNavigateWithParams(¶ms); |
| 5068 | 5061 |
| 5069 // Now reload. replaceState overrides the POST, so we should not show a | 5062 // Now reload. replaceState overrides the POST, so we should not show a |
| 5070 // repost warning dialog. | 5063 // repost warning dialog. |
| 5071 controller_impl().Reload(ReloadType::NORMAL, true); | 5064 controller_impl().Reload(ReloadType::NORMAL, true); |
| 5072 EXPECT_EQ(0, delegate->repost_form_warning_count()); | 5065 EXPECT_EQ(0, delegate->repost_form_warning_count()); |
| 5073 } | 5066 } |
| 5074 | 5067 |
| 5075 TEST_F(NavigationControllerTest, UnreachableURLGivesErrorPage) { | 5068 TEST_F(NavigationControllerTest, UnreachableURLGivesErrorPage) { |
| 5076 GURL url("http://foo"); | 5069 GURL url("http://foo"); |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5126 controller_impl().GetLastCommittedEntry()->GetPageType()); | 5119 controller_impl().GetLastCommittedEntry()->GetPageType()); |
| 5127 EXPECT_EQ(NAVIGATION_TYPE_SAME_PAGE, observer.details().type); | 5120 EXPECT_EQ(NAVIGATION_TYPE_SAME_PAGE, observer.details().type); |
| 5128 } | 5121 } |
| 5129 | 5122 |
| 5130 // Navigate in page. | 5123 // Navigate in page. |
| 5131 params.url = GURL("http://foo#foo"); | 5124 params.url = GURL("http://foo#foo"); |
| 5132 params.transition = ui::PAGE_TRANSITION_LINK; | 5125 params.transition = ui::PAGE_TRANSITION_LINK; |
| 5133 params.was_within_same_page = true; | 5126 params.was_within_same_page = true; |
| 5134 { | 5127 { |
| 5135 LoadCommittedDetailsObserver observer(contents()); | 5128 LoadCommittedDetailsObserver observer(contents()); |
| 5136 main_test_rfh()->SendRendererInitiatedNavigationRequest(params.url, false); | |
| 5137 main_test_rfh()->PrepareForCommit(); | |
| 5138 main_test_rfh()->SendNavigateWithParams(¶ms); | 5129 main_test_rfh()->SendNavigateWithParams(¶ms); |
| 5139 EXPECT_EQ(PAGE_TYPE_ERROR, | 5130 EXPECT_EQ(PAGE_TYPE_ERROR, |
| 5140 controller_impl().GetLastCommittedEntry()->GetPageType()); | 5131 controller_impl().GetLastCommittedEntry()->GetPageType()); |
| 5141 EXPECT_TRUE(observer.details().is_in_page); | 5132 EXPECT_TRUE(observer.details().is_in_page); |
| 5142 } | 5133 } |
| 5143 } | 5134 } |
| 5144 | 5135 |
| 5145 // Tests that if a stale navigation comes back from the renderer, it is properly | 5136 // Tests that if a stale navigation comes back from the renderer, it is properly |
| 5146 // resurrected. | 5137 // resurrected. |
| 5147 TEST_F(NavigationControllerTest, StaleNavigationsResurrected) { | 5138 TEST_F(NavigationControllerTest, StaleNavigationsResurrected) { |
| (...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5280 main_test_rfh()->SimulateNavigationStart(url_1); | 5271 main_test_rfh()->SimulateNavigationStart(url_1); |
| 5281 EXPECT_EQ(url_1, controller.GetVisibleEntry()->GetURL()); | 5272 EXPECT_EQ(url_1, controller.GetVisibleEntry()->GetURL()); |
| 5282 EXPECT_EQ(ReloadType::NONE, last_reload_type_); | 5273 EXPECT_EQ(ReloadType::NONE, last_reload_type_); |
| 5283 | 5274 |
| 5284 main_test_rfh()->SimulateNavigationCommit(url_2); | 5275 main_test_rfh()->SimulateNavigationCommit(url_2); |
| 5285 main_test_rfh()->SimulateNavigationCommit(url_1); | 5276 main_test_rfh()->SimulateNavigationCommit(url_1); |
| 5286 main_test_rfh()->SimulateNavigationCommit(url_1); | 5277 main_test_rfh()->SimulateNavigationCommit(url_1); |
| 5287 } | 5278 } |
| 5288 | 5279 |
| 5289 } // namespace content | 5280 } // namespace content |
| OLD | NEW |