OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/file_util.h" | 5 #include "base/file_util.h" |
6 #include "base/memory/scoped_ptr.h" | 6 #include "base/memory/scoped_ptr.h" |
7 #include "base/path_service.h" | 7 #include "base/path_service.h" |
8 #include "base/stl_util.h" | 8 #include "base/stl_util.h" |
9 #include "base/string_util.h" | 9 #include "base/string_util.h" |
10 #include "base/utf_string_conversions.h" | 10 #include "base/utf_string_conversions.h" |
(...skipping 1417 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1428 NavigationControllerImpl& controller = controller_impl(); | 1428 NavigationControllerImpl& controller = controller_impl(); |
1429 TestNotificationTracker notifications; | 1429 TestNotificationTracker notifications; |
1430 RegisterForAllNavNotifications(¬ifications, &controller); | 1430 RegisterForAllNavNotifications(¬ifications, &controller); |
1431 | 1431 |
1432 // Main page. | 1432 // Main page. |
1433 const GURL url1("http://foo"); | 1433 const GURL url1("http://foo"); |
1434 test_rvh()->SendNavigate(0, url1); | 1434 test_rvh()->SendNavigate(0, url1); |
1435 EXPECT_TRUE(notifications.Check1AndReset( | 1435 EXPECT_TRUE(notifications.Check1AndReset( |
1436 content::NOTIFICATION_NAV_ENTRY_COMMITTED)); | 1436 content::NOTIFICATION_NAV_ENTRY_COMMITTED)); |
1437 | 1437 |
1438 // First navigation. | 1438 // Ensure main page navigation to same url respects the was_within_same_page |
| 1439 // hint provided in the params. |
| 1440 ViewHostMsg_FrameNavigate_Params self_params; |
| 1441 self_params.page_id = 0; |
| 1442 self_params.url = url1; |
| 1443 self_params.transition = content::PAGE_TRANSITION_LINK; |
| 1444 self_params.should_update_history = false; |
| 1445 self_params.gesture = NavigationGestureUser; |
| 1446 self_params.is_post = false; |
| 1447 self_params.content_state = webkit_glue::CreateHistoryStateForURL(GURL(url1)); |
| 1448 self_params.was_within_same_page = true; |
| 1449 |
| 1450 content::LoadCommittedDetails details; |
| 1451 EXPECT_TRUE(controller.RendererDidNavigate(self_params, &details)); |
| 1452 EXPECT_TRUE(notifications.Check1AndReset( |
| 1453 content::NOTIFICATION_NAV_ENTRY_COMMITTED)); |
| 1454 EXPECT_TRUE(details.is_in_page); |
| 1455 // TODO(tsepez): check why |did_replace_entry| is returned as false. |
| 1456 EXPECT_FALSE(details.did_replace_entry); |
| 1457 EXPECT_EQ(1, controller.GetEntryCount()); |
| 1458 |
| 1459 // Fragment navigation to a new page_id. |
1439 const GURL url2("http://foo#a"); | 1460 const GURL url2("http://foo#a"); |
1440 ViewHostMsg_FrameNavigate_Params params; | 1461 ViewHostMsg_FrameNavigate_Params params; |
1441 params.page_id = 1; | 1462 params.page_id = 1; |
1442 params.url = url2; | 1463 params.url = url2; |
1443 params.transition = content::PAGE_TRANSITION_LINK; | 1464 params.transition = content::PAGE_TRANSITION_LINK; |
1444 params.should_update_history = false; | 1465 params.should_update_history = false; |
1445 params.gesture = NavigationGestureUser; | 1466 params.gesture = NavigationGestureUser; |
1446 params.is_post = false; | 1467 params.is_post = false; |
1447 params.content_state = webkit_glue::CreateHistoryStateForURL(GURL(url2)); | 1468 params.content_state = webkit_glue::CreateHistoryStateForURL(GURL(url2)); |
1448 | 1469 |
1449 // This should generate a new entry. | 1470 // This should generate a new entry. |
1450 content::LoadCommittedDetails details; | |
1451 EXPECT_TRUE(controller.RendererDidNavigate(params, &details)); | 1471 EXPECT_TRUE(controller.RendererDidNavigate(params, &details)); |
1452 EXPECT_TRUE(notifications.Check1AndReset( | 1472 EXPECT_TRUE(notifications.Check1AndReset( |
1453 content::NOTIFICATION_NAV_ENTRY_COMMITTED)); | 1473 content::NOTIFICATION_NAV_ENTRY_COMMITTED)); |
1454 EXPECT_TRUE(details.is_in_page); | 1474 EXPECT_TRUE(details.is_in_page); |
1455 EXPECT_FALSE(details.did_replace_entry); | 1475 EXPECT_FALSE(details.did_replace_entry); |
1456 EXPECT_EQ(2, controller.GetEntryCount()); | 1476 EXPECT_EQ(2, controller.GetEntryCount()); |
1457 | 1477 |
1458 // Go back one. | 1478 // Go back one. |
1459 ViewHostMsg_FrameNavigate_Params back_params(params); | 1479 ViewHostMsg_FrameNavigate_Params back_params(params); |
1460 controller.GoBack(); | 1480 controller.GoBack(); |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1497 | 1517 |
1498 // Finally, navigate to an unrelated URL to make sure in_page is not sticky. | 1518 // Finally, navigate to an unrelated URL to make sure in_page is not sticky. |
1499 const GURL url3("http://bar"); | 1519 const GURL url3("http://bar"); |
1500 params.page_id = 2; | 1520 params.page_id = 2; |
1501 params.url = url3; | 1521 params.url = url3; |
1502 notifications.Reset(); | 1522 notifications.Reset(); |
1503 EXPECT_TRUE(controller.RendererDidNavigate(params, &details)); | 1523 EXPECT_TRUE(controller.RendererDidNavigate(params, &details)); |
1504 EXPECT_TRUE(notifications.Check1AndReset( | 1524 EXPECT_TRUE(notifications.Check1AndReset( |
1505 content::NOTIFICATION_NAV_ENTRY_COMMITTED)); | 1525 content::NOTIFICATION_NAV_ENTRY_COMMITTED)); |
1506 EXPECT_FALSE(details.is_in_page); | 1526 EXPECT_FALSE(details.is_in_page); |
| 1527 EXPECT_EQ(3, controller.GetEntryCount()); |
| 1528 EXPECT_EQ(2, controller.GetCurrentEntryIndex()); |
1507 } | 1529 } |
1508 | 1530 |
1509 TEST_F(NavigationControllerTest, InPage_Replace) { | 1531 TEST_F(NavigationControllerTest, InPage_Replace) { |
1510 NavigationControllerImpl& controller = controller_impl(); | 1532 NavigationControllerImpl& controller = controller_impl(); |
1511 TestNotificationTracker notifications; | 1533 TestNotificationTracker notifications; |
1512 RegisterForAllNavNotifications(¬ifications, &controller); | 1534 RegisterForAllNavNotifications(¬ifications, &controller); |
1513 | 1535 |
1514 // Main page. | 1536 // Main page. |
1515 const GURL url1("http://foo"); | 1537 const GURL url1("http://foo"); |
1516 test_rvh()->SendNavigate(0, url1); | 1538 test_rvh()->SendNavigate(0, url1); |
(...skipping 1322 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2839 TabNavigation nav(0, url0, GURL(), string16(), | 2861 TabNavigation nav(0, url0, GURL(), string16(), |
2840 webkit_glue::CreateHistoryStateForURL(url0), | 2862 webkit_glue::CreateHistoryStateForURL(url0), |
2841 content::PAGE_TRANSITION_LINK); | 2863 content::PAGE_TRANSITION_LINK); |
2842 session_helper_.AssertNavigationEquals(nav, | 2864 session_helper_.AssertNavigationEquals(nav, |
2843 windows_[0]->tabs[0]->navigations[0]); | 2865 windows_[0]->tabs[0]->navigations[0]); |
2844 nav.set_url(url2); | 2866 nav.set_url(url2); |
2845 session_helper_.AssertNavigationEquals(nav, | 2867 session_helper_.AssertNavigationEquals(nav, |
2846 windows_[0]->tabs[0]->navigations[1]); | 2868 windows_[0]->tabs[0]->navigations[1]); |
2847 } | 2869 } |
2848 */ | 2870 */ |
OLD | NEW |