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/basictypes.h" | 5 #include "base/basictypes.h" |
6 #include "base/bind.h" | 6 #include "base/bind.h" |
7 #include "base/file_util.h" | 7 #include "base/file_util.h" |
8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
9 #include "base/path_service.h" | 9 #include "base/path_service.h" |
10 #include "base/stl_util.h" | 10 #include "base/stl_util.h" |
(...skipping 14 matching lines...) Expand all Loading... |
25 #include "content/browser/web_contents/navigation_entry_impl.h" | 25 #include "content/browser/web_contents/navigation_entry_impl.h" |
26 #include "content/browser/web_contents/web_contents_impl.h" | 26 #include "content/browser/web_contents/web_contents_impl.h" |
27 #include "content/browser/web_contents/web_contents_screenshot_manager.h" | 27 #include "content/browser/web_contents/web_contents_screenshot_manager.h" |
28 #include "content/common/view_messages.h" | 28 #include "content/common/view_messages.h" |
29 #include "content/public/browser/navigation_details.h" | 29 #include "content/public/browser/navigation_details.h" |
30 #include "content/public/browser/notification_registrar.h" | 30 #include "content/public/browser/notification_registrar.h" |
31 #include "content/public/browser/notification_types.h" | 31 #include "content/public/browser/notification_types.h" |
32 #include "content/public/browser/render_view_host.h" | 32 #include "content/public/browser/render_view_host.h" |
33 #include "content/public/browser/render_view_host_observer.h" | 33 #include "content/public/browser/render_view_host_observer.h" |
34 #include "content/public/browser/web_contents_delegate.h" | 34 #include "content/public/browser/web_contents_delegate.h" |
| 35 #include "content/public/common/page_state.h" |
35 #include "content/public/test/mock_render_process_host.h" | 36 #include "content/public/test/mock_render_process_host.h" |
36 #include "content/public/test/test_notification_tracker.h" | 37 #include "content/public/test/test_notification_tracker.h" |
37 #include "content/public/test/test_utils.h" | 38 #include "content/public/test/test_utils.h" |
38 #include "content/test/test_web_contents.h" | 39 #include "content/test/test_web_contents.h" |
39 #include "net/base/net_util.h" | 40 #include "net/base/net_util.h" |
40 #include "skia/ext/platform_canvas.h" | 41 #include "skia/ext/platform_canvas.h" |
41 #include "testing/gtest/include/gtest/gtest.h" | 42 #include "testing/gtest/include/gtest/gtest.h" |
42 #include "webkit/glue/glue_serialize.h" | |
43 | 43 |
44 using base::Time; | 44 using base::Time; |
45 | 45 |
46 namespace { | 46 namespace { |
47 | 47 |
48 // Creates an image with a 1x1 SkBitmap of the specified |color|. | 48 // Creates an image with a 1x1 SkBitmap of the specified |color|. |
49 gfx::Image CreateImage(SkColor color) { | 49 gfx::Image CreateImage(SkColor color) { |
50 SkBitmap bitmap; | 50 SkBitmap bitmap; |
51 bitmap.setConfig(SkBitmap::kARGB_8888_Config, 1, 1); | 51 bitmap.setConfig(SkBitmap::kARGB_8888_Config, 1, 1); |
52 bitmap.allocPixels(); | 52 bitmap.allocPixels(); |
(...skipping 1433 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1486 | 1486 |
1487 ViewHostMsg_FrameNavigate_Params params; | 1487 ViewHostMsg_FrameNavigate_Params params; |
1488 params.page_id = 0; | 1488 params.page_id = 0; |
1489 params.url = url2; | 1489 params.url = url2; |
1490 params.transition = PAGE_TRANSITION_SERVER_REDIRECT; | 1490 params.transition = PAGE_TRANSITION_SERVER_REDIRECT; |
1491 params.redirects.push_back(GURL("http://foo1")); | 1491 params.redirects.push_back(GURL("http://foo1")); |
1492 params.redirects.push_back(GURL("http://foo2")); | 1492 params.redirects.push_back(GURL("http://foo2")); |
1493 params.should_update_history = false; | 1493 params.should_update_history = false; |
1494 params.gesture = NavigationGestureAuto; | 1494 params.gesture = NavigationGestureAuto; |
1495 params.is_post = false; | 1495 params.is_post = false; |
1496 params.content_state = webkit_glue::CreateHistoryStateForURL(GURL(url2)); | 1496 params.page_state = PageState::CreateFromURL(url2); |
1497 | 1497 |
1498 LoadCommittedDetails details; | 1498 LoadCommittedDetails details; |
1499 | 1499 |
1500 EXPECT_EQ(0U, notifications.size()); | 1500 EXPECT_EQ(0U, notifications.size()); |
1501 EXPECT_TRUE(controller.RendererDidNavigate(params, &details)); | 1501 EXPECT_TRUE(controller.RendererDidNavigate(params, &details)); |
1502 EXPECT_TRUE(notifications.Check1AndReset(NOTIFICATION_NAV_ENTRY_COMMITTED)); | 1502 EXPECT_TRUE(notifications.Check1AndReset(NOTIFICATION_NAV_ENTRY_COMMITTED)); |
1503 | 1503 |
1504 EXPECT_TRUE(details.type == NAVIGATION_TYPE_SAME_PAGE); | 1504 EXPECT_TRUE(details.type == NAVIGATION_TYPE_SAME_PAGE); |
1505 EXPECT_EQ(controller.GetEntryCount(), 1); | 1505 EXPECT_EQ(controller.GetEntryCount(), 1); |
1506 EXPECT_EQ(controller.GetLastCommittedEntryIndex(), 0); | 1506 EXPECT_EQ(controller.GetLastCommittedEntryIndex(), 0); |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1541 | 1541 |
1542 ViewHostMsg_FrameNavigate_Params params; | 1542 ViewHostMsg_FrameNavigate_Params params; |
1543 params.page_id = 0; | 1543 params.page_id = 0; |
1544 params.url = url2; | 1544 params.url = url2; |
1545 params.transition = PAGE_TRANSITION_SERVER_REDIRECT; | 1545 params.transition = PAGE_TRANSITION_SERVER_REDIRECT; |
1546 params.redirects.push_back(GURL("http://foo1")); | 1546 params.redirects.push_back(GURL("http://foo1")); |
1547 params.redirects.push_back(GURL("http://foo2")); | 1547 params.redirects.push_back(GURL("http://foo2")); |
1548 params.should_update_history = false; | 1548 params.should_update_history = false; |
1549 params.gesture = NavigationGestureAuto; | 1549 params.gesture = NavigationGestureAuto; |
1550 params.is_post = false; | 1550 params.is_post = false; |
1551 params.content_state = webkit_glue::CreateHistoryStateForURL(GURL(url2)); | 1551 params.page_state = PageState::CreateFromURL(url2); |
1552 | 1552 |
1553 LoadCommittedDetails details; | 1553 LoadCommittedDetails details; |
1554 | 1554 |
1555 EXPECT_EQ(0U, notifications.size()); | 1555 EXPECT_EQ(0U, notifications.size()); |
1556 EXPECT_TRUE(controller.RendererDidNavigate(params, &details)); | 1556 EXPECT_TRUE(controller.RendererDidNavigate(params, &details)); |
1557 EXPECT_TRUE(notifications.Check1AndReset(NOTIFICATION_NAV_ENTRY_COMMITTED)); | 1557 EXPECT_TRUE(notifications.Check1AndReset(NOTIFICATION_NAV_ENTRY_COMMITTED)); |
1558 | 1558 |
1559 EXPECT_TRUE(details.type == NAVIGATION_TYPE_SAME_PAGE); | 1559 EXPECT_TRUE(details.type == NAVIGATION_TYPE_SAME_PAGE); |
1560 EXPECT_EQ(controller.GetEntryCount(), 1); | 1560 EXPECT_EQ(controller.GetEntryCount(), 1); |
1561 EXPECT_EQ(controller.GetLastCommittedEntryIndex(), 0); | 1561 EXPECT_EQ(controller.GetLastCommittedEntryIndex(), 0); |
(...skipping 25 matching lines...) Expand all Loading... |
1587 | 1587 |
1588 ViewHostMsg_FrameNavigate_Params params; | 1588 ViewHostMsg_FrameNavigate_Params params; |
1589 params.page_id = 0; | 1589 params.page_id = 0; |
1590 params.url = url2; | 1590 params.url = url2; |
1591 params.transition = PAGE_TRANSITION_SERVER_REDIRECT; | 1591 params.transition = PAGE_TRANSITION_SERVER_REDIRECT; |
1592 params.redirects.push_back(GURL("http://foo1")); | 1592 params.redirects.push_back(GURL("http://foo1")); |
1593 params.redirects.push_back(GURL("http://foo2")); | 1593 params.redirects.push_back(GURL("http://foo2")); |
1594 params.should_update_history = false; | 1594 params.should_update_history = false; |
1595 params.gesture = NavigationGestureAuto; | 1595 params.gesture = NavigationGestureAuto; |
1596 params.is_post = false; | 1596 params.is_post = false; |
1597 params.content_state = webkit_glue::CreateHistoryStateForURL(GURL(url2)); | 1597 params.page_state = PageState::CreateFromURL(url2); |
1598 | 1598 |
1599 LoadCommittedDetails details; | 1599 LoadCommittedDetails details; |
1600 | 1600 |
1601 EXPECT_EQ(0U, notifications.size()); | 1601 EXPECT_EQ(0U, notifications.size()); |
1602 EXPECT_TRUE(controller.RendererDidNavigate(params, &details)); | 1602 EXPECT_TRUE(controller.RendererDidNavigate(params, &details)); |
1603 EXPECT_TRUE(notifications.Check1AndReset(NOTIFICATION_NAV_ENTRY_COMMITTED)); | 1603 EXPECT_TRUE(notifications.Check1AndReset(NOTIFICATION_NAV_ENTRY_COMMITTED)); |
1604 | 1604 |
1605 EXPECT_TRUE(details.type == NAVIGATION_TYPE_NEW_PAGE); | 1605 EXPECT_TRUE(details.type == NAVIGATION_TYPE_NEW_PAGE); |
1606 EXPECT_EQ(controller.GetEntryCount(), 1); | 1606 EXPECT_EQ(controller.GetEntryCount(), 1); |
1607 EXPECT_EQ(controller.GetLastCommittedEntryIndex(), 0); | 1607 EXPECT_EQ(controller.GetLastCommittedEntryIndex(), 0); |
(...skipping 18 matching lines...) Expand all Loading... |
1626 EXPECT_TRUE(notifications.Check1AndReset(NOTIFICATION_NAV_ENTRY_COMMITTED)); | 1626 EXPECT_TRUE(notifications.Check1AndReset(NOTIFICATION_NAV_ENTRY_COMMITTED)); |
1627 | 1627 |
1628 const GURL url2("http://foo2"); | 1628 const GURL url2("http://foo2"); |
1629 ViewHostMsg_FrameNavigate_Params params; | 1629 ViewHostMsg_FrameNavigate_Params params; |
1630 params.page_id = 1; | 1630 params.page_id = 1; |
1631 params.url = url2; | 1631 params.url = url2; |
1632 params.transition = PAGE_TRANSITION_MANUAL_SUBFRAME; | 1632 params.transition = PAGE_TRANSITION_MANUAL_SUBFRAME; |
1633 params.should_update_history = false; | 1633 params.should_update_history = false; |
1634 params.gesture = NavigationGestureUser; | 1634 params.gesture = NavigationGestureUser; |
1635 params.is_post = false; | 1635 params.is_post = false; |
1636 params.content_state = webkit_glue::CreateHistoryStateForURL(GURL(url2)); | 1636 params.page_state = PageState::CreateFromURL(url2); |
1637 | 1637 |
1638 LoadCommittedDetails details; | 1638 LoadCommittedDetails details; |
1639 EXPECT_TRUE(controller.RendererDidNavigate(params, &details)); | 1639 EXPECT_TRUE(controller.RendererDidNavigate(params, &details)); |
1640 EXPECT_TRUE(notifications.Check1AndReset(NOTIFICATION_NAV_ENTRY_COMMITTED)); | 1640 EXPECT_TRUE(notifications.Check1AndReset(NOTIFICATION_NAV_ENTRY_COMMITTED)); |
1641 EXPECT_EQ(url1, details.previous_url); | 1641 EXPECT_EQ(url1, details.previous_url); |
1642 EXPECT_FALSE(details.is_in_page); | 1642 EXPECT_FALSE(details.is_in_page); |
1643 EXPECT_FALSE(details.is_main_frame); | 1643 EXPECT_FALSE(details.is_main_frame); |
1644 | 1644 |
1645 // The new entry should be appended. | 1645 // The new entry should be appended. |
1646 EXPECT_EQ(2, controller.GetEntryCount()); | 1646 EXPECT_EQ(2, controller.GetEntryCount()); |
(...skipping 14 matching lines...) Expand all Loading... |
1661 | 1661 |
1662 // Navigation controller currently has no entries. | 1662 // Navigation controller currently has no entries. |
1663 const GURL url("http://foo2"); | 1663 const GURL url("http://foo2"); |
1664 ViewHostMsg_FrameNavigate_Params params; | 1664 ViewHostMsg_FrameNavigate_Params params; |
1665 params.page_id = 1; | 1665 params.page_id = 1; |
1666 params.url = url; | 1666 params.url = url; |
1667 params.transition = PAGE_TRANSITION_AUTO_SUBFRAME; | 1667 params.transition = PAGE_TRANSITION_AUTO_SUBFRAME; |
1668 params.should_update_history = false; | 1668 params.should_update_history = false; |
1669 params.gesture = NavigationGestureAuto; | 1669 params.gesture = NavigationGestureAuto; |
1670 params.is_post = false; | 1670 params.is_post = false; |
1671 params.content_state = webkit_glue::CreateHistoryStateForURL(GURL(url)); | 1671 params.page_state = PageState::CreateFromURL(url); |
1672 | 1672 |
1673 LoadCommittedDetails details; | 1673 LoadCommittedDetails details; |
1674 EXPECT_FALSE(controller.RendererDidNavigate(params, &details)); | 1674 EXPECT_FALSE(controller.RendererDidNavigate(params, &details)); |
1675 EXPECT_EQ(0U, notifications.size()); | 1675 EXPECT_EQ(0U, notifications.size()); |
1676 } | 1676 } |
1677 | 1677 |
1678 // Auto subframes are ones the page loads automatically like ads. They should | 1678 // Auto subframes are ones the page loads automatically like ads. They should |
1679 // not create new navigation entries. | 1679 // not create new navigation entries. |
1680 TEST_F(NavigationControllerTest, AutoSubframe) { | 1680 TEST_F(NavigationControllerTest, AutoSubframe) { |
1681 NavigationControllerImpl& controller = controller_impl(); | 1681 NavigationControllerImpl& controller = controller_impl(); |
1682 TestNotificationTracker notifications; | 1682 TestNotificationTracker notifications; |
1683 RegisterForAllNavNotifications(¬ifications, &controller); | 1683 RegisterForAllNavNotifications(¬ifications, &controller); |
1684 | 1684 |
1685 const GURL url1("http://foo1"); | 1685 const GURL url1("http://foo1"); |
1686 test_rvh()->SendNavigate(0, url1); | 1686 test_rvh()->SendNavigate(0, url1); |
1687 EXPECT_TRUE(notifications.Check1AndReset(NOTIFICATION_NAV_ENTRY_COMMITTED)); | 1687 EXPECT_TRUE(notifications.Check1AndReset(NOTIFICATION_NAV_ENTRY_COMMITTED)); |
1688 | 1688 |
1689 const GURL url2("http://foo2"); | 1689 const GURL url2("http://foo2"); |
1690 ViewHostMsg_FrameNavigate_Params params; | 1690 ViewHostMsg_FrameNavigate_Params params; |
1691 params.page_id = 0; | 1691 params.page_id = 0; |
1692 params.url = url2; | 1692 params.url = url2; |
1693 params.transition = PAGE_TRANSITION_AUTO_SUBFRAME; | 1693 params.transition = PAGE_TRANSITION_AUTO_SUBFRAME; |
1694 params.should_update_history = false; | 1694 params.should_update_history = false; |
1695 params.gesture = NavigationGestureUser; | 1695 params.gesture = NavigationGestureUser; |
1696 params.is_post = false; | 1696 params.is_post = false; |
1697 params.content_state = webkit_glue::CreateHistoryStateForURL(GURL(url2)); | 1697 params.page_state = PageState::CreateFromURL(url2); |
1698 | 1698 |
1699 // Navigating should do nothing. | 1699 // Navigating should do nothing. |
1700 LoadCommittedDetails details; | 1700 LoadCommittedDetails details; |
1701 EXPECT_FALSE(controller.RendererDidNavigate(params, &details)); | 1701 EXPECT_FALSE(controller.RendererDidNavigate(params, &details)); |
1702 EXPECT_EQ(0U, notifications.size()); | 1702 EXPECT_EQ(0U, notifications.size()); |
1703 | 1703 |
1704 // There should still be only one entry. | 1704 // There should still be only one entry. |
1705 EXPECT_EQ(1, controller.GetEntryCount()); | 1705 EXPECT_EQ(1, controller.GetEntryCount()); |
1706 } | 1706 } |
1707 | 1707 |
(...skipping 10 matching lines...) Expand all Loading... |
1718 | 1718 |
1719 // First manual subframe navigation. | 1719 // First manual subframe navigation. |
1720 const GURL url2("http://foo2"); | 1720 const GURL url2("http://foo2"); |
1721 ViewHostMsg_FrameNavigate_Params params; | 1721 ViewHostMsg_FrameNavigate_Params params; |
1722 params.page_id = 1; | 1722 params.page_id = 1; |
1723 params.url = url2; | 1723 params.url = url2; |
1724 params.transition = PAGE_TRANSITION_MANUAL_SUBFRAME; | 1724 params.transition = PAGE_TRANSITION_MANUAL_SUBFRAME; |
1725 params.should_update_history = false; | 1725 params.should_update_history = false; |
1726 params.gesture = NavigationGestureUser; | 1726 params.gesture = NavigationGestureUser; |
1727 params.is_post = false; | 1727 params.is_post = false; |
1728 params.content_state = webkit_glue::CreateHistoryStateForURL(GURL(url2)); | 1728 params.page_state = PageState::CreateFromURL(url2); |
1729 | 1729 |
1730 // This should generate a new entry. | 1730 // This should generate a new entry. |
1731 LoadCommittedDetails details; | 1731 LoadCommittedDetails details; |
1732 EXPECT_TRUE(controller.RendererDidNavigate(params, &details)); | 1732 EXPECT_TRUE(controller.RendererDidNavigate(params, &details)); |
1733 EXPECT_TRUE(notifications.Check1AndReset(NOTIFICATION_NAV_ENTRY_COMMITTED)); | 1733 EXPECT_TRUE(notifications.Check1AndReset(NOTIFICATION_NAV_ENTRY_COMMITTED)); |
1734 EXPECT_EQ(2, controller.GetEntryCount()); | 1734 EXPECT_EQ(2, controller.GetEntryCount()); |
1735 | 1735 |
1736 // Second manual subframe navigation should also make a new entry. | 1736 // Second manual subframe navigation should also make a new entry. |
1737 const GURL url3("http://foo3"); | 1737 const GURL url3("http://foo3"); |
1738 params.page_id = 2; | 1738 params.page_id = 2; |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1801 | 1801 |
1802 // Ensure main page navigation to same url respects the was_within_same_page | 1802 // Ensure main page navigation to same url respects the was_within_same_page |
1803 // hint provided in the params. | 1803 // hint provided in the params. |
1804 ViewHostMsg_FrameNavigate_Params self_params; | 1804 ViewHostMsg_FrameNavigate_Params self_params; |
1805 self_params.page_id = 0; | 1805 self_params.page_id = 0; |
1806 self_params.url = url1; | 1806 self_params.url = url1; |
1807 self_params.transition = PAGE_TRANSITION_LINK; | 1807 self_params.transition = PAGE_TRANSITION_LINK; |
1808 self_params.should_update_history = false; | 1808 self_params.should_update_history = false; |
1809 self_params.gesture = NavigationGestureUser; | 1809 self_params.gesture = NavigationGestureUser; |
1810 self_params.is_post = false; | 1810 self_params.is_post = false; |
1811 self_params.content_state = webkit_glue::CreateHistoryStateForURL(GURL(url1)); | 1811 self_params.page_state = PageState::CreateFromURL(url1); |
1812 self_params.was_within_same_page = true; | 1812 self_params.was_within_same_page = true; |
1813 | 1813 |
1814 LoadCommittedDetails details; | 1814 LoadCommittedDetails details; |
1815 EXPECT_TRUE(controller.RendererDidNavigate(self_params, &details)); | 1815 EXPECT_TRUE(controller.RendererDidNavigate(self_params, &details)); |
1816 EXPECT_TRUE(notifications.Check1AndReset(NOTIFICATION_NAV_ENTRY_COMMITTED)); | 1816 EXPECT_TRUE(notifications.Check1AndReset(NOTIFICATION_NAV_ENTRY_COMMITTED)); |
1817 EXPECT_TRUE(details.is_in_page); | 1817 EXPECT_TRUE(details.is_in_page); |
1818 EXPECT_TRUE(details.did_replace_entry); | 1818 EXPECT_TRUE(details.did_replace_entry); |
1819 EXPECT_EQ(1, controller.GetEntryCount()); | 1819 EXPECT_EQ(1, controller.GetEntryCount()); |
1820 | 1820 |
1821 // Fragment navigation to a new page_id. | 1821 // Fragment navigation to a new page_id. |
1822 const GURL url2("http://foo#a"); | 1822 const GURL url2("http://foo#a"); |
1823 ViewHostMsg_FrameNavigate_Params params; | 1823 ViewHostMsg_FrameNavigate_Params params; |
1824 params.page_id = 1; | 1824 params.page_id = 1; |
1825 params.url = url2; | 1825 params.url = url2; |
1826 params.transition = PAGE_TRANSITION_LINK; | 1826 params.transition = PAGE_TRANSITION_LINK; |
1827 params.should_update_history = false; | 1827 params.should_update_history = false; |
1828 params.gesture = NavigationGestureUser; | 1828 params.gesture = NavigationGestureUser; |
1829 params.is_post = false; | 1829 params.is_post = false; |
1830 params.content_state = webkit_glue::CreateHistoryStateForURL(GURL(url2)); | 1830 params.page_state = PageState::CreateFromURL(url2); |
1831 | 1831 |
1832 // This should generate a new entry. | 1832 // This should generate a new entry. |
1833 EXPECT_TRUE(controller.RendererDidNavigate(params, &details)); | 1833 EXPECT_TRUE(controller.RendererDidNavigate(params, &details)); |
1834 EXPECT_TRUE(notifications.Check1AndReset(NOTIFICATION_NAV_ENTRY_COMMITTED)); | 1834 EXPECT_TRUE(notifications.Check1AndReset(NOTIFICATION_NAV_ENTRY_COMMITTED)); |
1835 EXPECT_TRUE(details.is_in_page); | 1835 EXPECT_TRUE(details.is_in_page); |
1836 EXPECT_FALSE(details.did_replace_entry); | 1836 EXPECT_FALSE(details.did_replace_entry); |
1837 EXPECT_EQ(2, controller.GetEntryCount()); | 1837 EXPECT_EQ(2, controller.GetEntryCount()); |
1838 | 1838 |
1839 // Go back one. | 1839 // Go back one. |
1840 ViewHostMsg_FrameNavigate_Params back_params(params); | 1840 ViewHostMsg_FrameNavigate_Params back_params(params); |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1898 | 1898 |
1899 // First navigation. | 1899 // First navigation. |
1900 const GURL url2("http://foo#a"); | 1900 const GURL url2("http://foo#a"); |
1901 ViewHostMsg_FrameNavigate_Params params; | 1901 ViewHostMsg_FrameNavigate_Params params; |
1902 params.page_id = 0; // Same page_id | 1902 params.page_id = 0; // Same page_id |
1903 params.url = url2; | 1903 params.url = url2; |
1904 params.transition = PAGE_TRANSITION_LINK; | 1904 params.transition = PAGE_TRANSITION_LINK; |
1905 params.should_update_history = false; | 1905 params.should_update_history = false; |
1906 params.gesture = NavigationGestureUser; | 1906 params.gesture = NavigationGestureUser; |
1907 params.is_post = false; | 1907 params.is_post = false; |
1908 params.content_state = webkit_glue::CreateHistoryStateForURL(GURL(url2)); | 1908 params.page_state = PageState::CreateFromURL(url2); |
1909 | 1909 |
1910 // This should NOT generate a new entry, nor prune the list. | 1910 // This should NOT generate a new entry, nor prune the list. |
1911 LoadCommittedDetails details; | 1911 LoadCommittedDetails details; |
1912 EXPECT_TRUE(controller.RendererDidNavigate(params, &details)); | 1912 EXPECT_TRUE(controller.RendererDidNavigate(params, &details)); |
1913 EXPECT_TRUE(notifications.Check1AndReset(NOTIFICATION_NAV_ENTRY_COMMITTED)); | 1913 EXPECT_TRUE(notifications.Check1AndReset(NOTIFICATION_NAV_ENTRY_COMMITTED)); |
1914 EXPECT_TRUE(details.is_in_page); | 1914 EXPECT_TRUE(details.is_in_page); |
1915 EXPECT_TRUE(details.did_replace_entry); | 1915 EXPECT_TRUE(details.did_replace_entry); |
1916 EXPECT_EQ(1, controller.GetEntryCount()); | 1916 EXPECT_EQ(1, controller.GetEntryCount()); |
1917 } | 1917 } |
1918 | 1918 |
(...skipping 26 matching lines...) Expand all Loading... |
1945 { | 1945 { |
1946 const GURL url("http://foo2/#a"); | 1946 const GURL url("http://foo2/#a"); |
1947 ViewHostMsg_FrameNavigate_Params params; | 1947 ViewHostMsg_FrameNavigate_Params params; |
1948 params.page_id = 1; // Same page_id | 1948 params.page_id = 1; // Same page_id |
1949 params.url = url; | 1949 params.url = url; |
1950 params.transition = PAGE_TRANSITION_LINK; | 1950 params.transition = PAGE_TRANSITION_LINK; |
1951 params.redirects.push_back(url); | 1951 params.redirects.push_back(url); |
1952 params.should_update_history = true; | 1952 params.should_update_history = true; |
1953 params.gesture = NavigationGestureUnknown; | 1953 params.gesture = NavigationGestureUnknown; |
1954 params.is_post = false; | 1954 params.is_post = false; |
1955 params.content_state = webkit_glue::CreateHistoryStateForURL(GURL(url)); | 1955 params.page_state = PageState::CreateFromURL(url); |
1956 | 1956 |
1957 // This should NOT generate a new entry, nor prune the list. | 1957 // This should NOT generate a new entry, nor prune the list. |
1958 LoadCommittedDetails details; | 1958 LoadCommittedDetails details; |
1959 EXPECT_TRUE(controller.RendererDidNavigate(params, &details)); | 1959 EXPECT_TRUE(controller.RendererDidNavigate(params, &details)); |
1960 EXPECT_TRUE(notifications.Check1AndReset(NOTIFICATION_NAV_ENTRY_COMMITTED)); | 1960 EXPECT_TRUE(notifications.Check1AndReset(NOTIFICATION_NAV_ENTRY_COMMITTED)); |
1961 EXPECT_TRUE(details.is_in_page); | 1961 EXPECT_TRUE(details.is_in_page); |
1962 EXPECT_TRUE(details.did_replace_entry); | 1962 EXPECT_TRUE(details.did_replace_entry); |
1963 EXPECT_EQ(2, controller.GetEntryCount()); | 1963 EXPECT_EQ(2, controller.GetEntryCount()); |
1964 } | 1964 } |
1965 | 1965 |
1966 // Perform a client redirect to a new page. | 1966 // Perform a client redirect to a new page. |
1967 { | 1967 { |
1968 const GURL url("http://foo3/"); | 1968 const GURL url("http://foo3/"); |
1969 ViewHostMsg_FrameNavigate_Params params; | 1969 ViewHostMsg_FrameNavigate_Params params; |
1970 params.page_id = 2; // New page_id | 1970 params.page_id = 2; // New page_id |
1971 params.url = url; | 1971 params.url = url; |
1972 params.transition = PAGE_TRANSITION_CLIENT_REDIRECT; | 1972 params.transition = PAGE_TRANSITION_CLIENT_REDIRECT; |
1973 params.redirects.push_back(GURL("http://foo2/#a")); | 1973 params.redirects.push_back(GURL("http://foo2/#a")); |
1974 params.redirects.push_back(url); | 1974 params.redirects.push_back(url); |
1975 params.should_update_history = true; | 1975 params.should_update_history = true; |
1976 params.gesture = NavigationGestureUnknown; | 1976 params.gesture = NavigationGestureUnknown; |
1977 params.is_post = false; | 1977 params.is_post = false; |
1978 params.content_state = webkit_glue::CreateHistoryStateForURL(GURL(url)); | 1978 params.page_state = PageState::CreateFromURL(url); |
1979 | 1979 |
1980 // This SHOULD generate a new entry. | 1980 // This SHOULD generate a new entry. |
1981 LoadCommittedDetails details; | 1981 LoadCommittedDetails details; |
1982 EXPECT_TRUE(controller.RendererDidNavigate(params, &details)); | 1982 EXPECT_TRUE(controller.RendererDidNavigate(params, &details)); |
1983 EXPECT_TRUE(notifications.Check1AndReset(NOTIFICATION_NAV_ENTRY_COMMITTED)); | 1983 EXPECT_TRUE(notifications.Check1AndReset(NOTIFICATION_NAV_ENTRY_COMMITTED)); |
1984 EXPECT_FALSE(details.is_in_page); | 1984 EXPECT_FALSE(details.is_in_page); |
1985 EXPECT_EQ(3, controller.GetEntryCount()); | 1985 EXPECT_EQ(3, controller.GetEntryCount()); |
1986 } | 1986 } |
1987 | 1987 |
1988 // Verify that BACK brings us back to http://foo2/. | 1988 // Verify that BACK brings us back to http://foo2/. |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2086 // SiteInstance for the entries created initially. | 2086 // SiteInstance for the entries created initially. |
2087 TEST_F(NavigationControllerTest, RestoreNavigate) { | 2087 TEST_F(NavigationControllerTest, RestoreNavigate) { |
2088 // Create a NavigationController with a restored set of tabs. | 2088 // Create a NavigationController with a restored set of tabs. |
2089 GURL url("http://foo"); | 2089 GURL url("http://foo"); |
2090 std::vector<NavigationEntry*> entries; | 2090 std::vector<NavigationEntry*> entries; |
2091 NavigationEntry* entry = NavigationControllerImpl::CreateNavigationEntry( | 2091 NavigationEntry* entry = NavigationControllerImpl::CreateNavigationEntry( |
2092 url, Referrer(), PAGE_TRANSITION_RELOAD, false, std::string(), | 2092 url, Referrer(), PAGE_TRANSITION_RELOAD, false, std::string(), |
2093 browser_context()); | 2093 browser_context()); |
2094 entry->SetPageID(0); | 2094 entry->SetPageID(0); |
2095 entry->SetTitle(ASCIIToUTF16("Title")); | 2095 entry->SetTitle(ASCIIToUTF16("Title")); |
2096 entry->SetContentState("state"); | 2096 entry->SetPageState(PageState::CreateFromEncodedData("state")); |
2097 const base::Time timestamp = base::Time::Now(); | 2097 const base::Time timestamp = base::Time::Now(); |
2098 entry->SetTimestamp(timestamp); | 2098 entry->SetTimestamp(timestamp); |
2099 entries.push_back(entry); | 2099 entries.push_back(entry); |
2100 scoped_ptr<WebContentsImpl> our_contents(static_cast<WebContentsImpl*>( | 2100 scoped_ptr<WebContentsImpl> our_contents(static_cast<WebContentsImpl*>( |
2101 WebContents::Create(WebContents::CreateParams(browser_context())))); | 2101 WebContents::Create(WebContents::CreateParams(browser_context())))); |
2102 NavigationControllerImpl& our_controller = our_contents->GetController(); | 2102 NavigationControllerImpl& our_controller = our_contents->GetController(); |
2103 our_controller.Restore( | 2103 our_controller.Restore( |
2104 0, | 2104 0, |
2105 NavigationController::RESTORE_LAST_SESSION_EXITED_CLEANLY, | 2105 NavigationController::RESTORE_LAST_SESSION_EXITED_CLEANLY, |
2106 &entries); | 2106 &entries); |
(...skipping 25 matching lines...) Expand all Loading... |
2132 EXPECT_EQ(timestamp, our_controller.GetEntryAtIndex(0)->GetTimestamp()); | 2132 EXPECT_EQ(timestamp, our_controller.GetEntryAtIndex(0)->GetTimestamp()); |
2133 | 2133 |
2134 // Say we navigated to that entry. | 2134 // Say we navigated to that entry. |
2135 ViewHostMsg_FrameNavigate_Params params; | 2135 ViewHostMsg_FrameNavigate_Params params; |
2136 params.page_id = 0; | 2136 params.page_id = 0; |
2137 params.url = url; | 2137 params.url = url; |
2138 params.transition = PAGE_TRANSITION_LINK; | 2138 params.transition = PAGE_TRANSITION_LINK; |
2139 params.should_update_history = false; | 2139 params.should_update_history = false; |
2140 params.gesture = NavigationGestureUser; | 2140 params.gesture = NavigationGestureUser; |
2141 params.is_post = false; | 2141 params.is_post = false; |
2142 params.content_state = webkit_glue::CreateHistoryStateForURL(GURL(url)); | 2142 params.page_state = PageState::CreateFromURL(url); |
2143 LoadCommittedDetails details; | 2143 LoadCommittedDetails details; |
2144 our_controller.RendererDidNavigate(params, &details); | 2144 our_controller.RendererDidNavigate(params, &details); |
2145 | 2145 |
2146 // There should be no longer any pending entry and one committed one. This | 2146 // There should be no longer any pending entry and one committed one. This |
2147 // means that we were able to locate the entry, assign its site instance, and | 2147 // means that we were able to locate the entry, assign its site instance, and |
2148 // commit it properly. | 2148 // commit it properly. |
2149 EXPECT_EQ(1, our_controller.GetEntryCount()); | 2149 EXPECT_EQ(1, our_controller.GetEntryCount()); |
2150 EXPECT_EQ(0, our_controller.GetLastCommittedEntryIndex()); | 2150 EXPECT_EQ(0, our_controller.GetLastCommittedEntryIndex()); |
2151 EXPECT_FALSE(our_controller.GetPendingEntry()); | 2151 EXPECT_FALSE(our_controller.GetPendingEntry()); |
2152 EXPECT_EQ(url, | 2152 EXPECT_EQ(url, |
(...skipping 12 matching lines...) Expand all Loading... |
2165 // navigation fails and clears the pending entry. http://crbug.com/90085 | 2165 // navigation fails and clears the pending entry. http://crbug.com/90085 |
2166 TEST_F(NavigationControllerTest, RestoreNavigateAfterFailure) { | 2166 TEST_F(NavigationControllerTest, RestoreNavigateAfterFailure) { |
2167 // Create a NavigationController with a restored set of tabs. | 2167 // Create a NavigationController with a restored set of tabs. |
2168 GURL url("http://foo"); | 2168 GURL url("http://foo"); |
2169 std::vector<NavigationEntry*> entries; | 2169 std::vector<NavigationEntry*> entries; |
2170 NavigationEntry* entry = NavigationControllerImpl::CreateNavigationEntry( | 2170 NavigationEntry* entry = NavigationControllerImpl::CreateNavigationEntry( |
2171 url, Referrer(), PAGE_TRANSITION_RELOAD, false, std::string(), | 2171 url, Referrer(), PAGE_TRANSITION_RELOAD, false, std::string(), |
2172 browser_context()); | 2172 browser_context()); |
2173 entry->SetPageID(0); | 2173 entry->SetPageID(0); |
2174 entry->SetTitle(ASCIIToUTF16("Title")); | 2174 entry->SetTitle(ASCIIToUTF16("Title")); |
2175 entry->SetContentState("state"); | 2175 entry->SetPageState(PageState::CreateFromEncodedData("state")); |
2176 entries.push_back(entry); | 2176 entries.push_back(entry); |
2177 scoped_ptr<WebContentsImpl> our_contents(static_cast<WebContentsImpl*>( | 2177 scoped_ptr<WebContentsImpl> our_contents(static_cast<WebContentsImpl*>( |
2178 WebContents::Create(WebContents::CreateParams(browser_context())))); | 2178 WebContents::Create(WebContents::CreateParams(browser_context())))); |
2179 NavigationControllerImpl& our_controller = our_contents->GetController(); | 2179 NavigationControllerImpl& our_controller = our_contents->GetController(); |
2180 our_controller.Restore( | 2180 our_controller.Restore( |
2181 0, NavigationController::RESTORE_LAST_SESSION_EXITED_CLEANLY, &entries); | 2181 0, NavigationController::RESTORE_LAST_SESSION_EXITED_CLEANLY, &entries); |
2182 ASSERT_EQ(0u, entries.size()); | 2182 ASSERT_EQ(0u, entries.size()); |
2183 | 2183 |
2184 // Before navigating to the restored entry, it should have a restore_type | 2184 // Before navigating to the restored entry, it should have a restore_type |
2185 // and no SiteInstance. | 2185 // and no SiteInstance. |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2218 fail_load_params)); | 2218 fail_load_params)); |
2219 | 2219 |
2220 // Now the pending restored entry commits. | 2220 // Now the pending restored entry commits. |
2221 ViewHostMsg_FrameNavigate_Params params; | 2221 ViewHostMsg_FrameNavigate_Params params; |
2222 params.page_id = 0; | 2222 params.page_id = 0; |
2223 params.url = url; | 2223 params.url = url; |
2224 params.transition = PAGE_TRANSITION_LINK; | 2224 params.transition = PAGE_TRANSITION_LINK; |
2225 params.should_update_history = false; | 2225 params.should_update_history = false; |
2226 params.gesture = NavigationGestureUser; | 2226 params.gesture = NavigationGestureUser; |
2227 params.is_post = false; | 2227 params.is_post = false; |
2228 params.content_state = webkit_glue::CreateHistoryStateForURL(GURL(url)); | 2228 params.page_state = PageState::CreateFromURL(url); |
2229 LoadCommittedDetails details; | 2229 LoadCommittedDetails details; |
2230 our_controller.RendererDidNavigate(params, &details); | 2230 our_controller.RendererDidNavigate(params, &details); |
2231 | 2231 |
2232 // There should be no pending entry and one committed one. | 2232 // There should be no pending entry and one committed one. |
2233 EXPECT_EQ(1, our_controller.GetEntryCount()); | 2233 EXPECT_EQ(1, our_controller.GetEntryCount()); |
2234 EXPECT_EQ(0, our_controller.GetLastCommittedEntryIndex()); | 2234 EXPECT_EQ(0, our_controller.GetLastCommittedEntryIndex()); |
2235 EXPECT_FALSE(our_controller.GetPendingEntry()); | 2235 EXPECT_FALSE(our_controller.GetPendingEntry()); |
2236 EXPECT_EQ(url, | 2236 EXPECT_EQ(url, |
2237 NavigationEntryImpl::FromNavigationEntry( | 2237 NavigationEntryImpl::FromNavigationEntry( |
2238 our_controller.GetLastCommittedEntry())->site_instance()-> | 2238 our_controller.GetLastCommittedEntry())->site_instance()-> |
(...skipping 348 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2587 | 2587 |
2588 // Navigate a subframe that would normally count as in-page. | 2588 // Navigate a subframe that would normally count as in-page. |
2589 const GURL subframe("http://www.google.com/#"); | 2589 const GURL subframe("http://www.google.com/#"); |
2590 ViewHostMsg_FrameNavigate_Params params; | 2590 ViewHostMsg_FrameNavigate_Params params; |
2591 params.page_id = 0; | 2591 params.page_id = 0; |
2592 params.url = subframe; | 2592 params.url = subframe; |
2593 params.transition = PAGE_TRANSITION_AUTO_SUBFRAME; | 2593 params.transition = PAGE_TRANSITION_AUTO_SUBFRAME; |
2594 params.should_update_history = false; | 2594 params.should_update_history = false; |
2595 params.gesture = NavigationGestureAuto; | 2595 params.gesture = NavigationGestureAuto; |
2596 params.is_post = false; | 2596 params.is_post = false; |
2597 params.content_state = webkit_glue::CreateHistoryStateForURL(GURL(subframe)); | 2597 params.page_state = PageState::CreateFromURL(subframe); |
2598 LoadCommittedDetails details; | 2598 LoadCommittedDetails details; |
2599 EXPECT_FALSE(controller.RendererDidNavigate(params, &details)); | 2599 EXPECT_FALSE(controller.RendererDidNavigate(params, &details)); |
2600 | 2600 |
2601 // Nothing should have changed. | 2601 // Nothing should have changed. |
2602 EXPECT_EQ(controller.GetEntryCount(), 1); | 2602 EXPECT_EQ(controller.GetEntryCount(), 1); |
2603 EXPECT_EQ(controller.GetLastCommittedEntryIndex(), 0); | 2603 EXPECT_EQ(controller.GetLastCommittedEntryIndex(), 0); |
2604 } | 2604 } |
2605 | 2605 |
2606 // Make sure that on cloning a WebContentsImpl and going back needs_reload is | 2606 // Make sure that on cloning a WebContentsImpl and going back needs_reload is |
2607 // false. | 2607 // false. |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2657 // Send a subframe update from the first page, as if one had just | 2657 // Send a subframe update from the first page, as if one had just |
2658 // automatically loaded. Auto subframes don't increment the page ID. | 2658 // automatically loaded. Auto subframes don't increment the page ID. |
2659 const GURL url1_sub("http://foo/subframe"); | 2659 const GURL url1_sub("http://foo/subframe"); |
2660 ViewHostMsg_FrameNavigate_Params params; | 2660 ViewHostMsg_FrameNavigate_Params params; |
2661 params.page_id = controller.GetLastCommittedEntry()->GetPageID(); | 2661 params.page_id = controller.GetLastCommittedEntry()->GetPageID(); |
2662 params.url = url1_sub; | 2662 params.url = url1_sub; |
2663 params.transition = PAGE_TRANSITION_AUTO_SUBFRAME; | 2663 params.transition = PAGE_TRANSITION_AUTO_SUBFRAME; |
2664 params.should_update_history = false; | 2664 params.should_update_history = false; |
2665 params.gesture = NavigationGestureAuto; | 2665 params.gesture = NavigationGestureAuto; |
2666 params.is_post = false; | 2666 params.is_post = false; |
2667 params.content_state = webkit_glue::CreateHistoryStateForURL(GURL(url1_sub)); | 2667 params.page_state = PageState::CreateFromURL(url1_sub); |
2668 LoadCommittedDetails details; | 2668 LoadCommittedDetails details; |
2669 | 2669 |
2670 // This should return false meaning that nothing was actually updated. | 2670 // This should return false meaning that nothing was actually updated. |
2671 EXPECT_FALSE(controller.RendererDidNavigate(params, &details)); | 2671 EXPECT_FALSE(controller.RendererDidNavigate(params, &details)); |
2672 | 2672 |
2673 // The notification should have updated the last committed one, and not | 2673 // The notification should have updated the last committed one, and not |
2674 // the pending load. | 2674 // the pending load. |
2675 EXPECT_EQ(url1, controller.GetLastCommittedEntry()->GetURL()); | 2675 EXPECT_EQ(url1, controller.GetLastCommittedEntry()->GetURL()); |
2676 | 2676 |
2677 // The active entry should be unchanged by the subframe load. | 2677 // The active entry should be unchanged by the subframe load. |
(...skipping 868 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3546 PAGE_TRANSITION_LINK); | 3546 PAGE_TRANSITION_LINK); |
3547 session_helper_.AssertNavigationEquals(nav, | 3547 session_helper_.AssertNavigationEquals(nav, |
3548 windows_[0]->tabs[0]->navigations[0]); | 3548 windows_[0]->tabs[0]->navigations[0]); |
3549 nav.set_url(url2); | 3549 nav.set_url(url2); |
3550 session_helper_.AssertNavigationEquals(nav, | 3550 session_helper_.AssertNavigationEquals(nav, |
3551 windows_[0]->tabs[0]->navigations[1]); | 3551 windows_[0]->tabs[0]->navigations[1]); |
3552 } | 3552 } |
3553 */ | 3553 */ |
3554 | 3554 |
3555 } // namespace content | 3555 } // namespace content |
OLD | NEW |