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

Unified Diff: chrome/browser/tab_contents/navigation_controller_unittest.cc

Issue 1036003: Add chromium-side support for history.{push,replace}State. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 10 years, 9 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/tab_contents/navigation_controller.cc ('k') | chrome/renderer/render_thread.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/tab_contents/navigation_controller_unittest.cc
===================================================================
--- chrome/browser/tab_contents/navigation_controller_unittest.cc (revision 41846)
+++ chrome/browser/tab_contents/navigation_controller_unittest.cc (working copy)
@@ -1043,15 +1043,14 @@
TestNotificationTracker notifications;
RegisterForAllNavNotifications(&notifications, &controller());
- // Main page. Note that we need "://" so this URL is treated as "standard"
- // which are the only ones that can have a ref.
- const GURL url1("http:////foo");
+ // Main page.
+ const GURL url1("http://foo");
rvh()->SendNavigate(0, url1);
EXPECT_TRUE(notifications.Check1AndReset(
NotificationType::NAV_ENTRY_COMMITTED));
// First navigation.
- const GURL url2("http:////foo#a");
+ const GURL url2("http://foo#a");
ViewHostMsg_FrameNavigate_Params params = {0};
params.page_id = 1;
params.url = url2;
@@ -1066,6 +1065,7 @@
EXPECT_TRUE(notifications.Check1AndReset(
NotificationType::NAV_ENTRY_COMMITTED));
EXPECT_TRUE(details.is_in_page);
+ EXPECT_FALSE(details.did_replace_entry);
EXPECT_EQ(2, controller().entry_count());
// Go back one.
@@ -1109,7 +1109,7 @@
controller().GetActiveEntry()->url());
// Finally, navigate to an unrelated URL to make sure in_page is not sticky.
- const GURL url3("http:////bar");
+ const GURL url3("http://bar");
params.page_id = 2;
params.url = url3;
notifications.Reset();
@@ -1119,6 +1119,37 @@
EXPECT_FALSE(details.is_in_page);
}
+TEST_F(NavigationControllerTest, InPage_Replace) {
+ TestNotificationTracker notifications;
+ RegisterForAllNavNotifications(&notifications, &controller());
+
+ // Main page.
+ const GURL url1("http://foo");
+ rvh()->SendNavigate(0, url1);
+ EXPECT_TRUE(notifications.Check1AndReset(
+ NotificationType::NAV_ENTRY_COMMITTED));
+
+ // First navigation.
+ const GURL url2("http://foo#a");
+ ViewHostMsg_FrameNavigate_Params params = {0};
+ params.page_id = 0; // Same page_id
+ params.url = url2;
+ params.transition = PageTransition::LINK;
+ params.should_update_history = false;
+ params.gesture = NavigationGestureUser;
+ params.is_post = false;
+
+ // This should NOT generate a new entry.
+ NavigationController::LoadCommittedDetails details;
+ EXPECT_TRUE(controller().RendererDidNavigate(params, 0, &details));
+ EXPECT_TRUE(notifications.Check2AndReset(
+ NotificationType::NAV_LIST_PRUNED,
+ NotificationType::NAV_ENTRY_COMMITTED));
+ EXPECT_TRUE(details.is_in_page);
+ EXPECT_TRUE(details.did_replace_entry);
+ EXPECT_EQ(1, controller().entry_count());
+}
+
// NotificationObserver implementation used in verifying we've received the
// NotificationType::NAV_LIST_PRUNED method.
class PrunedListener : public NotificationObserver {
« no previous file with comments | « chrome/browser/tab_contents/navigation_controller.cc ('k') | chrome/renderer/render_thread.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698