Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(145)

Side by Side Diff: content/browser/frame_host/navigation_controller_impl_unittest.cc

Issue 2584513003: PlzNavigate: identify same-page browser-initiated navigation. (Closed)
Patch Set: Very minor fix. Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 2571 matching lines...) Expand 10 before | Expand all | Expand 10 after
2582 // Ensure main page navigation to same url respects the was_within_same_page 2582 // Ensure main page navigation to same url respects the was_within_same_page
2583 // hint provided in the params. 2583 // hint provided in the params.
2584 FrameHostMsg_DidCommitProvisionalLoad_Params self_params; 2584 FrameHostMsg_DidCommitProvisionalLoad_Params self_params;
2585 self_params.nav_entry_id = 0; 2585 self_params.nav_entry_id = 0;
2586 self_params.did_create_new_entry = false; 2586 self_params.did_create_new_entry = false;
2587 self_params.url = url1; 2587 self_params.url = url1;
2588 self_params.transition = ui::PAGE_TRANSITION_LINK; 2588 self_params.transition = ui::PAGE_TRANSITION_LINK;
2589 self_params.should_update_history = false; 2589 self_params.should_update_history = false;
2590 self_params.gesture = NavigationGestureUser; 2590 self_params.gesture = NavigationGestureUser;
2591 self_params.method = "GET"; 2591 self_params.method = "GET";
2592 self_params.page_state = PageState::CreateFromURL(url1); 2592 self_params.item_sequence_number = GenerateSequenceNumber();
2593 self_params.document_sequence_number = GenerateSequenceNumber();
2594 self_params.page_state = PageState::CreateForTestingWithSequenceNumbers(
2595 url1, self_params.item_sequence_number,
2596 self_params.document_sequence_number);
2593 self_params.was_within_same_page = true; 2597 self_params.was_within_same_page = true;
2594 2598
2595 LoadCommittedDetailsObserver observer(contents()); 2599 LoadCommittedDetailsObserver observer(contents());
2596 main_test_rfh()->SendRendererInitiatedNavigationRequest(url1, false); 2600 main_test_rfh()->SendRendererInitiatedNavigationRequest(url1, false);
2597 main_test_rfh()->PrepareForCommit(); 2601 main_test_rfh()->PrepareForCommit();
2598 main_test_rfh()->SendNavigateWithParams(&self_params); 2602 main_test_rfh()->SendNavigateWithParams(&self_params);
2599 NavigationEntry* entry1 = controller.GetLastCommittedEntry(); 2603 NavigationEntry* entry1 = controller.GetLastCommittedEntry();
2600 EXPECT_EQ(1U, navigation_entry_committed_counter_); 2604 EXPECT_EQ(1U, navigation_entry_committed_counter_);
2601 navigation_entry_committed_counter_ = 0; 2605 navigation_entry_committed_counter_ = 0;
2602 EXPECT_TRUE(observer.details().is_in_page); 2606 EXPECT_TRUE(observer.details().is_in_page);
2603 EXPECT_TRUE(observer.details().did_replace_entry); 2607 EXPECT_TRUE(observer.details().did_replace_entry);
2604 EXPECT_EQ(1, controller.GetEntryCount()); 2608 EXPECT_EQ(1, controller.GetEntryCount());
2605 2609
2606 // Fragment navigation to a new page. 2610 // Fragment navigation to a new page.
2607 const GURL url2("http://foo#a"); 2611 const GURL url2("http://foo#a");
2608 FrameHostMsg_DidCommitProvisionalLoad_Params params; 2612 FrameHostMsg_DidCommitProvisionalLoad_Params params;
2609 params.nav_entry_id = 0; 2613 params.nav_entry_id = 0;
2610 params.did_create_new_entry = true; 2614 params.did_create_new_entry = true;
2611 params.url = url2; 2615 params.url = url2;
2612 params.transition = ui::PAGE_TRANSITION_LINK; 2616 params.transition = ui::PAGE_TRANSITION_LINK;
2613 params.should_update_history = false; 2617 params.should_update_history = false;
2614 params.gesture = NavigationGestureUser; 2618 params.gesture = NavigationGestureUser;
2615 params.method = "GET"; 2619 params.method = "GET";
2616 params.page_state = PageState::CreateFromURL(url2); 2620 params.item_sequence_number = GenerateSequenceNumber();
2621 params.document_sequence_number = self_params.document_sequence_number;
2622 params.page_state = PageState::CreateForTestingWithSequenceNumbers(
2623 url2, params.item_sequence_number, params.document_sequence_number);
2617 params.was_within_same_page = true; 2624 params.was_within_same_page = true;
2618 2625
2619 // This should generate a new entry. 2626 // This should generate a new entry.
2620 main_test_rfh()->SendRendererInitiatedNavigationRequest(url2, false);
2621 main_test_rfh()->PrepareForCommit();
nasko 2017/01/13 02:51:10 Doesn't dropping these change the nature of the te
arthursonzogni 2017/01/13 15:18:37 renderer-initiated navigations doesn't do a round-
nasko 2017/01/13 19:36:56 Acknowledged.
2622 main_test_rfh()->SendNavigateWithParams(&params); 2627 main_test_rfh()->SendNavigateWithParams(&params);
2623 NavigationEntry* entry2 = controller.GetLastCommittedEntry(); 2628 NavigationEntry* entry2 = controller.GetLastCommittedEntry();
2624 EXPECT_EQ(1U, navigation_entry_committed_counter_); 2629 EXPECT_EQ(1U, navigation_entry_committed_counter_);
2625 navigation_entry_committed_counter_ = 0; 2630 navigation_entry_committed_counter_ = 0;
2626 EXPECT_TRUE(observer.details().is_in_page); 2631 EXPECT_TRUE(observer.details().is_in_page);
2627 EXPECT_FALSE(observer.details().did_replace_entry); 2632 EXPECT_FALSE(observer.details().did_replace_entry);
2628 EXPECT_EQ(2, controller.GetEntryCount()); 2633 EXPECT_EQ(2, controller.GetEntryCount());
2629 2634
2630 // Go back one. 2635 // Go back one.
2631 FrameHostMsg_DidCommitProvisionalLoad_Params back_params(params); 2636 FrameHostMsg_DidCommitProvisionalLoad_Params back_params(self_params);
2632 controller.GoBack(); 2637 controller.GoBack();
2633 back_params.url = url1;
nasko 2017/01/13 02:51:09 Why is setting of the URL dropped here?
arthursonzogni 2017/01/13 15:18:37 back_params is a copy of self_params. We redo the
2634 back_params.nav_entry_id = entry1->GetUniqueID(); 2638 back_params.nav_entry_id = entry1->GetUniqueID();
2635 back_params.did_create_new_entry = false; 2639 back_params.did_create_new_entry = false;
2636 main_test_rfh()->PrepareForCommit();
2637 main_test_rfh()->SendNavigateWithParams(&back_params); 2640 main_test_rfh()->SendNavigateWithParams(&back_params);
2638 EXPECT_EQ(1U, navigation_entry_committed_counter_); 2641 EXPECT_EQ(1U, navigation_entry_committed_counter_);
2639 navigation_entry_committed_counter_ = 0; 2642 navigation_entry_committed_counter_ = 0;
2640 EXPECT_TRUE(observer.details().is_in_page); 2643 EXPECT_TRUE(observer.details().is_in_page);
2641 EXPECT_EQ(2, controller.GetEntryCount()); 2644 EXPECT_EQ(2, controller.GetEntryCount());
2642 EXPECT_EQ(0, controller.GetCurrentEntryIndex()); 2645 EXPECT_EQ(0, controller.GetCurrentEntryIndex());
2643 EXPECT_EQ(back_params.url, controller.GetVisibleEntry()->GetURL()); 2646 EXPECT_EQ(back_params.url, controller.GetVisibleEntry()->GetURL());
2644 2647
2645 // Go forward. 2648 // Go forward.
2646 FrameHostMsg_DidCommitProvisionalLoad_Params forward_params(params); 2649 FrameHostMsg_DidCommitProvisionalLoad_Params forward_params(params);
2647 controller.GoForward(); 2650 controller.GoForward();
2648 forward_params.url = url2;
2649 forward_params.nav_entry_id = entry2->GetUniqueID(); 2651 forward_params.nav_entry_id = entry2->GetUniqueID();
2650 forward_params.did_create_new_entry = false; 2652 forward_params.did_create_new_entry = false;
2651 main_test_rfh()->PrepareForCommit();
2652 main_test_rfh()->SendNavigateWithParams(&forward_params); 2653 main_test_rfh()->SendNavigateWithParams(&forward_params);
2653 EXPECT_EQ(1U, navigation_entry_committed_counter_); 2654 EXPECT_EQ(1U, navigation_entry_committed_counter_);
2654 navigation_entry_committed_counter_ = 0; 2655 navigation_entry_committed_counter_ = 0;
2655 EXPECT_TRUE(observer.details().is_in_page); 2656 EXPECT_TRUE(observer.details().is_in_page);
2656 EXPECT_EQ(2, controller.GetEntryCount()); 2657 EXPECT_EQ(2, controller.GetEntryCount());
2657 EXPECT_EQ(1, controller.GetCurrentEntryIndex()); 2658 EXPECT_EQ(1, controller.GetCurrentEntryIndex());
2658 EXPECT_EQ(forward_params.url, 2659 EXPECT_EQ(forward_params.url,
2659 controller.GetVisibleEntry()->GetURL()); 2660 controller.GetVisibleEntry()->GetURL());
2660 2661
2661 // Now go back and forward again. This is to work around a bug where we would 2662 // Now go back and forward again. This is to work around a bug where we would
2662 // compare the incoming URL with the last committed entry rather than the 2663 // compare the incoming URL with the last committed entry rather than the
2663 // one identified by an existing page ID. This would result in the second URL 2664 // one identified by an existing page ID. This would result in the second URL
2664 // losing the reference fragment when you navigate away from it and then back. 2665 // losing the reference fragment when you navigate away from it and then back.
2665 controller.GoBack(); 2666 controller.GoBack();
2666 main_test_rfh()->PrepareForCommit();
2667 main_test_rfh()->SendNavigateWithParams(&back_params); 2667 main_test_rfh()->SendNavigateWithParams(&back_params);
2668 controller.GoForward(); 2668 controller.GoForward();
2669 main_test_rfh()->PrepareForCommit();
2670 main_test_rfh()->SendNavigateWithParams(&forward_params); 2669 main_test_rfh()->SendNavigateWithParams(&forward_params);
2671 EXPECT_EQ(forward_params.url, 2670 EXPECT_EQ(forward_params.url,
2672 controller.GetVisibleEntry()->GetURL()); 2671 controller.GetVisibleEntry()->GetURL());
2673 2672
2674 // Finally, navigate to an unrelated URL to make sure in_page is not sticky. 2673 // Finally, navigate to an unrelated URL to make sure in_page is not sticky.
2675 const GURL url3("http://bar"); 2674 const GURL url3("http://bar");
2676 params.nav_entry_id = 0; 2675 params.nav_entry_id = 0;
2677 params.did_create_new_entry = true; 2676 params.did_create_new_entry = true;
2678 params.url = url3; 2677 params.url = url3;
2678 params.item_sequence_number = 0;
2679 params.document_sequence_number = 0;
2680 params.page_state = PageState::CreateFromURL(url3);
2681 params.was_within_same_page = false;
2679 navigation_entry_committed_counter_ = 0; 2682 navigation_entry_committed_counter_ = 0;
2680 main_test_rfh()->SendRendererInitiatedNavigationRequest(url3, false); 2683 main_test_rfh()->SendRendererInitiatedNavigationRequest(url3, false);
2681 main_test_rfh()->PrepareForCommit(); 2684 main_test_rfh()->PrepareForCommit();
2682 main_test_rfh()->SendNavigateWithParams(&params); 2685 main_test_rfh()->SendNavigateWithParams(&params);
2683 EXPECT_EQ(1U, navigation_entry_committed_counter_); 2686 EXPECT_EQ(1U, navigation_entry_committed_counter_);
2684 navigation_entry_committed_counter_ = 0; 2687 navigation_entry_committed_counter_ = 0;
2685 EXPECT_FALSE(observer.details().is_in_page); 2688 EXPECT_FALSE(observer.details().is_in_page);
2686 EXPECT_EQ(3, controller.GetEntryCount()); 2689 EXPECT_EQ(3, controller.GetEntryCount());
2687 EXPECT_EQ(2, controller.GetCurrentEntryIndex()); 2690 EXPECT_EQ(2, controller.GetCurrentEntryIndex());
2688 } 2691 }
(...skipping 17 matching lines...) Expand all
2706 params.url = url2; 2709 params.url = url2;
2707 params.transition = ui::PAGE_TRANSITION_LINK; 2710 params.transition = ui::PAGE_TRANSITION_LINK;
2708 params.should_update_history = false; 2711 params.should_update_history = false;
2709 params.gesture = NavigationGestureUser; 2712 params.gesture = NavigationGestureUser;
2710 params.method = "GET"; 2713 params.method = "GET";
2711 params.page_state = PageState::CreateFromURL(url2); 2714 params.page_state = PageState::CreateFromURL(url2);
2712 params.was_within_same_page = true; 2715 params.was_within_same_page = true;
2713 2716
2714 // This should NOT generate a new entry, nor prune the list. 2717 // This should NOT generate a new entry, nor prune the list.
2715 LoadCommittedDetailsObserver observer(contents()); 2718 LoadCommittedDetailsObserver observer(contents());
2716 main_test_rfh()->SendRendererInitiatedNavigationRequest(url2, false);
2717 main_test_rfh()->PrepareForCommit();
2718 main_test_rfh()->SendNavigateWithParams(&params); 2719 main_test_rfh()->SendNavigateWithParams(&params);
2719 EXPECT_EQ(1U, navigation_entry_committed_counter_); 2720 EXPECT_EQ(1U, navigation_entry_committed_counter_);
2720 navigation_entry_committed_counter_ = 0; 2721 navigation_entry_committed_counter_ = 0;
2721 EXPECT_TRUE(observer.details().is_in_page); 2722 EXPECT_TRUE(observer.details().is_in_page);
2722 EXPECT_TRUE(observer.details().did_replace_entry); 2723 EXPECT_TRUE(observer.details().did_replace_entry);
2723 EXPECT_EQ(1, controller.GetEntryCount()); 2724 EXPECT_EQ(1, controller.GetEntryCount());
2724 } 2725 }
2725 2726
2726 // Tests for http://crbug.com/40395 2727 // Tests for http://crbug.com/40395
2727 // Simulates this: 2728 // Simulates this:
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
2760 params.transition = ui::PAGE_TRANSITION_LINK; 2761 params.transition = ui::PAGE_TRANSITION_LINK;
2761 params.redirects.push_back(url); 2762 params.redirects.push_back(url);
2762 params.should_update_history = true; 2763 params.should_update_history = true;
2763 params.gesture = NavigationGestureUnknown; 2764 params.gesture = NavigationGestureUnknown;
2764 params.method = "GET"; 2765 params.method = "GET";
2765 params.page_state = PageState::CreateFromURL(url); 2766 params.page_state = PageState::CreateFromURL(url);
2766 params.was_within_same_page = true; 2767 params.was_within_same_page = true;
2767 2768
2768 // This should NOT generate a new entry, nor prune the list. 2769 // This should NOT generate a new entry, nor prune the list.
2769 LoadCommittedDetailsObserver observer(contents()); 2770 LoadCommittedDetailsObserver observer(contents());
2770 main_test_rfh()->SendRendererInitiatedNavigationRequest(url, false);
2771 main_test_rfh()->PrepareForCommit();
2772 main_test_rfh()->SendNavigateWithParams(&params); 2771 main_test_rfh()->SendNavigateWithParams(&params);
2773 EXPECT_EQ(1U, navigation_entry_committed_counter_); 2772 EXPECT_EQ(1U, navigation_entry_committed_counter_);
2774 navigation_entry_committed_counter_ = 0; 2773 navigation_entry_committed_counter_ = 0;
2775 EXPECT_TRUE(observer.details().is_in_page); 2774 EXPECT_TRUE(observer.details().is_in_page);
2776 EXPECT_TRUE(observer.details().did_replace_entry); 2775 EXPECT_TRUE(observer.details().did_replace_entry);
2777 EXPECT_EQ(2, controller.GetEntryCount()); 2776 EXPECT_EQ(2, controller.GetEntryCount());
2778 } 2777 }
2779 2778
2780 // Perform a client redirect to a new page. 2779 // Perform a client redirect to a new page.
2781 { 2780 {
(...skipping 577 matching lines...) Expand 10 before | Expand all | Expand 10 after
3359 main_test_rfh()->PrepareForCommit(); 3358 main_test_rfh()->PrepareForCommit();
3360 main_test_rfh()->SendNavigate(entry_id, false, url3); 3359 main_test_rfh()->SendNavigate(entry_id, false, url3);
3361 EXPECT_EQ(url3, controller.GetVisibleEntry()->GetURL()); 3360 EXPECT_EQ(url3, controller.GetVisibleEntry()->GetURL());
3362 3361
3363 // Add a transient and do an in-page navigation, replacing the current entry. 3362 // Add a transient and do an in-page navigation, replacing the current entry.
3364 transient_entry.reset(new NavigationEntryImpl); 3363 transient_entry.reset(new NavigationEntryImpl);
3365 transient_entry->SetURL(transient_url); 3364 transient_entry->SetURL(transient_url);
3366 controller.SetTransientEntry(std::move(transient_entry)); 3365 controller.SetTransientEntry(std::move(transient_entry));
3367 EXPECT_EQ(transient_url, controller.GetVisibleEntry()->GetURL()); 3366 EXPECT_EQ(transient_url, controller.GetVisibleEntry()->GetURL());
3368 3367
3369 main_test_rfh()->SendRendererInitiatedNavigationRequest(url3_ref, false);
3370 main_test_rfh()->PrepareForCommit();
3371 main_test_rfh()->SendNavigate(0, false, url3_ref); 3368 main_test_rfh()->SendNavigate(0, false, url3_ref);
3372 // Transient entry should be gone. 3369 // Transient entry should be gone.
3373 EXPECT_FALSE(controller.GetTransientEntry()); 3370 EXPECT_FALSE(controller.GetTransientEntry());
3374 EXPECT_EQ(url3_ref, controller.GetVisibleEntry()->GetURL()); 3371 EXPECT_EQ(url3_ref, controller.GetVisibleEntry()->GetURL());
3375 3372
3376 // Ensure the URLs are correct. 3373 // Ensure the URLs are correct.
3377 EXPECT_EQ(controller.GetEntryCount(), 5); 3374 EXPECT_EQ(controller.GetEntryCount(), 5);
3378 EXPECT_EQ(controller.GetEntryAtIndex(0)->GetURL(), url0); 3375 EXPECT_EQ(controller.GetEntryAtIndex(0)->GetURL(), url0);
3379 EXPECT_EQ(controller.GetEntryAtIndex(1)->GetURL(), url1); 3376 EXPECT_EQ(controller.GetEntryAtIndex(1)->GetURL(), url1);
3380 EXPECT_EQ(controller.GetEntryAtIndex(2)->GetURL(), url2); 3377 EXPECT_EQ(controller.GetEntryAtIndex(2)->GetURL(), url2);
(...skipping 1534 matching lines...) Expand 10 before | Expand all | Expand 10 after
4915 controller().GetLastCommittedEntry()->GetFavicon() = favicon; 4912 controller().GetLastCommittedEntry()->GetFavicon() = favicon;
4916 4913
4917 // history.pushState() is called. 4914 // history.pushState() is called.
4918 FrameHostMsg_DidCommitProvisionalLoad_Params params; 4915 FrameHostMsg_DidCommitProvisionalLoad_Params params;
4919 GURL kUrl2("http://foo#foo"); 4916 GURL kUrl2("http://foo#foo");
4920 params.nav_entry_id = 0; 4917 params.nav_entry_id = 0;
4921 params.did_create_new_entry = true; 4918 params.did_create_new_entry = true;
4922 params.url = kUrl2; 4919 params.url = kUrl2;
4923 params.page_state = PageState::CreateFromURL(kUrl2); 4920 params.page_state = PageState::CreateFromURL(kUrl2);
4924 params.was_within_same_page = true; 4921 params.was_within_same_page = true;
4925 main_test_rfh()->SendRendererInitiatedNavigationRequest(kUrl2, false);
4926 main_test_rfh()->PrepareForCommit();
4927 main_test_rfh()->SendNavigateWithParams(&params); 4922 main_test_rfh()->SendNavigateWithParams(&params);
4928 4923
4929 // The title should immediately be visible on the new NavigationEntry. 4924 // The title should immediately be visible on the new NavigationEntry.
4930 base::string16 new_title = 4925 base::string16 new_title =
4931 controller().GetLastCommittedEntry()->GetTitleForDisplay(); 4926 controller().GetLastCommittedEntry()->GetTitleForDisplay();
4932 EXPECT_EQ(title, new_title); 4927 EXPECT_EQ(title, new_title);
4933 FaviconStatus new_favicon = 4928 FaviconStatus new_favicon =
4934 controller().GetLastCommittedEntry()->GetFavicon(); 4929 controller().GetLastCommittedEntry()->GetFavicon();
4935 EXPECT_EQ(favicon.valid, new_favicon.valid); 4930 EXPECT_EQ(favicon.valid, new_favicon.valid);
4936 EXPECT_EQ(favicon.url, new_favicon.url); 4931 EXPECT_EQ(favicon.url, new_favicon.url);
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
5012 GURL replace_url("http://foo#foo"); 5007 GURL replace_url("http://foo#foo");
5013 params.nav_entry_id = 0; 5008 params.nav_entry_id = 0;
5014 params.did_create_new_entry = false; 5009 params.did_create_new_entry = false;
5015 params.url = replace_url; 5010 params.url = replace_url;
5016 params.transition = ui::PAGE_TRANSITION_LINK; 5011 params.transition = ui::PAGE_TRANSITION_LINK;
5017 params.gesture = NavigationGestureUser; 5012 params.gesture = NavigationGestureUser;
5018 params.page_state = PageState::CreateFromURL(replace_url); 5013 params.page_state = PageState::CreateFromURL(replace_url);
5019 params.was_within_same_page = true; 5014 params.was_within_same_page = true;
5020 params.method = "GET"; 5015 params.method = "GET";
5021 params.post_id = -1; 5016 params.post_id = -1;
5022 main_test_rfh()->SendRendererInitiatedNavigationRequest(replace_url, false);
5023 main_test_rfh()->PrepareForCommit();
5024 contents()->GetMainFrame()->SendNavigateWithParams(&params); 5017 contents()->GetMainFrame()->SendNavigateWithParams(&params);
5025 5018
5026 // Now reload. replaceState overrides the POST, so we should not show a 5019 // Now reload. replaceState overrides the POST, so we should not show a
5027 // repost warning dialog. 5020 // repost warning dialog.
5028 controller_impl().Reload(ReloadType::NORMAL, true); 5021 controller_impl().Reload(ReloadType::NORMAL, true);
5029 EXPECT_EQ(0, delegate->repost_form_warning_count()); 5022 EXPECT_EQ(0, delegate->repost_form_warning_count());
5030 } 5023 }
5031 5024
5032 TEST_F(NavigationControllerTest, UnreachableURLGivesErrorPage) { 5025 TEST_F(NavigationControllerTest, UnreachableURLGivesErrorPage) {
5033 GURL url("http://foo"); 5026 GURL url("http://foo");
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
5083 controller_impl().GetLastCommittedEntry()->GetPageType()); 5076 controller_impl().GetLastCommittedEntry()->GetPageType());
5084 EXPECT_EQ(NAVIGATION_TYPE_SAME_PAGE, observer.details().type); 5077 EXPECT_EQ(NAVIGATION_TYPE_SAME_PAGE, observer.details().type);
5085 } 5078 }
5086 5079
5087 // Navigate in page. 5080 // Navigate in page.
5088 params.url = GURL("http://foo#foo"); 5081 params.url = GURL("http://foo#foo");
5089 params.transition = ui::PAGE_TRANSITION_LINK; 5082 params.transition = ui::PAGE_TRANSITION_LINK;
5090 params.was_within_same_page = true; 5083 params.was_within_same_page = true;
5091 { 5084 {
5092 LoadCommittedDetailsObserver observer(contents()); 5085 LoadCommittedDetailsObserver observer(contents());
5093 main_test_rfh()->SendRendererInitiatedNavigationRequest(params.url, false);
5094 main_test_rfh()->PrepareForCommit();
5095 main_test_rfh()->SendNavigateWithParams(&params); 5086 main_test_rfh()->SendNavigateWithParams(&params);
5096 EXPECT_EQ(PAGE_TYPE_ERROR, 5087 EXPECT_EQ(PAGE_TYPE_ERROR,
5097 controller_impl().GetLastCommittedEntry()->GetPageType()); 5088 controller_impl().GetLastCommittedEntry()->GetPageType());
5098 EXPECT_TRUE(observer.details().is_in_page); 5089 EXPECT_TRUE(observer.details().is_in_page);
5099 } 5090 }
5100 } 5091 }
5101 5092
5102 // Tests that if a stale navigation comes back from the renderer, it is properly 5093 // Tests that if a stale navigation comes back from the renderer, it is properly
5103 // resurrected. 5094 // resurrected.
5104 TEST_F(NavigationControllerTest, StaleNavigationsResurrected) { 5095 TEST_F(NavigationControllerTest, StaleNavigationsResurrected) {
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
5237 main_test_rfh()->SimulateNavigationStart(url_1); 5228 main_test_rfh()->SimulateNavigationStart(url_1);
5238 EXPECT_EQ(url_1, controller.GetVisibleEntry()->GetURL()); 5229 EXPECT_EQ(url_1, controller.GetVisibleEntry()->GetURL());
5239 EXPECT_EQ(ReloadType::NONE, last_reload_type_); 5230 EXPECT_EQ(ReloadType::NONE, last_reload_type_);
5240 5231
5241 main_test_rfh()->SimulateNavigationCommit(url_2); 5232 main_test_rfh()->SimulateNavigationCommit(url_2);
5242 main_test_rfh()->SimulateNavigationCommit(url_1); 5233 main_test_rfh()->SimulateNavigationCommit(url_1);
5243 main_test_rfh()->SimulateNavigationCommit(url_1); 5234 main_test_rfh()->SimulateNavigationCommit(url_1);
5244 } 5235 }
5245 5236
5246 } // namespace content 5237 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698