OLD | NEW |
---|---|
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 <stdint.h> | 7 #include <stdint.h> |
8 #include <algorithm> | 8 #include <algorithm> |
9 #include <utility> | 9 #include <utility> |
10 #include <vector> | 10 #include <vector> |
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
192 // Load data, not loaddatawithbaseurl. | 192 // Load data, not loaddatawithbaseurl. |
193 EXPECT_TRUE(NavigateToURL(shell(), data_url2)); | 193 EXPECT_TRUE(NavigateToURL(shell(), data_url2)); |
194 same_tab_observer.Wait(); | 194 same_tab_observer.Wait(); |
195 } | 195 } |
196 | 196 |
197 // Go back. | 197 // Go back. |
198 TestNavigationObserver back_load_observer(shell()->web_contents()); | 198 TestNavigationObserver back_load_observer(shell()->web_contents()); |
199 controller.GoBack(); | 199 controller.GoBack(); |
200 back_load_observer.Wait(); | 200 back_load_observer.Wait(); |
201 | 201 |
202 // Check title. | 202 // Check title. We should load the data URL when going back. |
203 // TODO(creis): The default navigation path incorrectly loads the history_url | 203 EXPECT_EQ("One", base::UTF16ToUTF8(shell()->web_contents()->GetTitle())); |
204 // and claims it loaded the data_url (due to a bug where GoToEntry does not | |
205 // handle this case). This is confusing. When using subframe | |
206 // FrameNavigationEntries, we load the data URL when going back, as expected. | |
207 if (SiteIsolationPolicy::UseSubframeNavigationEntries()) | |
208 EXPECT_EQ("One", base::UTF16ToUTF8(shell()->web_contents()->GetTitle())); | |
209 else | |
210 EXPECT_EQ("form", base::UTF16ToUTF8(shell()->web_contents()->GetTitle())); | |
211 | 204 |
212 // Verify the last committed NavigationEntry. | 205 // Verify the last committed NavigationEntry. |
213 NavigationEntryImpl* back_entry = controller.GetLastCommittedEntry(); | 206 NavigationEntryImpl* back_entry = controller.GetLastCommittedEntry(); |
214 EXPECT_EQ(base_url, back_entry->GetBaseURLForDataURL()); | 207 EXPECT_EQ(base_url, back_entry->GetBaseURLForDataURL()); |
215 EXPECT_EQ(history_url, back_entry->GetVirtualURL()); | 208 EXPECT_EQ(history_url, back_entry->GetVirtualURL()); |
216 EXPECT_EQ(history_url, back_entry->GetHistoryURLForDataURL()); | 209 EXPECT_EQ(history_url, back_entry->GetHistoryURLForDataURL()); |
217 EXPECT_EQ(data_url1, back_entry->GetOriginalRequestURL()); | 210 EXPECT_EQ(data_url1, back_entry->GetOriginalRequestURL()); |
218 EXPECT_EQ(data_url1, back_entry->GetURL()); | 211 EXPECT_EQ(data_url1, back_entry->GetURL()); |
219 | 212 |
220 EXPECT_EQ(data_url1, | 213 EXPECT_EQ(data_url1, |
(...skipping 1452 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1673 capturer.transition_type(), ui::PAGE_TRANSITION_AUTO_SUBFRAME)); | 1666 capturer.transition_type(), ui::PAGE_TRANSITION_AUTO_SUBFRAME)); |
1674 } | 1667 } |
1675 | 1668 |
1676 // Check last committed NavigationEntry. | 1669 // Check last committed NavigationEntry. |
1677 EXPECT_EQ(1, controller.GetEntryCount()); | 1670 EXPECT_EQ(1, controller.GetEntryCount()); |
1678 NavigationEntryImpl* entry = controller.GetLastCommittedEntry(); | 1671 NavigationEntryImpl* entry = controller.GetLastCommittedEntry(); |
1679 EXPECT_EQ(main_url, entry->GetURL()); | 1672 EXPECT_EQ(main_url, entry->GetURL()); |
1680 FrameNavigationEntry* root_entry = entry->root_node()->frame_entry.get(); | 1673 FrameNavigationEntry* root_entry = entry->root_node()->frame_entry.get(); |
1681 EXPECT_EQ(main_url, root_entry->url()); | 1674 EXPECT_EQ(main_url, root_entry->url()); |
1682 | 1675 |
1683 // Verify subframe entries if they're enabled (e.g. in --site-per-process). | 1676 // Verify subframe entries. The entry should now have one blank subframe |
1684 if (SiteIsolationPolicy::UseSubframeNavigationEntries()) { | 1677 // FrameNavigationEntry, but this does not count as committing a real load. |
1685 // The entry should now have one blank subframe FrameNavigationEntry, but | 1678 ASSERT_EQ(1U, entry->root_node()->children.size()); |
1686 // this does not count as committing a real load. | 1679 FrameNavigationEntry* frame_entry = |
1687 ASSERT_EQ(1U, entry->root_node()->children.size()); | 1680 entry->root_node()->children[0]->frame_entry.get(); |
1688 FrameNavigationEntry* frame_entry = | 1681 EXPECT_EQ(about_blank_url, frame_entry->url()); |
1689 entry->root_node()->children[0]->frame_entry.get(); | |
1690 EXPECT_EQ(about_blank_url, frame_entry->url()); | |
1691 } else { | |
1692 // There are no subframe FrameNavigationEntries by default. | |
1693 EXPECT_EQ(0U, entry->root_node()->children.size()); | |
1694 } | |
1695 EXPECT_FALSE(root->child_at(0)->has_committed_real_load()); | 1682 EXPECT_FALSE(root->child_at(0)->has_committed_real_load()); |
1696 | 1683 |
1697 // 1a. A nested iframe with no URL should also create a subframe entry but not | 1684 // 1a. A nested iframe with no URL should also create a subframe entry but not |
1698 // count as a real load. | 1685 // count as a real load. |
1699 { | 1686 { |
1700 LoadCommittedCapturer capturer(shell()->web_contents()); | 1687 LoadCommittedCapturer capturer(shell()->web_contents()); |
1701 std::string script = "var iframe = document.createElement('iframe');" | 1688 std::string script = "var iframe = document.createElement('iframe');" |
1702 "document.body.appendChild(iframe);"; | 1689 "document.body.appendChild(iframe);"; |
1703 EXPECT_TRUE(ExecuteScript(root->child_at(0), script)); | 1690 EXPECT_TRUE(ExecuteScript(root->child_at(0), script)); |
1704 capturer.Wait(); | 1691 capturer.Wait(); |
1705 EXPECT_TRUE(ui::PageTransitionTypeIncludingQualifiersIs( | 1692 EXPECT_TRUE(ui::PageTransitionTypeIncludingQualifiersIs( |
1706 capturer.transition_type(), ui::PAGE_TRANSITION_AUTO_SUBFRAME)); | 1693 capturer.transition_type(), ui::PAGE_TRANSITION_AUTO_SUBFRAME)); |
1707 } | 1694 } |
1708 | 1695 |
1709 // Verify subframe entries if they're enabled (e.g. in --site-per-process). | 1696 // Verify subframe entries. The nested entry should have one blank subframe |
1710 if (SiteIsolationPolicy::UseSubframeNavigationEntries()) { | 1697 // FrameNavigationEntry, but this does not count as committing a real load. |
1711 // The nested entry should have one blank subframe FrameNavigationEntry, but | 1698 ASSERT_EQ(1U, entry->root_node()->children[0]->children.size()); |
1712 // this does not count as committing a real load. | 1699 frame_entry = entry->root_node()->children[0]->children[0]->frame_entry.get(); |
1713 ASSERT_EQ(1U, entry->root_node()->children[0]->children.size()); | 1700 EXPECT_EQ(about_blank_url, frame_entry->url()); |
1714 FrameNavigationEntry* frame_entry = | |
1715 entry->root_node()->children[0]->children[0]->frame_entry.get(); | |
1716 EXPECT_EQ(about_blank_url, frame_entry->url()); | |
1717 } else { | |
1718 // There are no subframe FrameNavigationEntries by default. | |
1719 EXPECT_EQ(0U, entry->root_node()->children.size()); | |
1720 } | |
1721 EXPECT_FALSE(root->child_at(0)->child_at(0)->has_committed_real_load()); | 1701 EXPECT_FALSE(root->child_at(0)->child_at(0)->has_committed_real_load()); |
1722 | 1702 |
1723 // 2. Create another iframe with an explicit about:blank URL. | 1703 // 2. Create another iframe with an explicit about:blank URL. |
1724 { | 1704 { |
1725 LoadCommittedCapturer capturer(shell()->web_contents()); | 1705 LoadCommittedCapturer capturer(shell()->web_contents()); |
1726 std::string script = "var iframe = document.createElement('iframe');" | 1706 std::string script = "var iframe = document.createElement('iframe');" |
1727 "iframe.src = 'about:blank';" | 1707 "iframe.src = 'about:blank';" |
1728 "document.body.appendChild(iframe);"; | 1708 "document.body.appendChild(iframe);"; |
1729 EXPECT_TRUE(ExecuteScript(root, script)); | 1709 EXPECT_TRUE(ExecuteScript(root, script)); |
1730 capturer.Wait(); | 1710 capturer.Wait(); |
1731 EXPECT_TRUE(ui::PageTransitionTypeIncludingQualifiersIs( | 1711 EXPECT_TRUE(ui::PageTransitionTypeIncludingQualifiersIs( |
1732 capturer.transition_type(), ui::PAGE_TRANSITION_AUTO_SUBFRAME)); | 1712 capturer.transition_type(), ui::PAGE_TRANSITION_AUTO_SUBFRAME)); |
1733 } | 1713 } |
1734 | 1714 |
1735 // Check last committed NavigationEntry. | 1715 // Check last committed NavigationEntry. |
1736 EXPECT_EQ(1, controller.GetEntryCount()); | 1716 EXPECT_EQ(1, controller.GetEntryCount()); |
1737 EXPECT_EQ(entry, controller.GetLastCommittedEntry()); | 1717 EXPECT_EQ(entry, controller.GetLastCommittedEntry()); |
1738 | 1718 |
1739 // Verify subframe entries if they're enabled (e.g. in --site-per-process). | 1719 // Verify subframe entries. The new entry should have one blank subframe |
1740 if (SiteIsolationPolicy::UseSubframeNavigationEntries()) { | 1720 // FrameNavigationEntry, but this does not count as committing a real load. |
1741 // The new entry should have one blank subframe FrameNavigationEntry, but | 1721 ASSERT_EQ(2U, entry->root_node()->children.size()); |
1742 // this does not count as committing a real load. | 1722 frame_entry = entry->root_node()->children[1]->frame_entry.get(); |
1743 ASSERT_EQ(2U, entry->root_node()->children.size()); | 1723 EXPECT_EQ(about_blank_url, frame_entry->url()); |
1744 FrameNavigationEntry* frame_entry = | |
1745 entry->root_node()->children[1]->frame_entry.get(); | |
1746 EXPECT_EQ(about_blank_url, frame_entry->url()); | |
1747 } else { | |
1748 // There are no subframe FrameNavigationEntries by default. | |
1749 EXPECT_EQ(0U, entry->root_node()->children.size()); | |
1750 } | |
1751 EXPECT_FALSE(root->child_at(1)->has_committed_real_load()); | 1724 EXPECT_FALSE(root->child_at(1)->has_committed_real_load()); |
1752 | 1725 |
1753 // 3. A real same-site navigation in the nested iframe should be AUTO. | 1726 // 3. A real same-site navigation in the nested iframe should be AUTO. |
1754 GURL frame_url(embedded_test_server()->GetURL( | 1727 GURL frame_url(embedded_test_server()->GetURL( |
1755 "/navigation_controller/simple_page_1.html")); | 1728 "/navigation_controller/simple_page_1.html")); |
1756 { | 1729 { |
1757 LoadCommittedCapturer capturer(root->child_at(0)->child_at(0)); | 1730 LoadCommittedCapturer capturer(root->child_at(0)->child_at(0)); |
1758 std::string script = "var frames = document.getElementsByTagName('iframe');" | 1731 std::string script = "var frames = document.getElementsByTagName('iframe');" |
1759 "frames[0].src = '" + frame_url.spec() + "';"; | 1732 "frames[0].src = '" + frame_url.spec() + "';"; |
1760 EXPECT_TRUE(ExecuteScript(root->child_at(0), script)); | 1733 EXPECT_TRUE(ExecuteScript(root->child_at(0), script)); |
1761 capturer.Wait(); | 1734 capturer.Wait(); |
1762 EXPECT_TRUE(ui::PageTransitionTypeIncludingQualifiersIs( | 1735 EXPECT_TRUE(ui::PageTransitionTypeIncludingQualifiersIs( |
1763 capturer.transition_type(), ui::PAGE_TRANSITION_AUTO_SUBFRAME)); | 1736 capturer.transition_type(), ui::PAGE_TRANSITION_AUTO_SUBFRAME)); |
1764 } | 1737 } |
1765 | 1738 |
1766 // Check last committed NavigationEntry. It should have replaced the previous | 1739 // Check last committed NavigationEntry. It should have replaced the previous |
1767 // frame entry in the original NavigationEntry. | 1740 // frame entry in the original NavigationEntry. |
1768 EXPECT_EQ(1, controller.GetEntryCount()); | 1741 EXPECT_EQ(1, controller.GetEntryCount()); |
1769 EXPECT_EQ(entry, controller.GetLastCommittedEntry()); | 1742 EXPECT_EQ(entry, controller.GetLastCommittedEntry()); |
1770 | 1743 |
1771 // Verify subframe entries if they're enabled (e.g. in --site-per-process). | 1744 // The entry should still have one nested subframe FrameNavigationEntry. |
1772 if (SiteIsolationPolicy::UseSubframeNavigationEntries()) { | 1745 ASSERT_EQ(1U, entry->root_node()->children[0]->children.size()); |
1773 // The entry should still have one nested subframe FrameNavigationEntry. | 1746 frame_entry = entry->root_node()->children[0]->children[0]->frame_entry.get(); |
1774 ASSERT_EQ(1U, entry->root_node()->children[0]->children.size()); | 1747 EXPECT_EQ(frame_url, frame_entry->url()); |
1775 FrameNavigationEntry* frame_entry = | |
1776 entry->root_node()->children[0]->children[0]->frame_entry.get(); | |
1777 EXPECT_EQ(frame_url, frame_entry->url()); | |
1778 } else { | |
1779 // There are no subframe FrameNavigationEntries by default. | |
1780 EXPECT_EQ(0U, entry->root_node()->children.size()); | |
1781 } | |
1782 EXPECT_FALSE(root->child_at(0)->has_committed_real_load()); | 1748 EXPECT_FALSE(root->child_at(0)->has_committed_real_load()); |
1783 EXPECT_TRUE(root->child_at(0)->child_at(0)->has_committed_real_load()); | 1749 EXPECT_TRUE(root->child_at(0)->child_at(0)->has_committed_real_load()); |
1784 EXPECT_FALSE(root->child_at(1)->has_committed_real_load()); | 1750 EXPECT_FALSE(root->child_at(1)->has_committed_real_load()); |
1785 | 1751 |
1786 // 4. A real cross-site navigation in the second iframe should be AUTO. | 1752 // 4. A real cross-site navigation in the second iframe should be AUTO. |
1787 GURL foo_url(embedded_test_server()->GetURL( | 1753 GURL foo_url(embedded_test_server()->GetURL( |
1788 "foo.com", "/navigation_controller/simple_page_2.html")); | 1754 "foo.com", "/navigation_controller/simple_page_2.html")); |
1789 { | 1755 { |
1790 LoadCommittedCapturer capturer(root->child_at(1)); | 1756 LoadCommittedCapturer capturer(root->child_at(1)); |
1791 std::string script = "var frames = document.getElementsByTagName('iframe');" | 1757 std::string script = "var frames = document.getElementsByTagName('iframe');" |
1792 "frames[1].src = '" + foo_url.spec() + "';"; | 1758 "frames[1].src = '" + foo_url.spec() + "';"; |
1793 EXPECT_TRUE(ExecuteScript(root, script)); | 1759 EXPECT_TRUE(ExecuteScript(root, script)); |
1794 capturer.Wait(); | 1760 capturer.Wait(); |
1795 EXPECT_TRUE(ui::PageTransitionTypeIncludingQualifiersIs( | 1761 EXPECT_TRUE(ui::PageTransitionTypeIncludingQualifiersIs( |
1796 capturer.transition_type(), ui::PAGE_TRANSITION_AUTO_SUBFRAME)); | 1762 capturer.transition_type(), ui::PAGE_TRANSITION_AUTO_SUBFRAME)); |
1797 } | 1763 } |
1798 | 1764 |
1799 // Check last committed NavigationEntry. | 1765 // Check last committed NavigationEntry. |
1800 EXPECT_EQ(1, controller.GetEntryCount()); | 1766 EXPECT_EQ(1, controller.GetEntryCount()); |
1801 EXPECT_EQ(entry, controller.GetLastCommittedEntry()); | 1767 EXPECT_EQ(entry, controller.GetLastCommittedEntry()); |
1802 | 1768 |
1803 // Verify subframe entries if they're enabled (e.g. in --site-per-process). | 1769 // The entry should still have two subframe FrameNavigationEntries. |
1804 if (SiteIsolationPolicy::UseSubframeNavigationEntries()) { | 1770 ASSERT_EQ(2U, entry->root_node()->children.size()); |
1805 // The entry should still have two subframe FrameNavigationEntries. | 1771 frame_entry = entry->root_node()->children[1]->frame_entry.get(); |
1806 ASSERT_EQ(2U, entry->root_node()->children.size()); | 1772 EXPECT_EQ(foo_url, frame_entry->url()); |
1807 FrameNavigationEntry* frame_entry = | |
1808 entry->root_node()->children[1]->frame_entry.get(); | |
1809 EXPECT_EQ(foo_url, frame_entry->url()); | |
1810 } else { | |
1811 // There are no subframe FrameNavigationEntries by default. | |
1812 EXPECT_EQ(0U, entry->root_node()->children.size()); | |
1813 } | |
1814 EXPECT_FALSE(root->child_at(0)->has_committed_real_load()); | 1773 EXPECT_FALSE(root->child_at(0)->has_committed_real_load()); |
1815 EXPECT_TRUE(root->child_at(0)->child_at(0)->has_committed_real_load()); | 1774 EXPECT_TRUE(root->child_at(0)->child_at(0)->has_committed_real_load()); |
1816 EXPECT_TRUE(root->child_at(1)->has_committed_real_load()); | 1775 EXPECT_TRUE(root->child_at(1)->has_committed_real_load()); |
1817 | 1776 |
1818 // 5. A new navigation to about:blank in the nested frame should count as a | 1777 // 5. A new navigation to about:blank in the nested frame should count as a |
1819 // real load, since that frame has already committed a real load and this is | 1778 // real load, since that frame has already committed a real load and this is |
1820 // not the initial blank page. | 1779 // not the initial blank page. |
1821 { | 1780 { |
1822 LoadCommittedCapturer capturer(root->child_at(0)->child_at(0)); | 1781 LoadCommittedCapturer capturer(root->child_at(0)->child_at(0)); |
1823 std::string script = "var frames = document.getElementsByTagName('iframe');" | 1782 std::string script = "var frames = document.getElementsByTagName('iframe');" |
1824 "frames[0].src = 'about:blank';"; | 1783 "frames[0].src = 'about:blank';"; |
1825 EXPECT_TRUE(ExecuteScript(root->child_at(0), script)); | 1784 EXPECT_TRUE(ExecuteScript(root->child_at(0), script)); |
1826 capturer.Wait(); | 1785 capturer.Wait(); |
1827 EXPECT_TRUE(ui::PageTransitionTypeIncludingQualifiersIs( | 1786 EXPECT_TRUE(ui::PageTransitionTypeIncludingQualifiersIs( |
1828 capturer.transition_type(), ui::PAGE_TRANSITION_MANUAL_SUBFRAME)); | 1787 capturer.transition_type(), ui::PAGE_TRANSITION_MANUAL_SUBFRAME)); |
1829 } | 1788 } |
1830 | 1789 |
1831 // This should have created a new NavigationEntry. | 1790 // This should have created a new NavigationEntry. |
1832 EXPECT_EQ(2, controller.GetEntryCount()); | 1791 EXPECT_EQ(2, controller.GetEntryCount()); |
1833 EXPECT_NE(entry, controller.GetLastCommittedEntry()); | 1792 EXPECT_NE(entry, controller.GetLastCommittedEntry()); |
1834 NavigationEntryImpl* entry2 = controller.GetLastCommittedEntry(); | 1793 NavigationEntryImpl* entry2 = controller.GetLastCommittedEntry(); |
1835 | 1794 |
1836 // Verify subframe entries if they're enabled (e.g. in --site-per-process). | 1795 // Verify subframe entries. |
1837 if (SiteIsolationPolicy::UseSubframeNavigationEntries()) { | 1796 ASSERT_EQ(2U, entry->root_node()->children.size()); |
1838 ASSERT_EQ(2U, entry->root_node()->children.size()); | 1797 frame_entry = |
1839 FrameNavigationEntry* frame_entry = | 1798 entry2->root_node()->children[0]->children[0]->frame_entry.get(); |
1840 entry2->root_node()->children[0]->children[0]->frame_entry.get(); | 1799 EXPECT_EQ(about_blank_url, frame_entry->url()); |
1841 EXPECT_EQ(about_blank_url, frame_entry->url()); | |
1842 } else { | |
1843 // There are no subframe FrameNavigationEntries by default. | |
1844 EXPECT_EQ(0U, entry->root_node()->children.size()); | |
1845 } | |
1846 EXPECT_FALSE(root->child_at(0)->has_committed_real_load()); | 1800 EXPECT_FALSE(root->child_at(0)->has_committed_real_load()); |
1847 EXPECT_TRUE(root->child_at(0)->child_at(0)->has_committed_real_load()); | 1801 EXPECT_TRUE(root->child_at(0)->child_at(0)->has_committed_real_load()); |
1848 EXPECT_TRUE(root->child_at(1)->has_committed_real_load()); | 1802 EXPECT_TRUE(root->child_at(1)->has_committed_real_load()); |
1849 | 1803 |
1850 // Check the end result of the frame tree. | 1804 // Check the end result of the frame tree. |
1851 if (AreAllSitesIsolatedForTesting()) { | 1805 if (AreAllSitesIsolatedForTesting()) { |
1852 FrameTreeVisualizer visualizer; | 1806 FrameTreeVisualizer visualizer; |
1853 EXPECT_EQ( | 1807 EXPECT_EQ( |
1854 " Site A ------------ proxies for B\n" | 1808 " Site A ------------ proxies for B\n" |
1855 " |--Site A ------- proxies for B\n" | 1809 " |--Site A ------- proxies for B\n" |
(...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2088 } | 2042 } |
2089 | 2043 |
2090 // Check last committed NavigationEntry. | 2044 // Check last committed NavigationEntry. |
2091 EXPECT_EQ(1, controller.GetEntryCount()); | 2045 EXPECT_EQ(1, controller.GetEntryCount()); |
2092 NavigationEntryImpl* entry = controller.GetLastCommittedEntry(); | 2046 NavigationEntryImpl* entry = controller.GetLastCommittedEntry(); |
2093 EXPECT_EQ(main_url, entry->GetURL()); | 2047 EXPECT_EQ(main_url, entry->GetURL()); |
2094 FrameNavigationEntry* root_entry = entry->root_node()->frame_entry.get(); | 2048 FrameNavigationEntry* root_entry = entry->root_node()->frame_entry.get(); |
2095 EXPECT_EQ(main_url, root_entry->url()); | 2049 EXPECT_EQ(main_url, root_entry->url()); |
2096 EXPECT_FALSE(controller.GetPendingEntry()); | 2050 EXPECT_FALSE(controller.GetPendingEntry()); |
2097 | 2051 |
2098 // Verify subframe entries if they're enabled (e.g. in --site-per-process). | 2052 // The entry should now have a subframe FrameNavigationEntry. |
2099 if (SiteIsolationPolicy::UseSubframeNavigationEntries()) { | 2053 ASSERT_EQ(1U, entry->root_node()->children.size()); |
2100 // The entry should now have a subframe FrameNavigationEntry. | 2054 FrameNavigationEntry* frame_entry = |
2101 ASSERT_EQ(1U, entry->root_node()->children.size()); | 2055 entry->root_node()->children[0]->frame_entry.get(); |
2102 FrameNavigationEntry* frame_entry = | 2056 EXPECT_EQ(frame_url, frame_entry->url()); |
2103 entry->root_node()->children[0]->frame_entry.get(); | 2057 EXPECT_TRUE(root->child_at(0)->has_committed_real_load()); |
2104 EXPECT_EQ(frame_url, frame_entry->url()); | |
2105 EXPECT_TRUE(root->child_at(0)->has_committed_real_load()); | |
2106 } else { | |
2107 // There are no subframe FrameNavigationEntries by default. | |
2108 EXPECT_EQ(0U, entry->root_node()->children.size()); | |
2109 } | |
2110 | 2058 |
2111 // 2. Create a second, initially cross-site iframe. | 2059 // 2. Create a second, initially cross-site iframe. |
2112 GURL foo_url(embedded_test_server()->GetURL( | 2060 GURL foo_url(embedded_test_server()->GetURL( |
2113 "foo.com", "/navigation_controller/simple_page_1.html")); | 2061 "foo.com", "/navigation_controller/simple_page_1.html")); |
2114 { | 2062 { |
2115 LoadCommittedCapturer capturer(shell()->web_contents()); | 2063 LoadCommittedCapturer capturer(shell()->web_contents()); |
2116 std::string script = "var iframe = document.createElement('iframe');" | 2064 std::string script = "var iframe = document.createElement('iframe');" |
2117 "iframe.src = '" + foo_url.spec() + "';" | 2065 "iframe.src = '" + foo_url.spec() + "';" |
2118 "document.body.appendChild(iframe);"; | 2066 "document.body.appendChild(iframe);"; |
2119 EXPECT_TRUE(ExecuteScript(root, script)); | 2067 EXPECT_TRUE(ExecuteScript(root, script)); |
2120 capturer.Wait(); | 2068 capturer.Wait(); |
2121 EXPECT_TRUE(ui::PageTransitionTypeIncludingQualifiersIs( | 2069 EXPECT_TRUE(ui::PageTransitionTypeIncludingQualifiersIs( |
2122 capturer.transition_type(), ui::PAGE_TRANSITION_AUTO_SUBFRAME)); | 2070 capturer.transition_type(), ui::PAGE_TRANSITION_AUTO_SUBFRAME)); |
2123 } | 2071 } |
2124 | 2072 |
2125 // The last committed NavigationEntry shouldn't have changed. | 2073 // The last committed NavigationEntry shouldn't have changed. |
2126 EXPECT_EQ(1, controller.GetEntryCount()); | 2074 EXPECT_EQ(1, controller.GetEntryCount()); |
2127 entry = controller.GetLastCommittedEntry(); | 2075 entry = controller.GetLastCommittedEntry(); |
2128 EXPECT_EQ(main_url, entry->GetURL()); | 2076 EXPECT_EQ(main_url, entry->GetURL()); |
2129 root_entry = entry->root_node()->frame_entry.get(); | 2077 root_entry = entry->root_node()->frame_entry.get(); |
2130 EXPECT_EQ(main_url, root_entry->url()); | 2078 EXPECT_EQ(main_url, root_entry->url()); |
2131 EXPECT_FALSE(controller.GetPendingEntry()); | 2079 EXPECT_FALSE(controller.GetPendingEntry()); |
2132 | 2080 |
2133 // Verify subframe entries if they're enabled (e.g. in --site-per-process). | 2081 // The entry should now have 2 subframe FrameNavigationEntries. |
2134 if (SiteIsolationPolicy::UseSubframeNavigationEntries()) { | 2082 ASSERT_EQ(2U, entry->root_node()->children.size()); |
2135 // The entry should now have 2 subframe FrameNavigationEntries. | 2083 frame_entry = entry->root_node()->children[1]->frame_entry.get(); |
2136 ASSERT_EQ(2U, entry->root_node()->children.size()); | 2084 EXPECT_EQ(foo_url, frame_entry->url()); |
2137 FrameNavigationEntry* frame_entry = | 2085 EXPECT_TRUE(root->child_at(1)->has_committed_real_load()); |
2138 entry->root_node()->children[1]->frame_entry.get(); | |
2139 EXPECT_EQ(foo_url, frame_entry->url()); | |
2140 EXPECT_TRUE(root->child_at(1)->has_committed_real_load()); | |
2141 } else { | |
2142 // There are no subframe FrameNavigationEntries by default. | |
2143 EXPECT_EQ(0U, entry->root_node()->children.size()); | |
2144 } | |
2145 | 2086 |
2146 // 3. Create a nested iframe in the second subframe. | 2087 // 3. Create a nested iframe in the second subframe. |
2147 { | 2088 { |
2148 LoadCommittedCapturer capturer(shell()->web_contents()); | 2089 LoadCommittedCapturer capturer(shell()->web_contents()); |
2149 std::string script = "var iframe = document.createElement('iframe');" | 2090 std::string script = "var iframe = document.createElement('iframe');" |
2150 "iframe.src = '" + foo_url.spec() + "';" | 2091 "iframe.src = '" + foo_url.spec() + "';" |
2151 "document.body.appendChild(iframe);"; | 2092 "document.body.appendChild(iframe);"; |
2152 EXPECT_TRUE(ExecuteScript(root->child_at(1), script)); | 2093 EXPECT_TRUE(ExecuteScript(root->child_at(1), script)); |
2153 capturer.Wait(); | 2094 capturer.Wait(); |
2154 EXPECT_TRUE(ui::PageTransitionTypeIncludingQualifiersIs( | 2095 EXPECT_TRUE(ui::PageTransitionTypeIncludingQualifiersIs( |
2155 capturer.transition_type(), ui::PAGE_TRANSITION_AUTO_SUBFRAME)); | 2096 capturer.transition_type(), ui::PAGE_TRANSITION_AUTO_SUBFRAME)); |
2156 } | 2097 } |
2157 | 2098 |
2158 // The last committed NavigationEntry shouldn't have changed. | 2099 // The last committed NavigationEntry shouldn't have changed. |
2159 EXPECT_EQ(1, controller.GetEntryCount()); | 2100 EXPECT_EQ(1, controller.GetEntryCount()); |
2160 entry = controller.GetLastCommittedEntry(); | 2101 entry = controller.GetLastCommittedEntry(); |
2161 EXPECT_EQ(main_url, entry->GetURL()); | 2102 EXPECT_EQ(main_url, entry->GetURL()); |
2162 root_entry = entry->root_node()->frame_entry.get(); | 2103 root_entry = entry->root_node()->frame_entry.get(); |
2163 EXPECT_EQ(main_url, root_entry->url()); | 2104 EXPECT_EQ(main_url, root_entry->url()); |
2164 | 2105 |
2165 // Verify subframe entries if they're enabled (e.g. in --site-per-process). | 2106 // The entry should now have 2 subframe FrameNavigationEntries. |
2166 if (SiteIsolationPolicy::UseSubframeNavigationEntries()) { | 2107 ASSERT_EQ(2U, entry->root_node()->children.size()); |
2167 // The entry should now have 2 subframe FrameNavigationEntries. | 2108 ASSERT_EQ(1U, entry->root_node()->children[1]->children.size()); |
2168 ASSERT_EQ(2U, entry->root_node()->children.size()); | 2109 frame_entry = entry->root_node()->children[1]->children[0]->frame_entry.get(); |
2169 ASSERT_EQ(1U, entry->root_node()->children[1]->children.size()); | 2110 EXPECT_EQ(foo_url, frame_entry->url()); |
2170 FrameNavigationEntry* frame_entry = | |
2171 entry->root_node()->children[1]->children[0]->frame_entry.get(); | |
2172 EXPECT_EQ(foo_url, frame_entry->url()); | |
2173 } else { | |
2174 // There are no subframe FrameNavigationEntries by default. | |
2175 EXPECT_EQ(0U, entry->root_node()->children.size()); | |
2176 } | |
2177 | 2111 |
2178 // 4. Create a third iframe on the same site as the second. This ensures that | 2112 // 4. Create a third iframe on the same site as the second. This ensures that |
2179 // the commit type is correct even when the subframe process already exists. | 2113 // the commit type is correct even when the subframe process already exists. |
2180 { | 2114 { |
2181 LoadCommittedCapturer capturer(shell()->web_contents()); | 2115 LoadCommittedCapturer capturer(shell()->web_contents()); |
2182 std::string script = "var iframe = document.createElement('iframe');" | 2116 std::string script = "var iframe = document.createElement('iframe');" |
2183 "iframe.src = '" + foo_url.spec() + "';" | 2117 "iframe.src = '" + foo_url.spec() + "';" |
2184 "document.body.appendChild(iframe);"; | 2118 "document.body.appendChild(iframe);"; |
2185 EXPECT_TRUE(ExecuteScript(root, script)); | 2119 EXPECT_TRUE(ExecuteScript(root, script)); |
2186 capturer.Wait(); | 2120 capturer.Wait(); |
2187 EXPECT_TRUE(ui::PageTransitionTypeIncludingQualifiersIs( | 2121 EXPECT_TRUE(ui::PageTransitionTypeIncludingQualifiersIs( |
2188 capturer.transition_type(), ui::PAGE_TRANSITION_AUTO_SUBFRAME)); | 2122 capturer.transition_type(), ui::PAGE_TRANSITION_AUTO_SUBFRAME)); |
2189 } | 2123 } |
2190 | 2124 |
2191 // The last committed NavigationEntry shouldn't have changed. | 2125 // The last committed NavigationEntry shouldn't have changed. |
2192 EXPECT_EQ(1, controller.GetEntryCount()); | 2126 EXPECT_EQ(1, controller.GetEntryCount()); |
2193 entry = controller.GetLastCommittedEntry(); | 2127 entry = controller.GetLastCommittedEntry(); |
2194 EXPECT_EQ(main_url, entry->GetURL()); | 2128 EXPECT_EQ(main_url, entry->GetURL()); |
2195 root_entry = entry->root_node()->frame_entry.get(); | 2129 root_entry = entry->root_node()->frame_entry.get(); |
2196 EXPECT_EQ(main_url, root_entry->url()); | 2130 EXPECT_EQ(main_url, root_entry->url()); |
2197 | 2131 |
2198 // Verify subframe entries if they're enabled (e.g. in --site-per-process). | 2132 // The entry should now have 3 subframe FrameNavigationEntries. |
2199 if (SiteIsolationPolicy::UseSubframeNavigationEntries()) { | 2133 ASSERT_EQ(3U, entry->root_node()->children.size()); |
2200 // The entry should now have 3 subframe FrameNavigationEntries. | 2134 frame_entry = entry->root_node()->children[2]->frame_entry.get(); |
2201 ASSERT_EQ(3U, entry->root_node()->children.size()); | 2135 EXPECT_EQ(foo_url, frame_entry->url()); |
2202 FrameNavigationEntry* frame_entry = | |
2203 entry->root_node()->children[2]->frame_entry.get(); | |
2204 EXPECT_EQ(foo_url, frame_entry->url()); | |
2205 } else { | |
2206 // There are no subframe FrameNavigationEntries by default. | |
2207 EXPECT_EQ(0U, entry->root_node()->children.size()); | |
2208 } | |
2209 | 2136 |
2210 // 5. Create a nested iframe on the original site (A-B-A). | 2137 // 5. Create a nested iframe on the original site (A-B-A). |
2211 { | 2138 { |
2212 LoadCommittedCapturer capturer(shell()->web_contents()); | 2139 LoadCommittedCapturer capturer(shell()->web_contents()); |
2213 std::string script = "var iframe = document.createElement('iframe');" | 2140 std::string script = "var iframe = document.createElement('iframe');" |
2214 "iframe.src = '" + frame_url.spec() + "';" | 2141 "iframe.src = '" + frame_url.spec() + "';" |
2215 "document.body.appendChild(iframe);"; | 2142 "document.body.appendChild(iframe);"; |
2216 FrameTreeNode* child = root->child_at(2); | 2143 FrameTreeNode* child = root->child_at(2); |
2217 EXPECT_TRUE(ExecuteScript(child, script)); | 2144 EXPECT_TRUE(ExecuteScript(child, script)); |
2218 capturer.Wait(); | 2145 capturer.Wait(); |
2219 EXPECT_TRUE(ui::PageTransitionTypeIncludingQualifiersIs( | 2146 EXPECT_TRUE(ui::PageTransitionTypeIncludingQualifiersIs( |
2220 capturer.transition_type(), ui::PAGE_TRANSITION_AUTO_SUBFRAME)); | 2147 capturer.transition_type(), ui::PAGE_TRANSITION_AUTO_SUBFRAME)); |
2221 } | 2148 } |
2222 | 2149 |
2223 // The last committed NavigationEntry shouldn't have changed. | 2150 // The last committed NavigationEntry shouldn't have changed. |
2224 EXPECT_EQ(1, controller.GetEntryCount()); | 2151 EXPECT_EQ(1, controller.GetEntryCount()); |
2225 entry = controller.GetLastCommittedEntry(); | 2152 entry = controller.GetLastCommittedEntry(); |
2226 EXPECT_EQ(main_url, entry->GetURL()); | 2153 EXPECT_EQ(main_url, entry->GetURL()); |
2227 root_entry = entry->root_node()->frame_entry.get(); | 2154 root_entry = entry->root_node()->frame_entry.get(); |
2228 EXPECT_EQ(main_url, root_entry->url()); | 2155 EXPECT_EQ(main_url, root_entry->url()); |
2229 | 2156 |
2230 // Verify subframe entries if they're enabled (e.g. in --site-per-process). | 2157 // There should be a corresponding FrameNavigationEntry. |
2231 if (SiteIsolationPolicy::UseSubframeNavigationEntries()) { | 2158 ASSERT_EQ(1U, entry->root_node()->children[2]->children.size()); |
2232 // There should be a corresponding FrameNavigationEntry. | 2159 frame_entry = entry->root_node()->children[2]->children[0]->frame_entry.get(); |
2233 ASSERT_EQ(1U, entry->root_node()->children[2]->children.size()); | 2160 EXPECT_EQ(frame_url, frame_entry->url()); |
2234 FrameNavigationEntry* frame_entry = | |
2235 entry->root_node()->children[2]->children[0]->frame_entry.get(); | |
2236 EXPECT_EQ(frame_url, frame_entry->url()); | |
2237 } else { | |
2238 // There are no subframe FrameNavigationEntries by default. | |
2239 EXPECT_EQ(0U, entry->root_node()->children.size()); | |
2240 } | |
2241 | 2161 |
2242 // Check the end result of the frame tree. | 2162 // Check the end result of the frame tree. |
2243 if (AreAllSitesIsolatedForTesting()) { | 2163 if (AreAllSitesIsolatedForTesting()) { |
2244 FrameTreeVisualizer visualizer; | 2164 FrameTreeVisualizer visualizer; |
2245 EXPECT_EQ( | 2165 EXPECT_EQ( |
2246 " Site A ------------ proxies for B\n" | 2166 " Site A ------------ proxies for B\n" |
2247 " |--Site A ------- proxies for B\n" | 2167 " |--Site A ------- proxies for B\n" |
2248 " |--Site B ------- proxies for A\n" | 2168 " |--Site B ------- proxies for A\n" |
2249 " | +--Site B -- proxies for A\n" | 2169 " | +--Site B -- proxies for A\n" |
2250 " +--Site B ------- proxies for A\n" | 2170 " +--Site B ------- proxies for A\n" |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2297 | 2217 |
2298 // We should have created a new NavigationEntry with the same main frame URL. | 2218 // We should have created a new NavigationEntry with the same main frame URL. |
2299 EXPECT_EQ(2, controller.GetEntryCount()); | 2219 EXPECT_EQ(2, controller.GetEntryCount()); |
2300 EXPECT_EQ(1, controller.GetLastCommittedEntryIndex()); | 2220 EXPECT_EQ(1, controller.GetLastCommittedEntryIndex()); |
2301 NavigationEntryImpl* entry2 = controller.GetLastCommittedEntry(); | 2221 NavigationEntryImpl* entry2 = controller.GetLastCommittedEntry(); |
2302 EXPECT_NE(entry, entry2); | 2222 EXPECT_NE(entry, entry2); |
2303 EXPECT_EQ(main_url, entry2->GetURL()); | 2223 EXPECT_EQ(main_url, entry2->GetURL()); |
2304 FrameNavigationEntry* root_entry2 = entry2->root_node()->frame_entry.get(); | 2224 FrameNavigationEntry* root_entry2 = entry2->root_node()->frame_entry.get(); |
2305 EXPECT_EQ(main_url, root_entry2->url()); | 2225 EXPECT_EQ(main_url, root_entry2->url()); |
2306 | 2226 |
2307 // Verify subframe entries if they're enabled (e.g. in --site-per-process). | 2227 // The entry should have a new FrameNavigationEntries for the subframe. |
2308 if (SiteIsolationPolicy::UseSubframeNavigationEntries()) { | 2228 ASSERT_EQ(1U, entry2->root_node()->children.size()); |
2309 // The entry should have a new FrameNavigationEntries for the subframe. | 2229 EXPECT_EQ(frame_url2, entry2->root_node()->children[0]->frame_entry->url()); |
2310 ASSERT_EQ(1U, entry2->root_node()->children.size()); | |
2311 EXPECT_EQ(frame_url2, entry2->root_node()->children[0]->frame_entry->url()); | |
2312 } else { | |
2313 // There are no subframe FrameNavigationEntries by default. | |
2314 EXPECT_EQ(0U, entry2->root_node()->children.size()); | |
2315 } | |
2316 | 2230 |
2317 // 3. Create a second, initially cross-site iframe. | 2231 // 3. Create a second, initially cross-site iframe. |
2318 GURL foo_url(embedded_test_server()->GetURL( | 2232 GURL foo_url(embedded_test_server()->GetURL( |
2319 "foo.com", "/navigation_controller/simple_page_1.html")); | 2233 "foo.com", "/navigation_controller/simple_page_1.html")); |
2320 { | 2234 { |
2321 LoadCommittedCapturer capturer(shell()->web_contents()); | 2235 LoadCommittedCapturer capturer(shell()->web_contents()); |
2322 std::string script = "var iframe = document.createElement('iframe');" | 2236 std::string script = "var iframe = document.createElement('iframe');" |
2323 "iframe.src = '" + foo_url.spec() + "';" | 2237 "iframe.src = '" + foo_url.spec() + "';" |
2324 "document.body.appendChild(iframe);"; | 2238 "document.body.appendChild(iframe);"; |
2325 EXPECT_TRUE(ExecuteScript(root, script)); | 2239 EXPECT_TRUE(ExecuteScript(root, script)); |
(...skipping 28 matching lines...) Expand all Loading... | |
2354 | 2268 |
2355 // We should have created a new NavigationEntry with the same main frame URL. | 2269 // We should have created a new NavigationEntry with the same main frame URL. |
2356 EXPECT_EQ(3, controller.GetEntryCount()); | 2270 EXPECT_EQ(3, controller.GetEntryCount()); |
2357 EXPECT_EQ(2, controller.GetLastCommittedEntryIndex()); | 2271 EXPECT_EQ(2, controller.GetLastCommittedEntryIndex()); |
2358 NavigationEntryImpl* entry3 = controller.GetLastCommittedEntry(); | 2272 NavigationEntryImpl* entry3 = controller.GetLastCommittedEntry(); |
2359 EXPECT_NE(entry, entry3); | 2273 EXPECT_NE(entry, entry3); |
2360 EXPECT_EQ(main_url, entry3->GetURL()); | 2274 EXPECT_EQ(main_url, entry3->GetURL()); |
2361 FrameNavigationEntry* root_entry3 = entry3->root_node()->frame_entry.get(); | 2275 FrameNavigationEntry* root_entry3 = entry3->root_node()->frame_entry.get(); |
2362 EXPECT_EQ(main_url, root_entry3->url()); | 2276 EXPECT_EQ(main_url, root_entry3->url()); |
2363 | 2277 |
2364 // Verify subframe entries if they're enabled (e.g. in --site-per-process). | 2278 // The entry should still have FrameNavigationEntries for all 3 subframes. |
2365 if (SiteIsolationPolicy::UseSubframeNavigationEntries()) { | 2279 ASSERT_EQ(2U, entry3->root_node()->children.size()); |
2366 // The entry should still have FrameNavigationEntries for all 3 subframes. | 2280 EXPECT_EQ(frame_url2, entry3->root_node()->children[0]->frame_entry->url()); |
2367 ASSERT_EQ(2U, entry3->root_node()->children.size()); | 2281 EXPECT_EQ(foo_url, entry3->root_node()->children[1]->frame_entry->url()); |
2368 EXPECT_EQ(frame_url2, entry3->root_node()->children[0]->frame_entry->url()); | 2282 ASSERT_EQ(1U, entry3->root_node()->children[1]->children.size()); |
2369 EXPECT_EQ(foo_url, entry3->root_node()->children[1]->frame_entry->url()); | 2283 EXPECT_EQ(bar_url, |
2370 ASSERT_EQ(1U, entry3->root_node()->children[1]->children.size()); | 2284 entry3->root_node()->children[1]->children[0]->frame_entry->url()); |
2371 EXPECT_EQ( | |
2372 bar_url, | |
2373 entry3->root_node()->children[1]->children[0]->frame_entry->url()); | |
2374 } else { | |
2375 // There are no subframe FrameNavigationEntries by default. | |
2376 EXPECT_EQ(0U, entry3->root_node()->children.size()); | |
2377 } | |
2378 | 2285 |
2379 // 6. Navigate the second subframe cross-site, clearing its existing subtree. | 2286 // 6. Navigate the second subframe cross-site, clearing its existing subtree. |
2380 GURL baz_url(embedded_test_server()->GetURL( | 2287 GURL baz_url(embedded_test_server()->GetURL( |
2381 "baz.com", "/navigation_controller/simple_page_1.html")); | 2288 "baz.com", "/navigation_controller/simple_page_1.html")); |
2382 { | 2289 { |
2383 FrameNavigateParamsCapturer capturer(root->child_at(1)); | 2290 FrameNavigateParamsCapturer capturer(root->child_at(1)); |
2384 RenderFrameDeletedObserver deleted_observer( | 2291 RenderFrameDeletedObserver deleted_observer( |
2385 root->child_at(1)->current_frame_host()); | 2292 root->child_at(1)->current_frame_host()); |
2386 std::string script = "var frames = document.getElementsByTagName('iframe');" | 2293 std::string script = "var frames = document.getElementsByTagName('iframe');" |
2387 "frames[1].src = '" + baz_url.spec() + "';"; | 2294 "frames[1].src = '" + baz_url.spec() + "';"; |
2388 EXPECT_TRUE(ExecuteScript(root, script)); | 2295 EXPECT_TRUE(ExecuteScript(root, script)); |
2389 // Wait for the RenderFrame to go away, if this will be cross-process. | 2296 // Wait for the RenderFrame to go away, if this will be cross-process. |
2390 if (AreAllSitesIsolatedForTesting()) | 2297 if (AreAllSitesIsolatedForTesting()) |
2391 deleted_observer.WaitUntilDeleted(); | 2298 deleted_observer.WaitUntilDeleted(); |
2392 capturer.Wait(); | 2299 capturer.Wait(); |
2393 EXPECT_TRUE(ui::PageTransitionTypeIncludingQualifiersIs( | 2300 EXPECT_TRUE(ui::PageTransitionTypeIncludingQualifiersIs( |
2394 capturer.params().transition, ui::PAGE_TRANSITION_MANUAL_SUBFRAME)); | 2301 capturer.params().transition, ui::PAGE_TRANSITION_MANUAL_SUBFRAME)); |
2395 EXPECT_EQ(NAVIGATION_TYPE_NEW_SUBFRAME, capturer.details().type); | 2302 EXPECT_EQ(NAVIGATION_TYPE_NEW_SUBFRAME, capturer.details().type); |
2396 } | 2303 } |
2397 | 2304 |
2398 // We should have created a new NavigationEntry with the same main frame URL. | 2305 // We should have created a new NavigationEntry with the same main frame URL. |
2399 EXPECT_EQ(4, controller.GetEntryCount()); | 2306 EXPECT_EQ(4, controller.GetEntryCount()); |
2400 EXPECT_EQ(3, controller.GetLastCommittedEntryIndex()); | 2307 EXPECT_EQ(3, controller.GetLastCommittedEntryIndex()); |
2401 NavigationEntryImpl* entry4 = controller.GetLastCommittedEntry(); | 2308 NavigationEntryImpl* entry4 = controller.GetLastCommittedEntry(); |
2402 EXPECT_NE(entry, entry4); | 2309 EXPECT_NE(entry, entry4); |
2403 EXPECT_EQ(main_url, entry4->GetURL()); | 2310 EXPECT_EQ(main_url, entry4->GetURL()); |
2404 FrameNavigationEntry* root_entry4 = entry4->root_node()->frame_entry.get(); | 2311 FrameNavigationEntry* root_entry4 = entry4->root_node()->frame_entry.get(); |
2405 EXPECT_EQ(main_url, root_entry4->url()); | 2312 EXPECT_EQ(main_url, root_entry4->url()); |
2406 | 2313 |
2407 // Verify subframe entries if they're enabled (e.g. in --site-per-process). | 2314 // The entry should still have FrameNavigationEntries for all 3 subframes. |
2408 if (SiteIsolationPolicy::UseSubframeNavigationEntries()) { | 2315 ASSERT_EQ(2U, entry4->root_node()->children.size()); |
2409 // The entry should still have FrameNavigationEntries for all 3 subframes. | 2316 EXPECT_EQ(frame_url2, entry4->root_node()->children[0]->frame_entry->url()); |
2410 ASSERT_EQ(2U, entry4->root_node()->children.size()); | 2317 EXPECT_EQ(baz_url, entry4->root_node()->children[1]->frame_entry->url()); |
2411 EXPECT_EQ(frame_url2, entry4->root_node()->children[0]->frame_entry->url()); | 2318 ASSERT_EQ(0U, entry4->root_node()->children[1]->children.size()); |
2412 EXPECT_EQ(baz_url, entry4->root_node()->children[1]->frame_entry->url()); | |
2413 ASSERT_EQ(0U, entry4->root_node()->children[1]->children.size()); | |
2414 } else { | |
2415 // There are no subframe FrameNavigationEntries by default. | |
2416 EXPECT_EQ(0U, entry4->root_node()->children.size()); | |
2417 } | |
2418 | 2319 |
2419 // Check the end result of the frame tree. | 2320 // Check the end result of the frame tree. |
2420 if (AreAllSitesIsolatedForTesting()) { | 2321 if (AreAllSitesIsolatedForTesting()) { |
2421 FrameTreeVisualizer visualizer; | 2322 FrameTreeVisualizer visualizer; |
2422 EXPECT_EQ( | 2323 EXPECT_EQ( |
2423 " Site A ------------ proxies for B\n" | 2324 " Site A ------------ proxies for B\n" |
2424 " |--Site A ------- proxies for B\n" | 2325 " |--Site A ------- proxies for B\n" |
2425 " +--Site B ------- proxies for A\n" | 2326 " +--Site B ------- proxies for A\n" |
2426 "Where A = http://127.0.0.1/\n" | 2327 "Where A = http://127.0.0.1/\n" |
2427 " B = http://baz.com/", | 2328 " B = http://baz.com/", |
(...skipping 29 matching lines...) Expand all Loading... | |
2457 capturer.Wait(); | 2358 capturer.Wait(); |
2458 EXPECT_TRUE(ui::PageTransitionTypeIncludingQualifiersIs( | 2359 EXPECT_TRUE(ui::PageTransitionTypeIncludingQualifiersIs( |
2459 capturer.transition_type(), ui::PAGE_TRANSITION_AUTO_SUBFRAME)); | 2360 capturer.transition_type(), ui::PAGE_TRANSITION_AUTO_SUBFRAME)); |
2460 } | 2361 } |
2461 | 2362 |
2462 // 2. In-page navigation in the main frame. | 2363 // 2. In-page navigation in the main frame. |
2463 std::string push_script = "history.pushState({}, 'page 2', 'page_2.html')"; | 2364 std::string push_script = "history.pushState({}, 'page 2', 'page_2.html')"; |
2464 EXPECT_TRUE(ExecuteScript(root, push_script)); | 2365 EXPECT_TRUE(ExecuteScript(root, push_script)); |
2465 EXPECT_TRUE(WaitForLoadStop(shell()->web_contents())); | 2366 EXPECT_TRUE(WaitForLoadStop(shell()->web_contents())); |
2466 | 2367 |
2467 // Verify subframe entries if they're enabled (e.g. in --site-per-process). | 2368 // The entry should have a FrameNavigationEntry for the subframe. |
2468 NavigationEntryImpl* entry = controller.GetLastCommittedEntry(); | 2369 NavigationEntryImpl* entry = controller.GetLastCommittedEntry(); |
2469 if (SiteIsolationPolicy::UseSubframeNavigationEntries()) { | 2370 ASSERT_EQ(1U, entry->root_node()->children.size()); |
2470 // The entry should have a FrameNavigationEntry for the subframe. | 2371 EXPECT_EQ(subframe_url, entry->root_node()->children[0]->frame_entry->url()); |
2471 ASSERT_EQ(1U, entry->root_node()->children.size()); | |
2472 EXPECT_EQ(subframe_url, | |
2473 entry->root_node()->children[0]->frame_entry->url()); | |
2474 } else { | |
2475 // There are no subframe FrameNavigationEntries by default. | |
2476 EXPECT_EQ(0U, entry->root_node()->children.size()); | |
2477 } | |
2478 | 2372 |
2479 // 3. Add a nested subframe. | 2373 // 3. Add a nested subframe. |
2480 { | 2374 { |
2481 LoadCommittedCapturer capturer(shell()->web_contents()); | 2375 LoadCommittedCapturer capturer(shell()->web_contents()); |
2482 std::string script = "var iframe = document.createElement('iframe');" | 2376 std::string script = "var iframe = document.createElement('iframe');" |
2483 "iframe.src = '" + subframe_url.spec() + "';" | 2377 "iframe.src = '" + subframe_url.spec() + "';" |
2484 "document.body.appendChild(iframe);"; | 2378 "document.body.appendChild(iframe);"; |
2485 EXPECT_TRUE(ExecuteScript(root->child_at(0), script)); | 2379 EXPECT_TRUE(ExecuteScript(root->child_at(0), script)); |
2486 capturer.Wait(); | 2380 capturer.Wait(); |
2487 EXPECT_TRUE(ui::PageTransitionTypeIncludingQualifiersIs( | 2381 EXPECT_TRUE(ui::PageTransitionTypeIncludingQualifiersIs( |
2488 capturer.transition_type(), ui::PAGE_TRANSITION_AUTO_SUBFRAME)); | 2382 capturer.transition_type(), ui::PAGE_TRANSITION_AUTO_SUBFRAME)); |
2489 } | 2383 } |
2490 | 2384 |
2491 // Verify subframe entries if they're enabled (e.g. in --site-per-process). | 2385 // The entry should have a FrameNavigationEntry for the subframe. |
2492 entry = controller.GetLastCommittedEntry(); | 2386 entry = controller.GetLastCommittedEntry(); |
2493 if (SiteIsolationPolicy::UseSubframeNavigationEntries()) { | 2387 ASSERT_EQ(1U, entry->root_node()->children.size()); |
2494 // The entry should have a FrameNavigationEntry for the subframe. | 2388 EXPECT_EQ(subframe_url, entry->root_node()->children[0]->frame_entry->url()); |
2495 ASSERT_EQ(1U, entry->root_node()->children.size()); | 2389 ASSERT_EQ(1U, entry->root_node()->children[0]->children.size()); |
2496 EXPECT_EQ(subframe_url, | 2390 EXPECT_EQ(subframe_url, |
2497 entry->root_node()->children[0]->frame_entry->url()); | 2391 entry->root_node()->children[0]->children[0]->frame_entry->url()); |
2498 ASSERT_EQ(1U, entry->root_node()->children[0]->children.size()); | |
2499 EXPECT_EQ(subframe_url, | |
2500 entry->root_node()->children[0]->children[0]->frame_entry->url()); | |
2501 } else { | |
2502 // There are no subframe FrameNavigationEntries by default. | |
2503 EXPECT_EQ(0U, entry->root_node()->children.size()); | |
2504 } | |
2505 } | 2392 } |
2506 | 2393 |
2507 // Verify the tree of FrameNavigationEntries after back/forward navigations in a | 2394 // Verify the tree of FrameNavigationEntries after back/forward navigations in a |
2508 // cross-site subframe. | 2395 // cross-site subframe. |
2509 IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest, | 2396 IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest, |
2510 FrameNavigationEntry_SubframeBackForward) { | 2397 FrameNavigationEntry_SubframeBackForward) { |
2511 GURL main_url(embedded_test_server()->GetURL( | 2398 GURL main_url(embedded_test_server()->GetURL( |
2512 "/navigation_controller/simple_page_1.html")); | 2399 "/navigation_controller/simple_page_1.html")); |
2513 EXPECT_TRUE(NavigateToURL(shell(), main_url)); | 2400 EXPECT_TRUE(NavigateToURL(shell(), main_url)); |
2514 const NavigationControllerImpl& controller = | 2401 const NavigationControllerImpl& controller = |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2561 shell()->web_contents()->GetController().GoBack(); | 2448 shell()->web_contents()->GetController().GoBack(); |
2562 capturer.Wait(); | 2449 capturer.Wait(); |
2563 EXPECT_TRUE(ui::PageTransitionTypeIncludingQualifiersIs( | 2450 EXPECT_TRUE(ui::PageTransitionTypeIncludingQualifiersIs( |
2564 capturer.params().transition, ui::PAGE_TRANSITION_AUTO_SUBFRAME)); | 2451 capturer.params().transition, ui::PAGE_TRANSITION_AUTO_SUBFRAME)); |
2565 EXPECT_EQ(NAVIGATION_TYPE_AUTO_SUBFRAME, capturer.details().type); | 2452 EXPECT_EQ(NAVIGATION_TYPE_AUTO_SUBFRAME, capturer.details().type); |
2566 } | 2453 } |
2567 EXPECT_EQ(3, controller.GetEntryCount()); | 2454 EXPECT_EQ(3, controller.GetEntryCount()); |
2568 EXPECT_EQ(1, controller.GetLastCommittedEntryIndex()); | 2455 EXPECT_EQ(1, controller.GetLastCommittedEntryIndex()); |
2569 EXPECT_EQ(entry2, controller.GetLastCommittedEntry()); | 2456 EXPECT_EQ(entry2, controller.GetLastCommittedEntry()); |
2570 | 2457 |
2571 // Verify subframe entries if they're enabled (e.g. in --site-per-process). | 2458 // The entry should have a FrameNavigationEntry for the subframe. |
2572 if (SiteIsolationPolicy::UseSubframeNavigationEntries()) { | 2459 ASSERT_EQ(1U, entry2->root_node()->children.size()); |
2573 // The entry should have a FrameNavigationEntry for the subframe. | 2460 EXPECT_EQ(frame_url2, entry2->root_node()->children[0]->frame_entry->url()); |
2574 ASSERT_EQ(1U, entry2->root_node()->children.size()); | |
2575 EXPECT_EQ(frame_url2, entry2->root_node()->children[0]->frame_entry->url()); | |
2576 } else { | |
2577 // There are no subframe FrameNavigationEntries by default. | |
2578 EXPECT_EQ(0U, entry2->root_node()->children.size()); | |
2579 } | |
2580 | 2461 |
2581 // 5. Go back in the subframe again to the parent page's site. | 2462 // 5. Go back in the subframe again to the parent page's site. |
2582 { | 2463 { |
2583 FrameNavigateParamsCapturer capturer(root->child_at(0)); | 2464 FrameNavigateParamsCapturer capturer(root->child_at(0)); |
2584 shell()->web_contents()->GetController().GoBack(); | 2465 shell()->web_contents()->GetController().GoBack(); |
2585 capturer.Wait(); | 2466 capturer.Wait(); |
2586 EXPECT_TRUE(ui::PageTransitionTypeIncludingQualifiersIs( | 2467 EXPECT_TRUE(ui::PageTransitionTypeIncludingQualifiersIs( |
2587 capturer.params().transition, ui::PAGE_TRANSITION_AUTO_SUBFRAME)); | 2468 capturer.params().transition, ui::PAGE_TRANSITION_AUTO_SUBFRAME)); |
2588 EXPECT_EQ(NAVIGATION_TYPE_AUTO_SUBFRAME, capturer.details().type); | 2469 EXPECT_EQ(NAVIGATION_TYPE_AUTO_SUBFRAME, capturer.details().type); |
2589 } | 2470 } |
2590 EXPECT_EQ(3, controller.GetEntryCount()); | 2471 EXPECT_EQ(3, controller.GetEntryCount()); |
2591 EXPECT_EQ(0, controller.GetLastCommittedEntryIndex()); | 2472 EXPECT_EQ(0, controller.GetLastCommittedEntryIndex()); |
2592 EXPECT_EQ(entry1, controller.GetLastCommittedEntry()); | 2473 EXPECT_EQ(entry1, controller.GetLastCommittedEntry()); |
2593 | 2474 |
2594 // Verify subframe entries if they're enabled (e.g. in --site-per-process). | 2475 // The entry should have a FrameNavigationEntry for the subframe. |
2595 if (SiteIsolationPolicy::UseSubframeNavigationEntries()) { | 2476 ASSERT_EQ(1U, entry1->root_node()->children.size()); |
2596 // The entry should have a FrameNavigationEntry for the subframe. | 2477 EXPECT_EQ(frame_url, entry1->root_node()->children[0]->frame_entry->url()); |
2597 ASSERT_EQ(1U, entry1->root_node()->children.size()); | |
2598 EXPECT_EQ(frame_url, entry1->root_node()->children[0]->frame_entry->url()); | |
2599 } else { | |
2600 // There are no subframe FrameNavigationEntries by default. | |
2601 EXPECT_EQ(0U, entry1->root_node()->children.size()); | |
2602 } | |
2603 | 2478 |
2604 // 6. Go forward in the subframe cross-site. | 2479 // 6. Go forward in the subframe cross-site. |
2605 { | 2480 { |
2606 FrameNavigateParamsCapturer capturer(root->child_at(0)); | 2481 FrameNavigateParamsCapturer capturer(root->child_at(0)); |
2607 shell()->web_contents()->GetController().GoForward(); | 2482 shell()->web_contents()->GetController().GoForward(); |
2608 capturer.Wait(); | 2483 capturer.Wait(); |
2609 EXPECT_TRUE(ui::PageTransitionTypeIncludingQualifiersIs( | 2484 EXPECT_TRUE(ui::PageTransitionTypeIncludingQualifiersIs( |
2610 capturer.params().transition, ui::PAGE_TRANSITION_AUTO_SUBFRAME)); | 2485 capturer.params().transition, ui::PAGE_TRANSITION_AUTO_SUBFRAME)); |
2611 EXPECT_EQ(NAVIGATION_TYPE_AUTO_SUBFRAME, capturer.details().type); | 2486 EXPECT_EQ(NAVIGATION_TYPE_AUTO_SUBFRAME, capturer.details().type); |
2612 } | 2487 } |
2613 EXPECT_EQ(3, controller.GetEntryCount()); | 2488 EXPECT_EQ(3, controller.GetEntryCount()); |
2614 EXPECT_EQ(1, controller.GetLastCommittedEntryIndex()); | 2489 EXPECT_EQ(1, controller.GetLastCommittedEntryIndex()); |
2615 EXPECT_EQ(entry2, controller.GetLastCommittedEntry()); | 2490 EXPECT_EQ(entry2, controller.GetLastCommittedEntry()); |
2616 | 2491 |
2617 // Verify subframe entries if they're enabled (e.g. in --site-per-process). | 2492 // The entry should have a FrameNavigationEntry for the subframe. |
2618 if (SiteIsolationPolicy::UseSubframeNavigationEntries()) { | 2493 ASSERT_EQ(1U, entry2->root_node()->children.size()); |
2619 // The entry should have a FrameNavigationEntry for the subframe. | 2494 EXPECT_EQ(frame_url2, entry2->root_node()->children[0]->frame_entry->url()); |
2620 ASSERT_EQ(1U, entry2->root_node()->children.size()); | |
2621 EXPECT_EQ(frame_url2, entry2->root_node()->children[0]->frame_entry->url()); | |
2622 } else { | |
2623 // There are no subframe FrameNavigationEntries by default. | |
2624 EXPECT_EQ(0U, entry2->root_node()->children.size()); | |
2625 } | |
2626 | 2495 |
2627 // 7. Go forward in the subframe again, cross-site. | 2496 // 7. Go forward in the subframe again, cross-site. |
2628 { | 2497 { |
2629 FrameNavigateParamsCapturer capturer(root->child_at(0)); | 2498 FrameNavigateParamsCapturer capturer(root->child_at(0)); |
2630 shell()->web_contents()->GetController().GoForward(); | 2499 shell()->web_contents()->GetController().GoForward(); |
2631 capturer.Wait(); | 2500 capturer.Wait(); |
2632 EXPECT_TRUE(ui::PageTransitionTypeIncludingQualifiersIs( | 2501 EXPECT_TRUE(ui::PageTransitionTypeIncludingQualifiersIs( |
2633 capturer.params().transition, ui::PAGE_TRANSITION_AUTO_SUBFRAME)); | 2502 capturer.params().transition, ui::PAGE_TRANSITION_AUTO_SUBFRAME)); |
2634 EXPECT_EQ(NAVIGATION_TYPE_AUTO_SUBFRAME, capturer.details().type); | 2503 EXPECT_EQ(NAVIGATION_TYPE_AUTO_SUBFRAME, capturer.details().type); |
2635 } | 2504 } |
2636 EXPECT_EQ(3, controller.GetEntryCount()); | 2505 EXPECT_EQ(3, controller.GetEntryCount()); |
2637 EXPECT_EQ(2, controller.GetLastCommittedEntryIndex()); | 2506 EXPECT_EQ(2, controller.GetLastCommittedEntryIndex()); |
2638 EXPECT_EQ(entry3, controller.GetLastCommittedEntry()); | 2507 EXPECT_EQ(entry3, controller.GetLastCommittedEntry()); |
2639 | 2508 |
2640 // Verify subframe entries if they're enabled (e.g. in --site-per-process). | 2509 // The entry should have a FrameNavigationEntry for the subframe. |
2641 if (SiteIsolationPolicy::UseSubframeNavigationEntries()) { | 2510 ASSERT_EQ(1U, entry3->root_node()->children.size()); |
2642 // The entry should have a FrameNavigationEntry for the subframe. | 2511 EXPECT_EQ(frame_url3, entry3->root_node()->children[0]->frame_entry->url()); |
2643 ASSERT_EQ(1U, entry3->root_node()->children.size()); | |
2644 EXPECT_EQ(frame_url3, entry3->root_node()->children[0]->frame_entry->url()); | |
2645 } else { | |
2646 // There are no subframe FrameNavigationEntries by default. | |
2647 EXPECT_EQ(0U, entry3->root_node()->children.size()); | |
2648 } | |
2649 } | 2512 } |
2650 | 2513 |
2651 // Verify the tree of FrameNavigationEntries after subframes are recreated in | 2514 // Verify the tree of FrameNavigationEntries after subframes are recreated in |
2652 // history navigations, including nested frames. The history will look like: | 2515 // history navigations, including nested frames. The history will look like: |
2653 // 1. initial_url | 2516 // 1. initial_url |
2654 // 2. main_url_a (data_url) | 2517 // 2. main_url_a (data_url) |
2655 // 3. main_url_a (frame_url_b (data_url)) | 2518 // 3. main_url_a (frame_url_b (data_url)) |
2656 // 4. main_url_a (frame_url_b (frame_url_c)) | 2519 // 4. main_url_a (frame_url_b (frame_url_c)) |
2657 // 5. main_url_d | 2520 // 5. main_url_d |
2658 IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest, | 2521 IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest, |
(...skipping 19 matching lines...) Expand all Loading... | |
2678 EXPECT_TRUE(NavigateToURL(shell(), main_url_a)); | 2541 EXPECT_TRUE(NavigateToURL(shell(), main_url_a)); |
2679 ASSERT_EQ(1U, root->child_count()); | 2542 ASSERT_EQ(1U, root->child_count()); |
2680 ASSERT_EQ(0U, root->child_at(0)->child_count()); | 2543 ASSERT_EQ(0U, root->child_at(0)->child_count()); |
2681 EXPECT_EQ(main_url_a, root->current_url()); | 2544 EXPECT_EQ(main_url_a, root->current_url()); |
2682 EXPECT_EQ(data_url, root->child_at(0)->current_url()); | 2545 EXPECT_EQ(data_url, root->child_at(0)->current_url()); |
2683 | 2546 |
2684 EXPECT_EQ(2, controller.GetEntryCount()); | 2547 EXPECT_EQ(2, controller.GetEntryCount()); |
2685 EXPECT_EQ(1, controller.GetLastCommittedEntryIndex()); | 2548 EXPECT_EQ(1, controller.GetLastCommittedEntryIndex()); |
2686 NavigationEntryImpl* entry2 = controller.GetLastCommittedEntry(); | 2549 NavigationEntryImpl* entry2 = controller.GetLastCommittedEntry(); |
2687 | 2550 |
2688 // Verify subframe entries if they're enabled (e.g. in --site-per-process). | 2551 // The entry should have a FrameNavigationEntry for the data subframe. |
2689 if (SiteIsolationPolicy::UseSubframeNavigationEntries()) { | 2552 ASSERT_EQ(1U, entry2->root_node()->children.size()); |
2690 // The entry should have a FrameNavigationEntry for the data subframe. | 2553 EXPECT_EQ(data_url, entry2->root_node()->children[0]->frame_entry->url()); |
2691 ASSERT_EQ(1U, entry2->root_node()->children.size()); | |
2692 EXPECT_EQ(data_url, entry2->root_node()->children[0]->frame_entry->url()); | |
2693 } else { | |
2694 // There are no subframe FrameNavigationEntries by default. | |
2695 EXPECT_EQ(0U, entry2->root_node()->children.size()); | |
2696 } | |
2697 | 2554 |
2698 // 3. Navigate the iframe cross-site to a page with a nested iframe. | 2555 // 3. Navigate the iframe cross-site to a page with a nested iframe. |
2699 GURL frame_url_b(embedded_test_server()->GetURL( | 2556 GURL frame_url_b(embedded_test_server()->GetURL( |
2700 "b.com", "/navigation_controller/page_with_data_iframe.html")); | 2557 "b.com", "/navigation_controller/page_with_data_iframe.html")); |
2701 { | 2558 { |
2702 FrameNavigateParamsCapturer capturer(root->child_at(0)); | 2559 FrameNavigateParamsCapturer capturer(root->child_at(0)); |
2703 NavigateFrameToURL(root->child_at(0), frame_url_b); | 2560 NavigateFrameToURL(root->child_at(0), frame_url_b); |
2704 capturer.Wait(); | 2561 capturer.Wait(); |
2705 } | 2562 } |
2706 ASSERT_EQ(1U, root->child_count()); | 2563 ASSERT_EQ(1U, root->child_count()); |
2707 EXPECT_EQ(main_url_a, root->current_url()); | 2564 EXPECT_EQ(main_url_a, root->current_url()); |
2708 EXPECT_EQ(frame_url_b, root->child_at(0)->current_url()); | 2565 EXPECT_EQ(frame_url_b, root->child_at(0)->current_url()); |
2709 EXPECT_EQ(data_url, root->child_at(0)->child_at(0)->current_url()); | 2566 EXPECT_EQ(data_url, root->child_at(0)->child_at(0)->current_url()); |
2710 | 2567 |
2711 EXPECT_EQ(3, controller.GetEntryCount()); | 2568 EXPECT_EQ(3, controller.GetEntryCount()); |
2712 EXPECT_EQ(2, controller.GetLastCommittedEntryIndex()); | 2569 EXPECT_EQ(2, controller.GetLastCommittedEntryIndex()); |
2713 NavigationEntryImpl* entry3 = controller.GetLastCommittedEntry(); | 2570 NavigationEntryImpl* entry3 = controller.GetLastCommittedEntry(); |
2714 | 2571 |
2715 // Verify subframe entries if they're enabled (e.g. in --site-per-process). | 2572 // The entry should have a FrameNavigationEntry for the b.com subframe. |
2716 if (SiteIsolationPolicy::UseSubframeNavigationEntries()) { | 2573 ASSERT_EQ(1U, entry3->root_node()->children.size()); |
2717 // The entry should have a FrameNavigationEntry for the b.com subframe. | 2574 ASSERT_EQ(1U, entry3->root_node()->children[0]->children.size()); |
2718 ASSERT_EQ(1U, entry3->root_node()->children.size()); | 2575 EXPECT_EQ(frame_url_b, entry3->root_node()->children[0]->frame_entry->url()); |
2719 ASSERT_EQ(1U, entry3->root_node()->children[0]->children.size()); | 2576 EXPECT_EQ(data_url, |
2720 EXPECT_EQ(frame_url_b, | 2577 entry3->root_node()->children[0]->children[0]->frame_entry->url()); |
2721 entry3->root_node()->children[0]->frame_entry->url()); | |
2722 EXPECT_EQ( | |
2723 data_url, | |
2724 entry3->root_node()->children[0]->children[0]->frame_entry->url()); | |
2725 } else { | |
2726 // There are no subframe FrameNavigationEntries by default. | |
2727 EXPECT_EQ(0U, entry3->root_node()->children.size()); | |
2728 } | |
2729 | 2578 |
2730 // 4. Navigate the nested iframe cross-site. | 2579 // 4. Navigate the nested iframe cross-site. |
2731 GURL frame_url_c(embedded_test_server()->GetURL( | 2580 GURL frame_url_c(embedded_test_server()->GetURL( |
2732 "c.com", "/navigation_controller/simple_page_2.html")); | 2581 "c.com", "/navigation_controller/simple_page_2.html")); |
2733 { | 2582 { |
2734 FrameNavigateParamsCapturer capturer(root->child_at(0)->child_at(0)); | 2583 FrameNavigateParamsCapturer capturer(root->child_at(0)->child_at(0)); |
2735 NavigateFrameToURL(root->child_at(0)->child_at(0), frame_url_c); | 2584 NavigateFrameToURL(root->child_at(0)->child_at(0), frame_url_c); |
2736 capturer.Wait(); | 2585 capturer.Wait(); |
2737 } | 2586 } |
2738 ASSERT_EQ(1U, root->child_count()); | 2587 ASSERT_EQ(1U, root->child_count()); |
2739 EXPECT_EQ(main_url_a, root->current_url()); | 2588 EXPECT_EQ(main_url_a, root->current_url()); |
2740 EXPECT_EQ(frame_url_b, root->child_at(0)->current_url()); | 2589 EXPECT_EQ(frame_url_b, root->child_at(0)->current_url()); |
2741 EXPECT_EQ(frame_url_c, root->child_at(0)->child_at(0)->current_url()); | 2590 EXPECT_EQ(frame_url_c, root->child_at(0)->child_at(0)->current_url()); |
2742 | 2591 |
2743 EXPECT_EQ(4, controller.GetEntryCount()); | 2592 EXPECT_EQ(4, controller.GetEntryCount()); |
2744 EXPECT_EQ(3, controller.GetLastCommittedEntryIndex()); | 2593 EXPECT_EQ(3, controller.GetLastCommittedEntryIndex()); |
2745 NavigationEntryImpl* entry4 = controller.GetLastCommittedEntry(); | 2594 NavigationEntryImpl* entry4 = controller.GetLastCommittedEntry(); |
2746 | 2595 |
2747 // Verify subframe entries if they're enabled (e.g. in --site-per-process). | 2596 // The entry should have FrameNavigationEntries for the subframes. |
2748 if (SiteIsolationPolicy::UseSubframeNavigationEntries()) { | 2597 ASSERT_EQ(1U, entry4->root_node()->children.size()); |
2749 // The entry should have FrameNavigationEntries for the subframes. | 2598 ASSERT_EQ(1U, entry4->root_node()->children[0]->children.size()); |
2750 ASSERT_EQ(1U, entry4->root_node()->children.size()); | 2599 EXPECT_EQ(frame_url_b, entry4->root_node()->children[0]->frame_entry->url()); |
2751 ASSERT_EQ(1U, entry4->root_node()->children[0]->children.size()); | 2600 EXPECT_EQ(frame_url_c, |
2752 EXPECT_EQ(frame_url_b, | 2601 entry4->root_node()->children[0]->children[0]->frame_entry->url()); |
2753 entry4->root_node()->children[0]->frame_entry->url()); | |
2754 EXPECT_EQ( | |
2755 frame_url_c, | |
2756 entry4->root_node()->children[0]->children[0]->frame_entry->url()); | |
2757 } else { | |
2758 // There are no subframe FrameNavigationEntries by default. | |
2759 EXPECT_EQ(0U, entry4->root_node()->children.size()); | |
2760 } | |
2761 | 2602 |
2762 // Remember the DSNs for later. | 2603 // Remember the DSNs for later. |
2763 int64_t root_dsn = | 2604 int64_t root_dsn = |
2764 entry4->root_node()->frame_entry->document_sequence_number(); | 2605 entry4->root_node()->frame_entry->document_sequence_number(); |
2765 int64_t frame_b_dsn = -1; | 2606 int64_t frame_b_dsn = |
2766 int64_t frame_c_dsn = -1; | 2607 entry4->root_node()->children[0]->frame_entry->document_sequence_number(); |
2767 if (SiteIsolationPolicy::UseSubframeNavigationEntries()) { | 2608 int64_t frame_c_dsn = entry4->root_node() |
2768 frame_b_dsn = entry4->root_node() | 2609 ->children[0] |
2769 ->children[0] | 2610 ->children[0] |
2770 ->frame_entry->document_sequence_number(); | 2611 ->frame_entry->document_sequence_number(); |
2771 frame_c_dsn = entry4->root_node() | |
2772 ->children[0] | |
2773 ->children[0] | |
2774 ->frame_entry->document_sequence_number(); | |
2775 } | |
2776 | 2612 |
2777 // 5. Navigate main frame cross-site, destroying the frames. | 2613 // 5. Navigate main frame cross-site, destroying the frames. |
2778 GURL main_url_d(embedded_test_server()->GetURL( | 2614 GURL main_url_d(embedded_test_server()->GetURL( |
2779 "d.com", "/navigation_controller/simple_page_2.html")); | 2615 "d.com", "/navigation_controller/simple_page_2.html")); |
2780 EXPECT_TRUE(NavigateToURL(shell(), main_url_d)); | 2616 EXPECT_TRUE(NavigateToURL(shell(), main_url_d)); |
2781 ASSERT_EQ(0U, root->child_count()); | 2617 ASSERT_EQ(0U, root->child_count()); |
2782 EXPECT_EQ(main_url_d, root->current_url()); | 2618 EXPECT_EQ(main_url_d, root->current_url()); |
2783 | 2619 |
2784 EXPECT_EQ(5, controller.GetEntryCount()); | 2620 EXPECT_EQ(5, controller.GetEntryCount()); |
2785 EXPECT_EQ(4, controller.GetLastCommittedEntryIndex()); | 2621 EXPECT_EQ(4, controller.GetLastCommittedEntryIndex()); |
(...skipping 13 matching lines...) Expand all Loading... | |
2799 EXPECT_EQ(frame_url_c, root->child_at(0)->child_at(0)->current_url()); | 2635 EXPECT_EQ(frame_url_c, root->child_at(0)->child_at(0)->current_url()); |
2800 | 2636 |
2801 EXPECT_EQ(5, controller.GetEntryCount()); | 2637 EXPECT_EQ(5, controller.GetEntryCount()); |
2802 EXPECT_EQ(3, controller.GetLastCommittedEntryIndex()); | 2638 EXPECT_EQ(3, controller.GetLastCommittedEntryIndex()); |
2803 EXPECT_EQ(entry4, controller.GetLastCommittedEntry()); | 2639 EXPECT_EQ(entry4, controller.GetLastCommittedEntry()); |
2804 | 2640 |
2805 // The main frame should not have changed its DSN. | 2641 // The main frame should not have changed its DSN. |
2806 EXPECT_EQ(root_dsn, | 2642 EXPECT_EQ(root_dsn, |
2807 entry4->root_node()->frame_entry->document_sequence_number()); | 2643 entry4->root_node()->frame_entry->document_sequence_number()); |
2808 | 2644 |
2809 // Verify subframe entries if they're enabled (e.g. in --site-per-process). | 2645 // The entry should have FrameNavigationEntries for the subframes. |
2810 if (SiteIsolationPolicy::UseSubframeNavigationEntries()) { | 2646 ASSERT_EQ(1U, entry4->root_node()->children.size()); |
2811 // The entry should have FrameNavigationEntries for the subframes. | 2647 ASSERT_EQ(1U, entry4->root_node()->children[0]->children.size()); |
2812 ASSERT_EQ(1U, entry4->root_node()->children.size()); | 2648 EXPECT_EQ(frame_url_b, entry4->root_node()->children[0]->frame_entry->url()); |
2813 ASSERT_EQ(1U, entry4->root_node()->children[0]->children.size()); | 2649 EXPECT_EQ(frame_url_c, |
2814 EXPECT_EQ(frame_url_b, | 2650 entry4->root_node()->children[0]->children[0]->frame_entry->url()); |
2815 entry4->root_node()->children[0]->frame_entry->url()); | 2651 // The subframes should not have changed their DSNs. |
2816 EXPECT_EQ( | 2652 // See https://crbug.com/628286. |
2817 frame_url_c, | 2653 EXPECT_EQ(frame_b_dsn, entry4->root_node() |
2818 entry4->root_node()->children[0]->children[0]->frame_entry->url()); | 2654 ->children[0] |
2819 | 2655 ->frame_entry->document_sequence_number()); |
2820 // The subframes should not have changed their DSNs. | 2656 EXPECT_EQ(frame_c_dsn, entry4->root_node() |
2821 // See https://crbug.com/628286. | 2657 ->children[0] |
2822 EXPECT_EQ(frame_b_dsn, entry4->root_node() | 2658 ->children[0] |
2823 ->children[0] | 2659 ->frame_entry->document_sequence_number()); |
2824 ->frame_entry->document_sequence_number()); | |
2825 EXPECT_EQ(frame_c_dsn, entry4->root_node() | |
2826 ->children[0] | |
2827 ->children[0] | |
2828 ->frame_entry->document_sequence_number()); | |
2829 } else { | |
2830 // There are no subframe FrameNavigationEntries by default. | |
2831 EXPECT_EQ(0U, entry4->root_node()->children.size()); | |
2832 } | |
2833 | 2660 |
2834 // Inject a JS value so that we can check for it later. | 2661 // Inject a JS value so that we can check for it later. |
2835 EXPECT_TRUE(content::ExecuteScript(root, "foo=3;")); | 2662 EXPECT_TRUE(content::ExecuteScript(root, "foo=3;")); |
2836 | 2663 |
2837 // 7. Go back again, to the data URL in the nested iframe. | 2664 // 7. Go back again, to the data URL in the nested iframe. |
2838 { | 2665 { |
2839 TestNavigationObserver back_load_observer(shell()->web_contents()); | 2666 TestNavigationObserver back_load_observer(shell()->web_contents()); |
2840 shell()->web_contents()->GetController().GoBack(); | 2667 shell()->web_contents()->GetController().GoBack(); |
2841 back_load_observer.Wait(); | 2668 back_load_observer.Wait(); |
2842 } | 2669 } |
2843 ASSERT_EQ(1U, root->child_count()); | 2670 ASSERT_EQ(1U, root->child_count()); |
2844 ASSERT_EQ(1U, root->child_at(0)->child_count()); | 2671 ASSERT_EQ(1U, root->child_at(0)->child_count()); |
2845 EXPECT_EQ(main_url_a, root->current_url()); | 2672 EXPECT_EQ(main_url_a, root->current_url()); |
2846 EXPECT_EQ(frame_url_b, root->child_at(0)->current_url()); | 2673 EXPECT_EQ(frame_url_b, root->child_at(0)->current_url()); |
2847 EXPECT_EQ(data_url, root->child_at(0)->child_at(0)->current_url()); | 2674 EXPECT_EQ(data_url, root->child_at(0)->child_at(0)->current_url()); |
2848 | 2675 |
2849 EXPECT_EQ(5, controller.GetEntryCount()); | 2676 EXPECT_EQ(5, controller.GetEntryCount()); |
2850 EXPECT_EQ(2, controller.GetLastCommittedEntryIndex()); | 2677 EXPECT_EQ(2, controller.GetLastCommittedEntryIndex()); |
2851 EXPECT_EQ(entry3, controller.GetLastCommittedEntry()); | 2678 EXPECT_EQ(entry3, controller.GetLastCommittedEntry()); |
2852 | 2679 |
2853 // Verify subframe entries if they're enabled (e.g. in --site-per-process). | 2680 // The entry should have FrameNavigationEntries for the subframes. |
2854 if (SiteIsolationPolicy::UseSubframeNavigationEntries()) { | 2681 ASSERT_EQ(1U, entry3->root_node()->children.size()); |
2855 // The entry should have FrameNavigationEntries for the subframes. | 2682 ASSERT_EQ(1U, entry3->root_node()->children[0]->children.size()); |
2856 ASSERT_EQ(1U, entry3->root_node()->children.size()); | 2683 EXPECT_EQ(frame_url_b, entry3->root_node()->children[0]->frame_entry->url()); |
2857 ASSERT_EQ(1U, entry3->root_node()->children[0]->children.size()); | 2684 EXPECT_EQ(data_url, |
2858 EXPECT_EQ(frame_url_b, | 2685 entry3->root_node()->children[0]->children[0]->frame_entry->url()); |
2859 entry3->root_node()->children[0]->frame_entry->url()); | |
2860 EXPECT_EQ( | |
2861 data_url, | |
2862 entry3->root_node()->children[0]->children[0]->frame_entry->url()); | |
2863 } else { | |
2864 // There are no subframe FrameNavigationEntries by default. | |
2865 EXPECT_EQ(0U, entry3->root_node()->children.size()); | |
2866 } | |
2867 | 2686 |
2868 // Verify that we did not reload the main frame. See https://crbug.com/586234. | 2687 // Verify that we did not reload the main frame. See https://crbug.com/586234. |
2869 { | 2688 { |
2870 int value = 0; | 2689 int value = 0; |
2871 EXPECT_TRUE(ExecuteScriptAndExtractInt( | 2690 EXPECT_TRUE(ExecuteScriptAndExtractInt( |
2872 root, "domAutomationController.send(foo)", &value)); | 2691 root, "domAutomationController.send(foo)", &value)); |
2873 EXPECT_EQ(3, value); | 2692 EXPECT_EQ(3, value); |
2874 } | 2693 } |
2875 | 2694 |
2876 // 8. Go back again, to the data URL in the first subframe. | 2695 // 8. Go back again, to the data URL in the first subframe. |
2877 { | 2696 { |
2878 TestNavigationObserver back_load_observer(shell()->web_contents()); | 2697 TestNavigationObserver back_load_observer(shell()->web_contents()); |
2879 shell()->web_contents()->GetController().GoBack(); | 2698 shell()->web_contents()->GetController().GoBack(); |
2880 back_load_observer.Wait(); | 2699 back_load_observer.Wait(); |
2881 } | 2700 } |
2882 ASSERT_EQ(1U, root->child_count()); | 2701 ASSERT_EQ(1U, root->child_count()); |
2883 ASSERT_EQ(0U, root->child_at(0)->child_count()); | 2702 ASSERT_EQ(0U, root->child_at(0)->child_count()); |
2884 EXPECT_EQ(main_url_a, root->current_url()); | 2703 EXPECT_EQ(main_url_a, root->current_url()); |
2885 EXPECT_EQ(data_url, root->child_at(0)->current_url()); | 2704 EXPECT_EQ(data_url, root->child_at(0)->current_url()); |
2886 | 2705 |
2887 EXPECT_EQ(5, controller.GetEntryCount()); | 2706 EXPECT_EQ(5, controller.GetEntryCount()); |
2888 EXPECT_EQ(1, controller.GetLastCommittedEntryIndex()); | 2707 EXPECT_EQ(1, controller.GetLastCommittedEntryIndex()); |
2889 EXPECT_EQ(entry2, controller.GetLastCommittedEntry()); | 2708 EXPECT_EQ(entry2, controller.GetLastCommittedEntry()); |
2890 | 2709 |
2891 // Verify subframe entries if they're enabled (e.g. in --site-per-process). | 2710 // The entry should have a FrameNavigationEntry for the subframe. |
2892 if (SiteIsolationPolicy::UseSubframeNavigationEntries()) { | 2711 ASSERT_EQ(1U, entry2->root_node()->children.size()); |
2893 // The entry should have a FrameNavigationEntry for the subframe. | 2712 EXPECT_EQ(data_url, entry2->root_node()->children[0]->frame_entry->url()); |
2894 ASSERT_EQ(1U, entry2->root_node()->children.size()); | |
2895 EXPECT_EQ(data_url, entry2->root_node()->children[0]->frame_entry->url()); | |
2896 } else { | |
2897 // There are no subframe FrameNavigationEntries by default. | |
2898 EXPECT_EQ(0U, entry2->root_node()->children.size()); | |
2899 } | |
2900 | 2713 |
2901 // 9. Go back again, to the initial main frame page. | 2714 // 9. Go back again, to the initial main frame page. |
2902 { | 2715 { |
2903 TestNavigationObserver back_load_observer(shell()->web_contents()); | 2716 TestNavigationObserver back_load_observer(shell()->web_contents()); |
2904 shell()->web_contents()->GetController().GoBack(); | 2717 shell()->web_contents()->GetController().GoBack(); |
2905 back_load_observer.Wait(); | 2718 back_load_observer.Wait(); |
2906 } | 2719 } |
2907 ASSERT_EQ(0U, root->child_count()); | 2720 ASSERT_EQ(0U, root->child_count()); |
2908 EXPECT_EQ(initial_url, root->current_url()); | 2721 EXPECT_EQ(initial_url, root->current_url()); |
2909 | 2722 |
(...skipping 10 matching lines...) Expand all Loading... | |
2920 } | 2733 } |
2921 ASSERT_EQ(1U, root->child_count()); | 2734 ASSERT_EQ(1U, root->child_count()); |
2922 EXPECT_EQ(main_url_a, root->current_url()); | 2735 EXPECT_EQ(main_url_a, root->current_url()); |
2923 EXPECT_EQ(frame_url_b, root->child_at(0)->current_url()); | 2736 EXPECT_EQ(frame_url_b, root->child_at(0)->current_url()); |
2924 EXPECT_EQ(data_url, root->child_at(0)->child_at(0)->current_url()); | 2737 EXPECT_EQ(data_url, root->child_at(0)->child_at(0)->current_url()); |
2925 | 2738 |
2926 EXPECT_EQ(5, controller.GetEntryCount()); | 2739 EXPECT_EQ(5, controller.GetEntryCount()); |
2927 EXPECT_EQ(2, controller.GetLastCommittedEntryIndex()); | 2740 EXPECT_EQ(2, controller.GetLastCommittedEntryIndex()); |
2928 EXPECT_EQ(entry3, controller.GetLastCommittedEntry()); | 2741 EXPECT_EQ(entry3, controller.GetLastCommittedEntry()); |
2929 | 2742 |
2930 // Verify subframe entries if they're enabled (e.g. in --site-per-process). | 2743 // The entry should have FrameNavigationEntries for the subframes. |
2931 if (SiteIsolationPolicy::UseSubframeNavigationEntries()) { | 2744 ASSERT_EQ(1U, entry3->root_node()->children.size()); |
2932 // The entry should have FrameNavigationEntries for the subframes. | 2745 EXPECT_EQ(frame_url_b, entry3->root_node()->children[0]->frame_entry->url()); |
2933 ASSERT_EQ(1U, entry3->root_node()->children.size()); | 2746 EXPECT_EQ(data_url, |
2934 EXPECT_EQ(frame_url_b, | 2747 entry3->root_node()->children[0]->children[0]->frame_entry->url()); |
2935 entry3->root_node()->children[0]->frame_entry->url()); | |
2936 EXPECT_EQ( | |
2937 data_url, | |
2938 entry3->root_node()->children[0]->children[0]->frame_entry->url()); | |
2939 } else { | |
2940 // There are no subframe FrameNavigationEntries by default. | |
2941 EXPECT_EQ(0U, entry3->root_node()->children.size()); | |
2942 } | |
2943 } | 2748 } |
2944 | 2749 |
2945 // Verify that we navigate to the fallback (original) URL if a subframe's | 2750 // Verify that we navigate to the fallback (original) URL if a subframe's |
2946 // FrameNavigationEntry can't be found during a history navigation. | 2751 // FrameNavigationEntry can't be found during a history navigation. |
2947 IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest, | 2752 IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest, |
2948 FrameNavigationEntry_SubframeHistoryFallback) { | 2753 FrameNavigationEntry_SubframeHistoryFallback) { |
2949 // This test only makes sense when subframe FrameNavigationEntries are in use. | |
2950 if (!SiteIsolationPolicy::UseSubframeNavigationEntries()) | |
2951 return; | |
2952 | |
2953 // 1. Start on a page with a data URL iframe. | 2754 // 1. Start on a page with a data URL iframe. |
2954 GURL main_url_a(embedded_test_server()->GetURL( | 2755 GURL main_url_a(embedded_test_server()->GetURL( |
2955 "a.com", "/navigation_controller/page_with_data_iframe.html")); | 2756 "a.com", "/navigation_controller/page_with_data_iframe.html")); |
2956 GURL data_url("data:text/html,Subframe"); | 2757 GURL data_url("data:text/html,Subframe"); |
2957 EXPECT_TRUE(NavigateToURL(shell(), main_url_a)); | 2758 EXPECT_TRUE(NavigateToURL(shell(), main_url_a)); |
2958 const NavigationControllerImpl& controller = | 2759 const NavigationControllerImpl& controller = |
2959 static_cast<const NavigationControllerImpl&>( | 2760 static_cast<const NavigationControllerImpl&>( |
2960 shell()->web_contents()->GetController()); | 2761 shell()->web_contents()->GetController()); |
2961 FrameTreeNode* root = static_cast<WebContentsImpl*>(shell()->web_contents()) | 2762 FrameTreeNode* root = static_cast<WebContentsImpl*>(shell()->web_contents()) |
2962 ->GetFrameTree() | 2763 ->GetFrameTree() |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3051 | 2852 |
3052 // The MessageLoopRunner used to spin the message loop. | 2853 // The MessageLoopRunner used to spin the message loop. |
3053 scoped_refptr<MessageLoopRunner> message_loop_runner_; | 2854 scoped_refptr<MessageLoopRunner> message_loop_runner_; |
3054 }; | 2855 }; |
3055 | 2856 |
3056 // Verify that dynamically generated iframes load properly during a history | 2857 // Verify that dynamically generated iframes load properly during a history |
3057 // navigation if no history item can be found for them. | 2858 // navigation if no history item can be found for them. |
3058 // See https://crbug.com/649345. | 2859 // See https://crbug.com/649345. |
3059 IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest, | 2860 IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest, |
3060 FrameNavigationEntry_DynamicSubframeHistoryFallback) { | 2861 FrameNavigationEntry_DynamicSubframeHistoryFallback) { |
3061 // This test only makes sense when subframe FrameNavigationEntries are in use. | |
3062 if (!SiteIsolationPolicy::UseSubframeNavigationEntries()) | |
3063 return; | |
3064 | |
3065 // 1. Start on a page with a script-generated iframe. The iframe has a | 2862 // 1. Start on a page with a script-generated iframe. The iframe has a |
3066 // dynamic name, starts at about:blank, and gets navigated to a dynamic data | 2863 // dynamic name, starts at about:blank, and gets navigated to a dynamic data |
3067 // URL as the page is loading. | 2864 // URL as the page is loading. |
3068 GURL main_url_a(embedded_test_server()->GetURL( | 2865 GURL main_url_a(embedded_test_server()->GetURL( |
3069 "a.com", "/navigation_controller/dynamic_iframe.html")); | 2866 "a.com", "/navigation_controller/dynamic_iframe.html")); |
3070 { | 2867 { |
3071 // Wait until the data URL has committed, even if load stop happens after | 2868 // Wait until the data URL has committed, even if load stop happens after |
3072 // about:blank load. | 2869 // about:blank load. |
3073 DataUrlCommitObserver data_observer(shell()->web_contents()); | 2870 DataUrlCommitObserver data_observer(shell()->web_contents()); |
3074 EXPECT_TRUE(NavigateToURL(shell(), main_url_a)); | 2871 EXPECT_TRUE(NavigateToURL(shell(), main_url_a)); |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3164 root->child_at(0), | 2961 root->child_at(0), |
3165 "domAutomationController.send(document.body.innerHTML)", &value)); | 2962 "domAutomationController.send(document.body.innerHTML)", &value)); |
3166 EXPECT_EQ(expected_text, value); | 2963 EXPECT_EQ(expected_text, value); |
3167 } | 2964 } |
3168 | 2965 |
3169 EXPECT_EQ(1, controller.GetEntryCount()); | 2966 EXPECT_EQ(1, controller.GetEntryCount()); |
3170 EXPECT_EQ(0, controller.GetLastCommittedEntryIndex()); | 2967 EXPECT_EQ(0, controller.GetLastCommittedEntryIndex()); |
3171 NavigationEntryImpl* entry = controller.GetLastCommittedEntry(); | 2968 NavigationEntryImpl* entry = controller.GetLastCommittedEntry(); |
3172 | 2969 |
3173 // The entry should have a FrameNavigationEntry for the blank subframe. | 2970 // The entry should have a FrameNavigationEntry for the blank subframe. |
3174 if (SiteIsolationPolicy::UseSubframeNavigationEntries()) { | 2971 ASSERT_EQ(1U, entry->root_node()->children.size()); |
3175 ASSERT_EQ(1U, entry->root_node()->children.size()); | 2972 EXPECT_EQ(blank_url, entry->root_node()->children[0]->frame_entry->url()); |
3176 EXPECT_EQ(blank_url, entry->root_node()->children[0]->frame_entry->url()); | |
3177 } | |
3178 | 2973 |
3179 // 2. Navigate the main frame, destroying the frames. | 2974 // 2. Navigate the main frame, destroying the frames. |
3180 GURL main_url_2(embedded_test_server()->GetURL( | 2975 GURL main_url_2(embedded_test_server()->GetURL( |
3181 "/navigation_controller/simple_page_1.html")); | 2976 "/navigation_controller/simple_page_1.html")); |
3182 EXPECT_TRUE(NavigateToURL(shell(), main_url_2)); | 2977 EXPECT_TRUE(NavigateToURL(shell(), main_url_2)); |
3183 ASSERT_EQ(0U, root->child_count()); | 2978 ASSERT_EQ(0U, root->child_count()); |
3184 EXPECT_EQ(main_url_2, root->current_url()); | 2979 EXPECT_EQ(main_url_2, root->current_url()); |
3185 | 2980 |
3186 EXPECT_EQ(2, controller.GetEntryCount()); | 2981 EXPECT_EQ(2, controller.GetEntryCount()); |
3187 EXPECT_EQ(1, controller.GetLastCommittedEntryIndex()); | 2982 EXPECT_EQ(1, controller.GetLastCommittedEntryIndex()); |
(...skipping 15 matching lines...) Expand all Loading... | |
3203 root->child_at(0), | 2998 root->child_at(0), |
3204 "domAutomationController.send(document.body.innerHTML)", &value)); | 2999 "domAutomationController.send(document.body.innerHTML)", &value)); |
3205 EXPECT_EQ(expected_text, value); | 3000 EXPECT_EQ(expected_text, value); |
3206 } | 3001 } |
3207 | 3002 |
3208 EXPECT_EQ(2, controller.GetEntryCount()); | 3003 EXPECT_EQ(2, controller.GetEntryCount()); |
3209 EXPECT_EQ(0, controller.GetLastCommittedEntryIndex()); | 3004 EXPECT_EQ(0, controller.GetLastCommittedEntryIndex()); |
3210 EXPECT_EQ(entry, controller.GetLastCommittedEntry()); | 3005 EXPECT_EQ(entry, controller.GetLastCommittedEntry()); |
3211 | 3006 |
3212 // The entry should have a FrameNavigationEntry for the blank subframe. | 3007 // The entry should have a FrameNavigationEntry for the blank subframe. |
3213 if (SiteIsolationPolicy::UseSubframeNavigationEntries()) { | 3008 ASSERT_EQ(1U, entry->root_node()->children.size()); |
3214 ASSERT_EQ(1U, entry->root_node()->children.size()); | 3009 EXPECT_EQ(blank_url, entry->root_node()->children[0]->frame_entry->url()); |
3215 EXPECT_EQ(blank_url, entry->root_node()->children[0]->frame_entry->url()); | |
3216 } | |
3217 } | 3010 } |
3218 | 3011 |
3219 // Verify that we correctly load nested iframes injected into a page if we go | 3012 // Verify that we correctly load nested iframes injected into a page if we go |
3220 // back and recreate them. Also confirm that form values are not restored for | 3013 // back and recreate them. Also confirm that form values are not restored for |
3221 // forms injected into about:blank pages. See https://crbug.com/657896. | 3014 // forms injected into about:blank pages. See https://crbug.com/657896. |
3222 IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest, | 3015 IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest, |
3223 FrameNavigationEntry_RecreatedInjectedBlankSubframe) { | 3016 FrameNavigationEntry_RecreatedInjectedBlankSubframe) { |
3224 // 1. Start on a page that injects a nested iframe into an injected | 3017 // 1. Start on a page that injects a nested iframe into an injected |
3225 // about:blank iframe. | 3018 // about:blank iframe. |
3226 GURL main_url(embedded_test_server()->GetURL( | 3019 GURL main_url(embedded_test_server()->GetURL( |
(...skipping 14 matching lines...) Expand all Loading... | |
3241 ASSERT_EQ(0U, root->child_at(0)->child_at(0)->child_count()); | 3034 ASSERT_EQ(0U, root->child_at(0)->child_at(0)->child_count()); |
3242 EXPECT_EQ(main_url, root->current_url()); | 3035 EXPECT_EQ(main_url, root->current_url()); |
3243 EXPECT_EQ(blank_url, root->child_at(0)->current_url()); | 3036 EXPECT_EQ(blank_url, root->child_at(0)->current_url()); |
3244 EXPECT_EQ(inner_url, root->child_at(0)->child_at(0)->current_url()); | 3037 EXPECT_EQ(inner_url, root->child_at(0)->child_at(0)->current_url()); |
3245 | 3038 |
3246 EXPECT_EQ(1, controller.GetEntryCount()); | 3039 EXPECT_EQ(1, controller.GetEntryCount()); |
3247 EXPECT_EQ(0, controller.GetLastCommittedEntryIndex()); | 3040 EXPECT_EQ(0, controller.GetLastCommittedEntryIndex()); |
3248 NavigationEntryImpl* entry = controller.GetLastCommittedEntry(); | 3041 NavigationEntryImpl* entry = controller.GetLastCommittedEntry(); |
3249 | 3042 |
3250 // The entry should have FrameNavigationEntries for the subframes. | 3043 // The entry should have FrameNavigationEntries for the subframes. |
3251 if (SiteIsolationPolicy::UseSubframeNavigationEntries()) { | 3044 ASSERT_EQ(1U, entry->root_node()->children.size()); |
3252 ASSERT_EQ(1U, entry->root_node()->children.size()); | 3045 EXPECT_EQ(blank_url, entry->root_node()->children[0]->frame_entry->url()); |
3253 EXPECT_EQ(blank_url, entry->root_node()->children[0]->frame_entry->url()); | 3046 EXPECT_EQ(inner_url, |
3254 EXPECT_EQ(inner_url, | 3047 entry->root_node()->children[0]->children[0]->frame_entry->url()); |
3255 entry->root_node()->children[0]->children[0]->frame_entry->url()); | |
3256 } | |
3257 | 3048 |
3258 // Set a value in the form which will be stored in the PageState. | 3049 // Set a value in the form which will be stored in the PageState. |
3259 EXPECT_TRUE( | 3050 EXPECT_TRUE( |
3260 ExecuteScript(root->child_at(0)->child_at(0), | 3051 ExecuteScript(root->child_at(0)->child_at(0), |
3261 "document.getElementById('itext').value = 'modified';")); | 3052 "document.getElementById('itext').value = 'modified';")); |
3262 | 3053 |
3263 // 2. Navigate the main frame same-site, destroying the subframes. | 3054 // 2. Navigate the main frame same-site, destroying the subframes. |
3264 GURL main_url_2(embedded_test_server()->GetURL( | 3055 GURL main_url_2(embedded_test_server()->GetURL( |
3265 "/navigation_controller/simple_page_1.html")); | 3056 "/navigation_controller/simple_page_1.html")); |
3266 EXPECT_TRUE(NavigateToURL(shell(), main_url_2)); | 3057 EXPECT_TRUE(NavigateToURL(shell(), main_url_2)); |
(...skipping 14 matching lines...) Expand all Loading... | |
3281 EXPECT_EQ(blank_url, root->child_at(0)->current_url()); | 3072 EXPECT_EQ(blank_url, root->child_at(0)->current_url()); |
3282 | 3073 |
3283 // Verify that the inner iframe went to the correct URL. | 3074 // Verify that the inner iframe went to the correct URL. |
3284 EXPECT_EQ(inner_url, root->child_at(0)->child_at(0)->current_url()); | 3075 EXPECT_EQ(inner_url, root->child_at(0)->child_at(0)->current_url()); |
3285 | 3076 |
3286 EXPECT_EQ(2, controller.GetEntryCount()); | 3077 EXPECT_EQ(2, controller.GetEntryCount()); |
3287 EXPECT_EQ(0, controller.GetLastCommittedEntryIndex()); | 3078 EXPECT_EQ(0, controller.GetLastCommittedEntryIndex()); |
3288 EXPECT_EQ(entry, controller.GetLastCommittedEntry()); | 3079 EXPECT_EQ(entry, controller.GetLastCommittedEntry()); |
3289 | 3080 |
3290 // The entry should have FrameNavigationEntries for the subframes. | 3081 // The entry should have FrameNavigationEntries for the subframes. |
3291 if (SiteIsolationPolicy::UseSubframeNavigationEntries()) { | 3082 ASSERT_EQ(1U, entry->root_node()->children.size()); |
3292 ASSERT_EQ(1U, entry->root_node()->children.size()); | 3083 EXPECT_EQ(blank_url, entry->root_node()->children[0]->frame_entry->url()); |
3293 EXPECT_EQ(blank_url, entry->root_node()->children[0]->frame_entry->url()); | 3084 EXPECT_EQ(inner_url, |
3294 EXPECT_EQ(inner_url, | 3085 entry->root_node()->children[0]->children[0]->frame_entry->url()); |
3295 entry->root_node()->children[0]->children[0]->frame_entry->url()); | |
3296 } | |
3297 | 3086 |
3298 // With injected about:blank iframes, we never restore form values from | 3087 // With injected about:blank iframes, we never restore form values from |
3299 // PageState. | 3088 // PageState. |
3300 std::string form_value = "fail"; | 3089 std::string form_value = "fail"; |
3301 EXPECT_TRUE( | 3090 EXPECT_TRUE( |
3302 ExecuteScriptAndExtractString(root->child_at(0)->child_at(0), | 3091 ExecuteScriptAndExtractString(root->child_at(0)->child_at(0), |
3303 "window.domAutomationController.send(" | 3092 "window.domAutomationController.send(" |
3304 "document.getElementById('itext').value);", | 3093 "document.getElementById('itext').value);", |
3305 &form_value)); | 3094 &form_value)); |
3306 EXPECT_EQ("", form_value); | 3095 EXPECT_EQ("", form_value); |
(...skipping 29 matching lines...) Expand all Loading... | |
3336 ASSERT_EQ(0U, root->child_at(0)->child_at(0)->child_count()); | 3125 ASSERT_EQ(0U, root->child_at(0)->child_at(0)->child_count()); |
3337 EXPECT_EQ(main_url, root->current_url()); | 3126 EXPECT_EQ(main_url, root->current_url()); |
3338 EXPECT_EQ(srcdoc_url, root->child_at(0)->current_url()); | 3127 EXPECT_EQ(srcdoc_url, root->child_at(0)->current_url()); |
3339 EXPECT_EQ(inner_url, root->child_at(0)->child_at(0)->current_url()); | 3128 EXPECT_EQ(inner_url, root->child_at(0)->child_at(0)->current_url()); |
3340 | 3129 |
3341 EXPECT_EQ(1, controller.GetEntryCount()); | 3130 EXPECT_EQ(1, controller.GetEntryCount()); |
3342 EXPECT_EQ(0, controller.GetLastCommittedEntryIndex()); | 3131 EXPECT_EQ(0, controller.GetLastCommittedEntryIndex()); |
3343 NavigationEntryImpl* entry = controller.GetLastCommittedEntry(); | 3132 NavigationEntryImpl* entry = controller.GetLastCommittedEntry(); |
3344 | 3133 |
3345 // The entry should have FrameNavigationEntries for the subframes. | 3134 // The entry should have FrameNavigationEntries for the subframes. |
3346 if (SiteIsolationPolicy::UseSubframeNavigationEntries()) { | 3135 ASSERT_EQ(1U, entry->root_node()->children.size()); |
3347 ASSERT_EQ(1U, entry->root_node()->children.size()); | 3136 EXPECT_EQ(srcdoc_url, entry->root_node()->children[0]->frame_entry->url()); |
3348 EXPECT_EQ(srcdoc_url, entry->root_node()->children[0]->frame_entry->url()); | 3137 EXPECT_EQ(inner_url, |
3349 EXPECT_EQ(inner_url, | 3138 entry->root_node()->children[0]->children[0]->frame_entry->url()); |
3350 entry->root_node()->children[0]->children[0]->frame_entry->url()); | |
3351 } | |
3352 | 3139 |
3353 // Set a value in the form which will be stored in the PageState. | 3140 // Set a value in the form which will be stored in the PageState. |
3354 EXPECT_TRUE( | 3141 EXPECT_TRUE( |
3355 ExecuteScript(root->child_at(0)->child_at(0), | 3142 ExecuteScript(root->child_at(0)->child_at(0), |
3356 "document.getElementById('itext').value = 'modified';")); | 3143 "document.getElementById('itext').value = 'modified';")); |
3357 | 3144 |
3358 // 2. Navigate the main frame same-site, destroying the subframes. | 3145 // 2. Navigate the main frame same-site, destroying the subframes. |
3359 GURL main_url_2(embedded_test_server()->GetURL( | 3146 GURL main_url_2(embedded_test_server()->GetURL( |
3360 "/navigation_controller/simple_page_1.html")); | 3147 "/navigation_controller/simple_page_1.html")); |
3361 EXPECT_TRUE(NavigateToURL(shell(), main_url_2)); | 3148 EXPECT_TRUE(NavigateToURL(shell(), main_url_2)); |
(...skipping 16 matching lines...) Expand all Loading... | |
3378 EXPECT_EQ(srcdoc_url, root->child_at(0)->current_url()); | 3165 EXPECT_EQ(srcdoc_url, root->child_at(0)->current_url()); |
3379 | 3166 |
3380 // Verify that the inner iframe went to the correct URL. | 3167 // Verify that the inner iframe went to the correct URL. |
3381 EXPECT_EQ(inner_url, root->child_at(0)->child_at(0)->current_url()); | 3168 EXPECT_EQ(inner_url, root->child_at(0)->child_at(0)->current_url()); |
3382 | 3169 |
3383 EXPECT_EQ(2, controller.GetEntryCount()); | 3170 EXPECT_EQ(2, controller.GetEntryCount()); |
3384 EXPECT_EQ(0, controller.GetLastCommittedEntryIndex()); | 3171 EXPECT_EQ(0, controller.GetLastCommittedEntryIndex()); |
3385 EXPECT_EQ(entry, controller.GetLastCommittedEntry()); | 3172 EXPECT_EQ(entry, controller.GetLastCommittedEntry()); |
3386 | 3173 |
3387 // The entry should have FrameNavigationEntries for the subframes. | 3174 // The entry should have FrameNavigationEntries for the subframes. |
3388 if (SiteIsolationPolicy::UseSubframeNavigationEntries()) { | 3175 ASSERT_EQ(1U, entry->root_node()->children.size()); |
3389 ASSERT_EQ(1U, entry->root_node()->children.size()); | 3176 EXPECT_EQ(srcdoc_url, entry->root_node()->children[0]->frame_entry->url()); |
3390 EXPECT_EQ(srcdoc_url, entry->root_node()->children[0]->frame_entry->url()); | 3177 EXPECT_EQ(inner_url, |
3391 EXPECT_EQ(inner_url, | 3178 entry->root_node()->children[0]->children[0]->frame_entry->url()); |
3392 entry->root_node()->children[0]->children[0]->frame_entry->url()); | |
3393 } | |
3394 | 3179 |
3395 // With injected iframe srcdoc pages, we do restore form values from | 3180 // With injected iframe srcdoc pages, we do restore form values from |
3396 // PageState. | 3181 // PageState. |
3397 std::string form_value; | 3182 std::string form_value; |
3398 EXPECT_TRUE( | 3183 EXPECT_TRUE( |
3399 ExecuteScriptAndExtractString(root->child_at(0)->child_at(0), | 3184 ExecuteScriptAndExtractString(root->child_at(0)->child_at(0), |
3400 "window.domAutomationController.send(" | 3185 "window.domAutomationController.send(" |
3401 "document.getElementById('itext').value);", | 3186 "document.getElementById('itext').value);", |
3402 &form_value)); | 3187 &form_value)); |
3403 EXPECT_EQ("modified", form_value); | 3188 EXPECT_EQ("modified", form_value); |
(...skipping 21 matching lines...) Expand all Loading... | |
3425 | 3210 |
3426 // 2. Navigate the subframe to about:blank. | 3211 // 2. Navigate the subframe to about:blank. |
3427 GURL blank_url(url::kAboutBlankURL); | 3212 GURL blank_url(url::kAboutBlankURL); |
3428 NavigateFrameToURL(root->child_at(0), blank_url); | 3213 NavigateFrameToURL(root->child_at(0), blank_url); |
3429 EXPECT_EQ(blank_url, root->child_at(0)->current_url()); | 3214 EXPECT_EQ(blank_url, root->child_at(0)->current_url()); |
3430 EXPECT_EQ(2, controller.GetEntryCount()); | 3215 EXPECT_EQ(2, controller.GetEntryCount()); |
3431 EXPECT_EQ(1, controller.GetLastCommittedEntryIndex()); | 3216 EXPECT_EQ(1, controller.GetLastCommittedEntryIndex()); |
3432 NavigationEntryImpl* entry = controller.GetLastCommittedEntry(); | 3217 NavigationEntryImpl* entry = controller.GetLastCommittedEntry(); |
3433 | 3218 |
3434 // The entry should have a FrameNavigationEntry for the blank subframe. | 3219 // The entry should have a FrameNavigationEntry for the blank subframe. |
3435 if (SiteIsolationPolicy::UseSubframeNavigationEntries()) { | 3220 ASSERT_EQ(1U, entry->root_node()->children.size()); |
3436 ASSERT_EQ(1U, entry->root_node()->children.size()); | 3221 EXPECT_EQ(blank_url, entry->root_node()->children[0]->frame_entry->url()); |
3437 EXPECT_EQ(blank_url, entry->root_node()->children[0]->frame_entry->url()); | |
3438 } | |
3439 | 3222 |
3440 // 3. Navigate the main frame, destroying the frames. | 3223 // 3. Navigate the main frame, destroying the frames. |
3441 GURL main_url_2(embedded_test_server()->GetURL( | 3224 GURL main_url_2(embedded_test_server()->GetURL( |
3442 "/navigation_controller/simple_page_1.html")); | 3225 "/navigation_controller/simple_page_1.html")); |
3443 EXPECT_TRUE(NavigateToURL(shell(), main_url_2)); | 3226 EXPECT_TRUE(NavigateToURL(shell(), main_url_2)); |
3444 ASSERT_EQ(0U, root->child_count()); | 3227 ASSERT_EQ(0U, root->child_count()); |
3445 EXPECT_EQ(main_url_2, root->current_url()); | 3228 EXPECT_EQ(main_url_2, root->current_url()); |
3446 | 3229 |
3447 EXPECT_EQ(3, controller.GetEntryCount()); | 3230 EXPECT_EQ(3, controller.GetEntryCount()); |
3448 EXPECT_EQ(2, controller.GetLastCommittedEntryIndex()); | 3231 EXPECT_EQ(2, controller.GetLastCommittedEntryIndex()); |
3449 | 3232 |
3450 // 3. Go back, recreating the iframe. | 3233 // 3. Go back, recreating the iframe. |
3451 { | 3234 { |
3452 TestNavigationObserver back_load_observer(shell()->web_contents()); | 3235 TestNavigationObserver back_load_observer(shell()->web_contents()); |
3453 controller.GoBack(); | 3236 controller.GoBack(); |
3454 back_load_observer.Wait(); | 3237 back_load_observer.Wait(); |
3455 } | 3238 } |
3456 ASSERT_EQ(1U, root->child_count()); | 3239 ASSERT_EQ(1U, root->child_count()); |
3457 EXPECT_EQ(main_url, root->current_url()); | 3240 EXPECT_EQ(main_url, root->current_url()); |
3458 EXPECT_EQ(blank_url, root->child_at(0)->current_url()); | 3241 EXPECT_EQ(blank_url, root->child_at(0)->current_url()); |
3459 | 3242 |
3460 EXPECT_EQ(3, controller.GetEntryCount()); | 3243 EXPECT_EQ(3, controller.GetEntryCount()); |
3461 EXPECT_EQ(1, controller.GetLastCommittedEntryIndex()); | 3244 EXPECT_EQ(1, controller.GetLastCommittedEntryIndex()); |
3462 EXPECT_EQ(entry, controller.GetLastCommittedEntry()); | 3245 EXPECT_EQ(entry, controller.GetLastCommittedEntry()); |
3463 | 3246 |
3464 // The entry should have a FrameNavigationEntry for the blank subframe. | 3247 // The entry should have a FrameNavigationEntry for the blank subframe. |
3465 if (SiteIsolationPolicy::UseSubframeNavigationEntries()) { | 3248 ASSERT_EQ(1U, entry->root_node()->children.size()); |
3466 ASSERT_EQ(1U, entry->root_node()->children.size()); | 3249 EXPECT_EQ(blank_url, entry->root_node()->children[0]->frame_entry->url()); |
3467 EXPECT_EQ(blank_url, entry->root_node()->children[0]->frame_entry->url()); | |
3468 } | |
3469 } | 3250 } |
3470 | 3251 |
3471 // Ensure we don't crash if an onload handler removes an about:blank frame after | 3252 // Ensure we don't crash if an onload handler removes an about:blank frame after |
3472 // recreating it on a back/forward. See https://crbug.com/638166. | 3253 // recreating it on a back/forward. See https://crbug.com/638166. |
3473 IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest, | 3254 IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest, |
3474 FrameNavigationEntry_RemoveRecreatedBlankSubframe) { | 3255 FrameNavigationEntry_RemoveRecreatedBlankSubframe) { |
3475 // 1. Start on a page that removes its about:blank iframe during onload. | 3256 // 1. Start on a page that removes its about:blank iframe during onload. |
3476 GURL main_url(embedded_test_server()->GetURL( | 3257 GURL main_url(embedded_test_server()->GetURL( |
3477 "/navigation_controller/remove_blank_iframe_on_load.html")); | 3258 "/navigation_controller/remove_blank_iframe_on_load.html")); |
3478 GURL blank_url(url::kAboutBlankURL); | 3259 GURL blank_url(url::kAboutBlankURL); |
3479 EXPECT_TRUE(NavigateToURL(shell(), main_url)); | 3260 EXPECT_TRUE(NavigateToURL(shell(), main_url)); |
3480 NavigationControllerImpl& controller = static_cast<NavigationControllerImpl&>( | 3261 NavigationControllerImpl& controller = static_cast<NavigationControllerImpl&>( |
3481 shell()->web_contents()->GetController()); | 3262 shell()->web_contents()->GetController()); |
3482 FrameTreeNode* root = static_cast<WebContentsImpl*>(shell()->web_contents()) | 3263 FrameTreeNode* root = static_cast<WebContentsImpl*>(shell()->web_contents()) |
3483 ->GetFrameTree() | 3264 ->GetFrameTree() |
3484 ->root(); | 3265 ->root(); |
3485 EXPECT_EQ(main_url, root->current_url()); | 3266 EXPECT_EQ(main_url, root->current_url()); |
3486 | 3267 |
3487 EXPECT_EQ(1, controller.GetEntryCount()); | 3268 EXPECT_EQ(1, controller.GetEntryCount()); |
3488 EXPECT_EQ(0, controller.GetLastCommittedEntryIndex()); | 3269 EXPECT_EQ(0, controller.GetLastCommittedEntryIndex()); |
3489 NavigationEntryImpl* entry = controller.GetLastCommittedEntry(); | 3270 NavigationEntryImpl* entry = controller.GetLastCommittedEntry(); |
3490 | 3271 |
3491 // The entry should have a FrameNavigationEntry for the blank subframe, even | 3272 // The entry should have a FrameNavigationEntry for the blank subframe, even |
3492 // though it is being removed from the page. | 3273 // though it is being removed from the page. |
3493 if (SiteIsolationPolicy::UseSubframeNavigationEntries()) { | 3274 ASSERT_EQ(1U, entry->root_node()->children.size()); |
3494 ASSERT_EQ(1U, entry->root_node()->children.size()); | 3275 EXPECT_EQ(blank_url, entry->root_node()->children[0]->frame_entry->url()); |
3495 EXPECT_EQ(blank_url, entry->root_node()->children[0]->frame_entry->url()); | |
3496 } | |
3497 | 3276 |
3498 // 2. Navigate the main frame, destroying the frames. | 3277 // 2. Navigate the main frame, destroying the frames. |
3499 GURL main_url_2(embedded_test_server()->GetURL( | 3278 GURL main_url_2(embedded_test_server()->GetURL( |
3500 "/navigation_controller/simple_page_1.html")); | 3279 "/navigation_controller/simple_page_1.html")); |
3501 EXPECT_TRUE(NavigateToURL(shell(), main_url_2)); | 3280 EXPECT_TRUE(NavigateToURL(shell(), main_url_2)); |
3502 ASSERT_EQ(0U, root->child_count()); | 3281 ASSERT_EQ(0U, root->child_count()); |
3503 EXPECT_EQ(main_url_2, root->current_url()); | 3282 EXPECT_EQ(main_url_2, root->current_url()); |
3504 | 3283 |
3505 EXPECT_EQ(2, controller.GetEntryCount()); | 3284 EXPECT_EQ(2, controller.GetEntryCount()); |
3506 EXPECT_EQ(1, controller.GetLastCommittedEntryIndex()); | 3285 EXPECT_EQ(1, controller.GetLastCommittedEntryIndex()); |
3507 | 3286 |
3508 // 3. Go back, recreating the iframe (and removing it again). | 3287 // 3. Go back, recreating the iframe (and removing it again). |
3509 { | 3288 { |
3510 TestNavigationObserver back_load_observer(shell()->web_contents()); | 3289 TestNavigationObserver back_load_observer(shell()->web_contents()); |
3511 controller.GoBack(); | 3290 controller.GoBack(); |
3512 back_load_observer.Wait(); | 3291 back_load_observer.Wait(); |
3513 } | 3292 } |
3514 EXPECT_EQ(main_url, root->current_url()); | 3293 EXPECT_EQ(main_url, root->current_url()); |
3515 | 3294 |
3516 // Check that the renderer is still alive. | 3295 // Check that the renderer is still alive. |
3517 EXPECT_TRUE(ExecuteScript(shell(), "console.log('Success');")); | 3296 EXPECT_TRUE(ExecuteScript(shell(), "console.log('Success');")); |
3518 | 3297 |
3519 EXPECT_EQ(2, controller.GetEntryCount()); | 3298 EXPECT_EQ(2, controller.GetEntryCount()); |
3520 EXPECT_EQ(0, controller.GetLastCommittedEntryIndex()); | 3299 EXPECT_EQ(0, controller.GetLastCommittedEntryIndex()); |
3521 EXPECT_EQ(entry, controller.GetLastCommittedEntry()); | 3300 EXPECT_EQ(entry, controller.GetLastCommittedEntry()); |
3522 | 3301 |
3523 // The entry should have a FrameNavigationEntry for the blank subframe. | 3302 // The entry should have a FrameNavigationEntry for the blank subframe. |
3524 if (SiteIsolationPolicy::UseSubframeNavigationEntries()) { | 3303 ASSERT_EQ(1U, entry->root_node()->children.size()); |
3525 ASSERT_EQ(1U, entry->root_node()->children.size()); | 3304 EXPECT_EQ(blank_url, entry->root_node()->children[0]->frame_entry->url()); |
3526 EXPECT_EQ(blank_url, entry->root_node()->children[0]->frame_entry->url()); | |
3527 } | |
3528 } | 3305 } |
3529 | 3306 |
3530 // Verifies that we clear the children FrameNavigationEntries if a history | 3307 // Verifies that we clear the children FrameNavigationEntries if a history |
3531 // navigation redirects, so that we don't try to load previous history items in | 3308 // navigation redirects, so that we don't try to load previous history items in |
3532 // frames of the new page. This should only clear the children of the frame | 3309 // frames of the new page. This should only clear the children of the frame |
3533 // that is redirecting. See https://crbug.com/585194. | 3310 // that is redirecting. See https://crbug.com/585194. |
3534 // | 3311 // |
3535 // Specifically, this test covers the following interesting cases: | 3312 // Specifically, this test covers the following interesting cases: |
3536 // - Subframe redirect when going back from a different main frame (step 4). | 3313 // - Subframe redirect when going back from a different main frame (step 4). |
3537 // - Subframe redirect without changing the main frame (step 6). | 3314 // - Subframe redirect without changing the main frame (step 6). |
3538 // - Main frame redirect, clearing the children (step 8). | 3315 // - Main frame redirect, clearing the children (step 8). |
3539 IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest, | 3316 IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest, |
3540 FrameNavigationEntry_BackWithRedirect) { | 3317 FrameNavigationEntry_BackWithRedirect) { |
3541 // 1. Start on a page with two frames. | 3318 // 1. Start on a page with two frames. |
3542 GURL initial_url( | 3319 GURL initial_url( |
3543 embedded_test_server()->GetURL("/frame_tree/page_with_two_frames.html")); | 3320 embedded_test_server()->GetURL("/frame_tree/page_with_two_frames.html")); |
3544 EXPECT_TRUE(NavigateToURL(shell(), initial_url)); | 3321 EXPECT_TRUE(NavigateToURL(shell(), initial_url)); |
3545 const NavigationControllerImpl& controller = | 3322 const NavigationControllerImpl& controller = |
3546 static_cast<const NavigationControllerImpl&>( | 3323 static_cast<const NavigationControllerImpl&>( |
3547 shell()->web_contents()->GetController()); | 3324 shell()->web_contents()->GetController()); |
3548 FrameTreeNode* root = static_cast<WebContentsImpl*>(shell()->web_contents()) | 3325 FrameTreeNode* root = static_cast<WebContentsImpl*>(shell()->web_contents()) |
3549 ->GetFrameTree() | 3326 ->GetFrameTree() |
3550 ->root(); | 3327 ->root(); |
3551 EXPECT_EQ(initial_url, root->current_url()); | 3328 EXPECT_EQ(initial_url, root->current_url()); |
3552 EXPECT_EQ(2U, root->child_count()); | 3329 EXPECT_EQ(2U, root->child_count()); |
3553 NavigationEntryImpl* entry1 = controller.GetLastCommittedEntry(); | 3330 NavigationEntryImpl* entry1 = controller.GetLastCommittedEntry(); |
3554 if (SiteIsolationPolicy::UseSubframeNavigationEntries()) | 3331 EXPECT_EQ(2U, entry1->root_node()->children.size()); |
3555 EXPECT_EQ(2U, entry1->root_node()->children.size()); | |
3556 | 3332 |
3557 // 2. Navigate both iframes to a page with a nested iframe. | 3333 // 2. Navigate both iframes to a page with a nested iframe. |
3558 GURL frame_url(embedded_test_server()->GetURL( | 3334 GURL frame_url(embedded_test_server()->GetURL( |
3559 "foo.com", "/navigation_controller/page_with_data_iframe.html")); | 3335 "foo.com", "/navigation_controller/page_with_data_iframe.html")); |
3560 GURL data_url("data:text/html,Subframe"); | 3336 GURL data_url("data:text/html,Subframe"); |
3561 NavigateFrameToURL(root->child_at(0), frame_url); | 3337 NavigateFrameToURL(root->child_at(0), frame_url); |
3562 NavigateFrameToURL(root->child_at(1), frame_url); | 3338 NavigateFrameToURL(root->child_at(1), frame_url); |
3563 EXPECT_EQ(initial_url, root->current_url()); | 3339 EXPECT_EQ(initial_url, root->current_url()); |
3564 EXPECT_EQ(frame_url, root->child_at(0)->current_url()); | 3340 EXPECT_EQ(frame_url, root->child_at(0)->current_url()); |
3565 EXPECT_EQ(data_url, root->child_at(0)->child_at(0)->current_url()); | 3341 EXPECT_EQ(data_url, root->child_at(0)->child_at(0)->current_url()); |
3566 EXPECT_EQ(frame_url, root->child_at(1)->current_url()); | 3342 EXPECT_EQ(frame_url, root->child_at(1)->current_url()); |
3567 EXPECT_EQ(data_url, root->child_at(1)->child_at(0)->current_url()); | 3343 EXPECT_EQ(data_url, root->child_at(1)->child_at(0)->current_url()); |
3568 | 3344 |
3569 EXPECT_EQ(3, controller.GetEntryCount()); | 3345 EXPECT_EQ(3, controller.GetEntryCount()); |
3570 EXPECT_EQ(2, controller.GetLastCommittedEntryIndex()); | 3346 EXPECT_EQ(2, controller.GetLastCommittedEntryIndex()); |
3571 NavigationEntryImpl* entry2 = controller.GetLastCommittedEntry(); | 3347 NavigationEntryImpl* entry2 = controller.GetLastCommittedEntry(); |
3572 // Verify subframe entries if they're enabled (e.g. in --site-per-process). | 3348 |
3573 if (SiteIsolationPolicy::UseSubframeNavigationEntries()) { | 3349 // Verify subframe entries. |
3574 NavigationEntryImpl::TreeNode* root_node = entry2->root_node(); | 3350 NavigationEntryImpl::TreeNode* root_node = entry2->root_node(); |
3575 ASSERT_EQ(2U, root_node->children.size()); | 3351 ASSERT_EQ(2U, root_node->children.size()); |
3576 EXPECT_EQ(frame_url, root_node->children[0]->frame_entry->url()); | 3352 EXPECT_EQ(frame_url, root_node->children[0]->frame_entry->url()); |
3577 EXPECT_EQ(data_url, | 3353 EXPECT_EQ(data_url, root_node->children[0]->children[0]->frame_entry->url()); |
3578 root_node->children[0]->children[0]->frame_entry->url()); | 3354 EXPECT_EQ(frame_url, root_node->children[1]->frame_entry->url()); |
3579 EXPECT_EQ(frame_url, root_node->children[1]->frame_entry->url()); | 3355 EXPECT_EQ(data_url, root_node->children[1]->children[0]->frame_entry->url()); |
3580 EXPECT_EQ(data_url, | |
3581 root_node->children[1]->children[0]->frame_entry->url()); | |
3582 } | |
3583 | 3356 |
3584 // Cause the first iframe to redirect when we come back later. It will go | 3357 // Cause the first iframe to redirect when we come back later. It will go |
3585 // cross-site to a page with an about:blank iframe. | 3358 // cross-site to a page with an about:blank iframe. |
3586 GURL frame_redirect_dest_url(embedded_test_server()->GetURL( | 3359 GURL frame_redirect_dest_url(embedded_test_server()->GetURL( |
3587 "bar.com", "/navigation_controller/page_with_iframe.html")); | 3360 "bar.com", "/navigation_controller/page_with_iframe.html")); |
3588 GURL blank_url(url::kAboutBlankURL); | 3361 GURL blank_url(url::kAboutBlankURL); |
3589 { | 3362 { |
3590 TestNavigationObserver observer(shell()->web_contents()); | 3363 TestNavigationObserver observer(shell()->web_contents()); |
3591 std::string script = "history.replaceState({}, '', '/server-redirect?" + | 3364 std::string script = "history.replaceState({}, '', '/server-redirect?" + |
3592 frame_redirect_dest_url.spec() + "')"; | 3365 frame_redirect_dest_url.spec() + "')"; |
3593 EXPECT_TRUE(ExecuteScript(root->child_at(0), script)); | 3366 EXPECT_TRUE(ExecuteScript(root->child_at(0), script)); |
3594 observer.Wait(); | 3367 observer.Wait(); |
3595 } | 3368 } |
3596 | 3369 |
3597 // We should not have lost subframe entries for the nested frame. | 3370 // We should not have lost subframe entries for the nested frame. |
3598 EXPECT_EQ(3, controller.GetEntryCount()); | 3371 EXPECT_EQ(3, controller.GetEntryCount()); |
3599 EXPECT_EQ(2, controller.GetLastCommittedEntryIndex()); | 3372 EXPECT_EQ(2, controller.GetLastCommittedEntryIndex()); |
3600 if (SiteIsolationPolicy::UseSubframeNavigationEntries()) { | 3373 FrameNavigationEntry* nested_entry = |
3601 FrameNavigationEntry* nested_entry = | 3374 entry2->GetFrameEntry(root->child_at(0)->child_at(0)); |
3602 entry2->GetFrameEntry(root->child_at(0)->child_at(0)); | 3375 EXPECT_TRUE(nested_entry); |
3603 EXPECT_TRUE(nested_entry); | 3376 EXPECT_EQ(data_url, nested_entry->url()); |
3604 EXPECT_EQ(data_url, nested_entry->url()); | |
3605 } | |
3606 | 3377 |
3607 // 3. Navigate the main frame to a different page. When we come back, we'll | 3378 // 3. Navigate the main frame to a different page. When we come back, we'll |
3608 // commit the main frame first and have no pending entry when navigating the | 3379 // commit the main frame first and have no pending entry when navigating the |
3609 // subframes. | 3380 // subframes. |
3610 GURL url2(embedded_test_server()->GetURL( | 3381 GURL url2(embedded_test_server()->GetURL( |
3611 "/navigation_controller/simple_page_1.html")); | 3382 "/navigation_controller/simple_page_1.html")); |
3612 EXPECT_TRUE(NavigateToURL(shell(), url2)); | 3383 EXPECT_TRUE(NavigateToURL(shell(), url2)); |
3613 EXPECT_EQ(4, controller.GetEntryCount()); | 3384 EXPECT_EQ(4, controller.GetEntryCount()); |
3614 EXPECT_EQ(3, controller.GetLastCommittedEntryIndex()); | 3385 EXPECT_EQ(3, controller.GetLastCommittedEntryIndex()); |
3615 | 3386 |
3616 // 4. Go back. The first iframe should redirect to a cross-site page with a | 3387 // 4. Go back. The first iframe should redirect to a cross-site page with a |
3617 // different nested iframe. | 3388 // different nested iframe. |
3618 { | 3389 { |
3619 TestNavigationObserver back_load_observer(shell()->web_contents()); | 3390 TestNavigationObserver back_load_observer(shell()->web_contents()); |
3620 shell()->web_contents()->GetController().GoBack(); | 3391 shell()->web_contents()->GetController().GoBack(); |
3621 back_load_observer.Wait(); | 3392 back_load_observer.Wait(); |
3622 } | 3393 } |
3623 EXPECT_EQ(initial_url, root->current_url()); | 3394 EXPECT_EQ(initial_url, root->current_url()); |
3624 EXPECT_EQ(frame_redirect_dest_url, root->child_at(0)->current_url()); | 3395 EXPECT_EQ(frame_redirect_dest_url, root->child_at(0)->current_url()); |
3625 EXPECT_EQ(blank_url, root->child_at(0)->child_at(0)->current_url()); | 3396 EXPECT_EQ(blank_url, root->child_at(0)->child_at(0)->current_url()); |
3626 EXPECT_EQ(frame_url, root->child_at(1)->current_url()); | 3397 EXPECT_EQ(frame_url, root->child_at(1)->current_url()); |
3627 EXPECT_EQ(data_url, root->child_at(1)->child_at(0)->current_url()); | 3398 EXPECT_EQ(data_url, root->child_at(1)->child_at(0)->current_url()); |
3628 | 3399 |
3629 // Check the FrameNavigationEntries as well. | 3400 // Check the FrameNavigationEntries as well. |
3630 EXPECT_EQ(4, controller.GetEntryCount()); | 3401 EXPECT_EQ(4, controller.GetEntryCount()); |
3631 EXPECT_EQ(2, controller.GetLastCommittedEntryIndex()); | 3402 EXPECT_EQ(2, controller.GetLastCommittedEntryIndex()); |
3632 if (SiteIsolationPolicy::UseSubframeNavigationEntries()) { | 3403 EXPECT_EQ(frame_redirect_dest_url, |
3633 EXPECT_EQ(frame_redirect_dest_url, | 3404 entry2->GetFrameEntry(root->child_at(0))->url()); |
3634 entry2->GetFrameEntry(root->child_at(0))->url()); | 3405 EXPECT_EQ(blank_url, |
3635 EXPECT_EQ(blank_url, | 3406 entry2->GetFrameEntry(root->child_at(0)->child_at(0))->url()); |
3636 entry2->GetFrameEntry(root->child_at(0)->child_at(0))->url()); | 3407 EXPECT_EQ(frame_url, entry2->GetFrameEntry(root->child_at(1))->url()); |
3637 EXPECT_EQ(frame_url, entry2->GetFrameEntry(root->child_at(1))->url()); | 3408 EXPECT_EQ(data_url, |
3638 EXPECT_EQ(data_url, | 3409 entry2->GetFrameEntry(root->child_at(1)->child_at(0))->url()); |
3639 entry2->GetFrameEntry(root->child_at(1)->child_at(0))->url()); | |
3640 } | |
3641 | 3410 |
3642 // In --site-per-process, we're misclassifying the subframe redirect in step 6 | 3411 // In --site-per-process, we're misclassifying the subframe redirect in step 6 |
3643 // below. For now, skip the rest of the test in that mode. | 3412 // below. For now, skip the rest of the test in that mode. |
3644 // TODO(creis): Fix this in https://crbug.com/628782. | 3413 // TODO(creis): Fix this in https://crbug.com/628782. |
3645 if (AreAllSitesIsolatedForTesting()) | 3414 if (AreAllSitesIsolatedForTesting()) |
3646 return; | 3415 return; |
3647 | 3416 |
3648 // Now cause the second iframe to redirect when we come back to it. | 3417 // Now cause the second iframe to redirect when we come back to it. |
3649 { | 3418 { |
3650 TestNavigationObserver observer(shell()->web_contents()); | 3419 TestNavigationObserver observer(shell()->web_contents()); |
(...skipping 23 matching lines...) Expand all Loading... | |
3674 } | 3443 } |
3675 EXPECT_EQ(initial_url, root->current_url()); | 3444 EXPECT_EQ(initial_url, root->current_url()); |
3676 EXPECT_EQ(frame_redirect_dest_url, root->child_at(0)->current_url()); | 3445 EXPECT_EQ(frame_redirect_dest_url, root->child_at(0)->current_url()); |
3677 EXPECT_EQ(blank_url, root->child_at(0)->child_at(0)->current_url()); | 3446 EXPECT_EQ(blank_url, root->child_at(0)->child_at(0)->current_url()); |
3678 EXPECT_EQ(frame_redirect_dest_url, root->child_at(1)->current_url()); | 3447 EXPECT_EQ(frame_redirect_dest_url, root->child_at(1)->current_url()); |
3679 EXPECT_EQ(blank_url, root->child_at(1)->child_at(0)->current_url()); | 3448 EXPECT_EQ(blank_url, root->child_at(1)->child_at(0)->current_url()); |
3680 | 3449 |
3681 // Check the FrameNavigationEntries as well. | 3450 // Check the FrameNavigationEntries as well. |
3682 EXPECT_EQ(4, controller.GetEntryCount()); | 3451 EXPECT_EQ(4, controller.GetEntryCount()); |
3683 EXPECT_EQ(2, controller.GetLastCommittedEntryIndex()); | 3452 EXPECT_EQ(2, controller.GetLastCommittedEntryIndex()); |
3684 if (SiteIsolationPolicy::UseSubframeNavigationEntries()) { | 3453 EXPECT_EQ(frame_redirect_dest_url, |
3685 EXPECT_EQ(frame_redirect_dest_url, | 3454 entry2->GetFrameEntry(root->child_at(0))->url()); |
3686 entry2->GetFrameEntry(root->child_at(0))->url()); | 3455 EXPECT_EQ(blank_url, |
3687 EXPECT_EQ(blank_url, | 3456 entry2->GetFrameEntry(root->child_at(0)->child_at(0))->url()); |
3688 entry2->GetFrameEntry(root->child_at(0)->child_at(0))->url()); | 3457 EXPECT_EQ(frame_redirect_dest_url, |
3689 EXPECT_EQ(frame_redirect_dest_url, | 3458 entry2->GetFrameEntry(root->child_at(1))->url()); |
3690 entry2->GetFrameEntry(root->child_at(1))->url()); | 3459 EXPECT_EQ(blank_url, |
3691 EXPECT_EQ(blank_url, | 3460 entry2->GetFrameEntry(root->child_at(1)->child_at(0))->url()); |
3692 entry2->GetFrameEntry(root->child_at(1)->child_at(0))->url()); | |
3693 } | |
3694 | 3461 |
3695 // Now cause the main frame to redirect to a page with no frames when we come | 3462 // Now cause the main frame to redirect to a page with no frames when we come |
3696 // back to it. | 3463 // back to it. |
3697 GURL redirect_dest_url(embedded_test_server()->GetURL( | 3464 GURL redirect_dest_url(embedded_test_server()->GetURL( |
3698 "bar.com", "/navigation_controller/simple_page_2.html")); | 3465 "bar.com", "/navigation_controller/simple_page_2.html")); |
3699 { | 3466 { |
3700 TestNavigationObserver observer(shell()->web_contents()); | 3467 TestNavigationObserver observer(shell()->web_contents()); |
3701 std::string script = "history.replaceState({}, '', '/server-redirect?" + | 3468 std::string script = "history.replaceState({}, '', '/server-redirect?" + |
3702 redirect_dest_url.spec() + "')"; | 3469 redirect_dest_url.spec() + "')"; |
3703 EXPECT_TRUE(ExecuteScript(root, script)); | 3470 EXPECT_TRUE(ExecuteScript(root, script)); |
(...skipping 28 matching lines...) Expand all Loading... | |
3732 "/navigation_controller/page_with_data_iframe.html")); | 3499 "/navigation_controller/page_with_data_iframe.html")); |
3733 EXPECT_TRUE(NavigateToURL(shell(), initial_url)); | 3500 EXPECT_TRUE(NavigateToURL(shell(), initial_url)); |
3734 NavigationControllerImpl& controller = static_cast<NavigationControllerImpl&>( | 3501 NavigationControllerImpl& controller = static_cast<NavigationControllerImpl&>( |
3735 shell()->web_contents()->GetController()); | 3502 shell()->web_contents()->GetController()); |
3736 FrameTreeNode* root = static_cast<WebContentsImpl*>(shell()->web_contents()) | 3503 FrameTreeNode* root = static_cast<WebContentsImpl*>(shell()->web_contents()) |
3737 ->GetFrameTree() | 3504 ->GetFrameTree() |
3738 ->root(); | 3505 ->root(); |
3739 EXPECT_EQ(initial_url, root->current_url()); | 3506 EXPECT_EQ(initial_url, root->current_url()); |
3740 EXPECT_EQ(1U, root->child_count()); | 3507 EXPECT_EQ(1U, root->child_count()); |
3741 NavigationEntryImpl* entry1 = controller.GetLastCommittedEntry(); | 3508 NavigationEntryImpl* entry1 = controller.GetLastCommittedEntry(); |
3742 if (SiteIsolationPolicy::UseSubframeNavigationEntries()) | 3509 EXPECT_EQ(1U, entry1->root_node()->children.size()); |
3743 EXPECT_EQ(1U, entry1->root_node()->children.size()); | |
3744 | 3510 |
3745 // 2. Navigate the iframe to a page with a nested iframe. | 3511 // 2. Navigate the iframe to a page with a nested iframe. |
3746 GURL frame_url(embedded_test_server()->GetURL( | 3512 GURL frame_url(embedded_test_server()->GetURL( |
3747 "/navigation_controller/page_with_data_iframe.html")); | 3513 "/navigation_controller/page_with_data_iframe.html")); |
3748 GURL data_url("data:text/html,Subframe"); | 3514 GURL data_url("data:text/html,Subframe"); |
3749 NavigateFrameToURL(root->child_at(0), frame_url); | 3515 NavigateFrameToURL(root->child_at(0), frame_url); |
3750 EXPECT_EQ(initial_url, root->current_url()); | 3516 EXPECT_EQ(initial_url, root->current_url()); |
3751 EXPECT_EQ(frame_url, root->child_at(0)->current_url()); | 3517 EXPECT_EQ(frame_url, root->child_at(0)->current_url()); |
3752 EXPECT_EQ(data_url, root->child_at(0)->child_at(0)->current_url()); | 3518 EXPECT_EQ(data_url, root->child_at(0)->child_at(0)->current_url()); |
3753 | 3519 |
3754 EXPECT_EQ(2, controller.GetEntryCount()); | 3520 EXPECT_EQ(2, controller.GetEntryCount()); |
3755 EXPECT_EQ(1, controller.GetLastCommittedEntryIndex()); | 3521 EXPECT_EQ(1, controller.GetLastCommittedEntryIndex()); |
3756 NavigationEntryImpl* entry2 = controller.GetLastCommittedEntry(); | 3522 NavigationEntryImpl* entry2 = controller.GetLastCommittedEntry(); |
3757 // Verify subframe entries if they're enabled (e.g. in --site-per-process). | 3523 |
3758 if (SiteIsolationPolicy::UseSubframeNavigationEntries()) { | 3524 // Verify subframe entries. |
3759 NavigationEntryImpl::TreeNode* root_node = entry2->root_node(); | 3525 NavigationEntryImpl::TreeNode* root_node = entry2->root_node(); |
3760 ASSERT_EQ(1U, root_node->children.size()); | 3526 ASSERT_EQ(1U, root_node->children.size()); |
3761 EXPECT_EQ(frame_url, root_node->children[0]->frame_entry->url()); | 3527 EXPECT_EQ(frame_url, root_node->children[0]->frame_entry->url()); |
3762 EXPECT_EQ(data_url, | 3528 EXPECT_EQ(data_url, root_node->children[0]->children[0]->frame_entry->url()); |
3763 root_node->children[0]->children[0]->frame_entry->url()); | |
3764 } | |
3765 | 3529 |
3766 // Cause the iframe to redirect when we come back later. It will go | 3530 // Cause the iframe to redirect when we come back later. It will go |
3767 // same-origin to a page with an about:blank iframe. | 3531 // same-origin to a page with an about:blank iframe. |
3768 GURL frame_redirect_dest_url(embedded_test_server()->GetURL( | 3532 GURL frame_redirect_dest_url(embedded_test_server()->GetURL( |
3769 "/navigation_controller/page_with_iframe.html")); | 3533 "/navigation_controller/page_with_iframe.html")); |
3770 { | 3534 { |
3771 TestNavigationObserver observer(shell()->web_contents()); | 3535 TestNavigationObserver observer(shell()->web_contents()); |
3772 std::string script = "history.replaceState({}, '', '/server-redirect?" + | 3536 std::string script = "history.replaceState({}, '', '/server-redirect?" + |
3773 frame_redirect_dest_url.spec() + "')"; | 3537 frame_redirect_dest_url.spec() + "')"; |
3774 EXPECT_TRUE(ExecuteScript(root->child_at(0), script)); | 3538 EXPECT_TRUE(ExecuteScript(root->child_at(0), script)); |
3775 observer.Wait(); | 3539 observer.Wait(); |
3776 } | 3540 } |
3777 | 3541 |
3778 // We should not have lost subframe entries for the nested frame. | 3542 // We should not have lost subframe entries for the nested frame. |
3779 EXPECT_EQ(2, controller.GetEntryCount()); | 3543 EXPECT_EQ(2, controller.GetEntryCount()); |
3780 EXPECT_EQ(1, controller.GetLastCommittedEntryIndex()); | 3544 EXPECT_EQ(1, controller.GetLastCommittedEntryIndex()); |
3781 if (SiteIsolationPolicy::UseSubframeNavigationEntries()) { | 3545 FrameNavigationEntry* nested_entry = |
3782 FrameNavigationEntry* nested_entry = | 3546 entry2->GetFrameEntry(root->child_at(0)->child_at(0)); |
3783 entry2->GetFrameEntry(root->child_at(0)->child_at(0)); | 3547 EXPECT_TRUE(nested_entry); |
3784 EXPECT_TRUE(nested_entry); | 3548 EXPECT_EQ(data_url, nested_entry->url()); |
3785 EXPECT_EQ(data_url, nested_entry->url()); | |
3786 } | |
3787 | 3549 |
3788 // 3. Navigate the main frame to a different page. When we come back, we'll | 3550 // 3. Navigate the main frame to a different page. When we come back, we'll |
3789 // commit the main frame first and have no pending entry when navigating the | 3551 // commit the main frame first and have no pending entry when navigating the |
3790 // subframes. | 3552 // subframes. |
3791 GURL url2(embedded_test_server()->GetURL( | 3553 GURL url2(embedded_test_server()->GetURL( |
3792 "/navigation_controller/simple_page_1.html")); | 3554 "/navigation_controller/simple_page_1.html")); |
3793 EXPECT_TRUE(NavigateToURL(shell(), url2)); | 3555 EXPECT_TRUE(NavigateToURL(shell(), url2)); |
3794 EXPECT_EQ(3, controller.GetEntryCount()); | 3556 EXPECT_EQ(3, controller.GetEntryCount()); |
3795 EXPECT_EQ(2, controller.GetLastCommittedEntryIndex()); | 3557 EXPECT_EQ(2, controller.GetLastCommittedEntryIndex()); |
3796 | 3558 |
3797 // 4. Go back. The first iframe should redirect to a same-origin page with a | 3559 // 4. Go back. The first iframe should redirect to a same-origin page with a |
3798 // different nested iframe. | 3560 // different nested iframe. |
3799 { | 3561 { |
3800 TestNavigationObserver back_load_observer(shell()->web_contents()); | 3562 TestNavigationObserver back_load_observer(shell()->web_contents()); |
3801 controller.GoBack(); | 3563 controller.GoBack(); |
3802 back_load_observer.Wait(); | 3564 back_load_observer.Wait(); |
3803 } | 3565 } |
3804 GURL blank_url(url::kAboutBlankURL); | 3566 GURL blank_url(url::kAboutBlankURL); |
3805 EXPECT_EQ(initial_url, root->current_url()); | 3567 EXPECT_EQ(initial_url, root->current_url()); |
3806 EXPECT_EQ(frame_redirect_dest_url, root->child_at(0)->current_url()); | 3568 EXPECT_EQ(frame_redirect_dest_url, root->child_at(0)->current_url()); |
3807 EXPECT_EQ(blank_url, root->child_at(0)->child_at(0)->current_url()); | 3569 EXPECT_EQ(blank_url, root->child_at(0)->child_at(0)->current_url()); |
3808 | 3570 |
3809 // Check the FrameNavigationEntries as well. | 3571 // Check the FrameNavigationEntries as well. |
3810 EXPECT_EQ(3, controller.GetEntryCount()); | 3572 EXPECT_EQ(3, controller.GetEntryCount()); |
3811 EXPECT_EQ(1, controller.GetLastCommittedEntryIndex()); | 3573 EXPECT_EQ(1, controller.GetLastCommittedEntryIndex()); |
3812 if (SiteIsolationPolicy::UseSubframeNavigationEntries()) { | 3574 EXPECT_EQ(frame_redirect_dest_url, |
3813 EXPECT_EQ(frame_redirect_dest_url, | 3575 entry2->GetFrameEntry(root->child_at(0))->url()); |
3814 entry2->GetFrameEntry(root->child_at(0))->url()); | 3576 EXPECT_EQ(blank_url, |
3815 EXPECT_EQ(blank_url, | 3577 entry2->GetFrameEntry(root->child_at(0)->child_at(0))->url()); |
3816 entry2->GetFrameEntry(root->child_at(0)->child_at(0))->url()); | |
3817 } | |
3818 | 3578 |
3819 // Now cause the main frame to redirect to a page with no frames when we come | 3579 // Now cause the main frame to redirect to a page with no frames when we come |
3820 // back to it. | 3580 // back to it. |
3821 GURL redirect_dest_url(embedded_test_server()->GetURL( | 3581 GURL redirect_dest_url(embedded_test_server()->GetURL( |
3822 "/navigation_controller/simple_page_2.html")); | 3582 "/navigation_controller/simple_page_2.html")); |
3823 { | 3583 { |
3824 TestNavigationObserver observer(shell()->web_contents()); | 3584 TestNavigationObserver observer(shell()->web_contents()); |
3825 std::string script = "history.replaceState({}, '', '/server-redirect?" + | 3585 std::string script = "history.replaceState({}, '', '/server-redirect?" + |
3826 redirect_dest_url.spec() + "')"; | 3586 redirect_dest_url.spec() + "')"; |
3827 EXPECT_TRUE(ExecuteScript(root, script)); | 3587 EXPECT_TRUE(ExecuteScript(root, script)); |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3864 ->root(); | 3624 ->root(); |
3865 ASSERT_EQ(1U, root->child_count()); | 3625 ASSERT_EQ(1U, root->child_count()); |
3866 ASSERT_EQ(0U, root->child_at(0)->child_count()); | 3626 ASSERT_EQ(0U, root->child_at(0)->child_count()); |
3867 EXPECT_EQ(main_url_a, root->current_url()); | 3627 EXPECT_EQ(main_url_a, root->current_url()); |
3868 EXPECT_EQ(data_url, root->child_at(0)->current_url()); | 3628 EXPECT_EQ(data_url, root->child_at(0)->current_url()); |
3869 | 3629 |
3870 EXPECT_EQ(1, controller.GetEntryCount()); | 3630 EXPECT_EQ(1, controller.GetEntryCount()); |
3871 EXPECT_EQ(0, controller.GetLastCommittedEntryIndex()); | 3631 EXPECT_EQ(0, controller.GetLastCommittedEntryIndex()); |
3872 NavigationEntryImpl* entry1 = controller.GetLastCommittedEntry(); | 3632 NavigationEntryImpl* entry1 = controller.GetLastCommittedEntry(); |
3873 | 3633 |
3874 // Verify subframe entries if they're enabled (e.g. in --site-per-process). | 3634 // The entry should have a FrameNavigationEntry for the data subframe. |
3875 if (SiteIsolationPolicy::UseSubframeNavigationEntries()) { | 3635 ASSERT_EQ(1U, entry1->root_node()->children.size()); |
3876 // The entry should have a FrameNavigationEntry for the data subframe. | 3636 EXPECT_EQ(data_url, entry1->root_node()->children[0]->frame_entry->url()); |
3877 ASSERT_EQ(1U, entry1->root_node()->children.size()); | |
3878 EXPECT_EQ(data_url, entry1->root_node()->children[0]->frame_entry->url()); | |
3879 } else { | |
3880 // There are no subframe FrameNavigationEntries by default. | |
3881 EXPECT_EQ(0U, entry1->root_node()->children.size()); | |
3882 } | |
3883 | 3637 |
3884 // 2. Navigate the iframe cross-site. | 3638 // 2. Navigate the iframe cross-site. |
3885 GURL frame_url_b(embedded_test_server()->GetURL( | 3639 GURL frame_url_b(embedded_test_server()->GetURL( |
3886 "b.com", "/navigation_controller/simple_page_1.html")); | 3640 "b.com", "/navigation_controller/simple_page_1.html")); |
3887 { | 3641 { |
3888 FrameNavigateParamsCapturer capturer(root->child_at(0)); | 3642 FrameNavigateParamsCapturer capturer(root->child_at(0)); |
3889 NavigateFrameToURL(root->child_at(0), frame_url_b); | 3643 NavigateFrameToURL(root->child_at(0), frame_url_b); |
3890 capturer.Wait(); | 3644 capturer.Wait(); |
3891 } | 3645 } |
3892 ASSERT_EQ(1U, root->child_count()); | 3646 ASSERT_EQ(1U, root->child_count()); |
3893 EXPECT_EQ(main_url_a, root->current_url()); | 3647 EXPECT_EQ(main_url_a, root->current_url()); |
3894 EXPECT_EQ(frame_url_b, root->child_at(0)->current_url()); | 3648 EXPECT_EQ(frame_url_b, root->child_at(0)->current_url()); |
3895 | 3649 |
3896 EXPECT_EQ(2, controller.GetEntryCount()); | 3650 EXPECT_EQ(2, controller.GetEntryCount()); |
3897 EXPECT_EQ(1, controller.GetLastCommittedEntryIndex()); | 3651 EXPECT_EQ(1, controller.GetLastCommittedEntryIndex()); |
3898 NavigationEntryImpl* entry2 = controller.GetLastCommittedEntry(); | 3652 NavigationEntryImpl* entry2 = controller.GetLastCommittedEntry(); |
3899 | 3653 |
3900 // Verify subframe entries if they're enabled (e.g. in --site-per-process). | 3654 // The entry should have a FrameNavigationEntry for the b.com subframe. |
3901 if (SiteIsolationPolicy::UseSubframeNavigationEntries()) { | 3655 ASSERT_EQ(1U, entry2->root_node()->children.size()); |
3902 // The entry should have a FrameNavigationEntry for the b.com subframe. | 3656 EXPECT_EQ(frame_url_b, entry2->root_node()->children[0]->frame_entry->url()); |
3903 ASSERT_EQ(1U, entry2->root_node()->children.size()); | |
3904 EXPECT_EQ(frame_url_b, | |
3905 entry2->root_node()->children[0]->frame_entry->url()); | |
3906 } else { | |
3907 // There are no subframe FrameNavigationEntries by default. | |
3908 EXPECT_EQ(0U, entry2->root_node()->children.size()); | |
3909 } | |
3910 | 3657 |
3911 // 3. Navigate main frame cross-site, destroying the frames. | 3658 // 3. Navigate main frame cross-site, destroying the frames. |
3912 GURL main_url_c(embedded_test_server()->GetURL( | 3659 GURL main_url_c(embedded_test_server()->GetURL( |
3913 "c.com", "/navigation_controller/simple_page_2.html")); | 3660 "c.com", "/navigation_controller/simple_page_2.html")); |
3914 EXPECT_TRUE(NavigateToURL(shell(), main_url_c)); | 3661 EXPECT_TRUE(NavigateToURL(shell(), main_url_c)); |
3915 ASSERT_EQ(0U, root->child_count()); | 3662 ASSERT_EQ(0U, root->child_count()); |
3916 EXPECT_EQ(main_url_c, root->current_url()); | 3663 EXPECT_EQ(main_url_c, root->current_url()); |
3917 | 3664 |
3918 EXPECT_EQ(3, controller.GetEntryCount()); | 3665 EXPECT_EQ(3, controller.GetEntryCount()); |
3919 EXPECT_EQ(2, controller.GetLastCommittedEntryIndex()); | 3666 EXPECT_EQ(2, controller.GetLastCommittedEntryIndex()); |
3920 NavigationEntryImpl* entry3 = controller.GetLastCommittedEntry(); | 3667 NavigationEntryImpl* entry3 = controller.GetLastCommittedEntry(); |
3921 EXPECT_EQ(0U, entry3->root_node()->children.size()); | 3668 EXPECT_EQ(0U, entry3->root_node()->children.size()); |
3922 | 3669 |
3923 // 4. Create a NavigationEntry with the same PageState as |entry2| and verify | 3670 // 4. Create a NavigationEntry with the same PageState as |entry2| and verify |
3924 // it has the same FrameNavigationEntry structure. | 3671 // it has the same FrameNavigationEntry structure. |
3925 std::unique_ptr<NavigationEntryImpl> restored_entry = | 3672 std::unique_ptr<NavigationEntryImpl> restored_entry = |
3926 NavigationEntryImpl::FromNavigationEntry( | 3673 NavigationEntryImpl::FromNavigationEntry( |
3927 NavigationControllerImpl::CreateNavigationEntry( | 3674 NavigationControllerImpl::CreateNavigationEntry( |
3928 main_url_a, Referrer(), ui::PAGE_TRANSITION_RELOAD, false, | 3675 main_url_a, Referrer(), ui::PAGE_TRANSITION_RELOAD, false, |
3929 std::string(), controller.GetBrowserContext())); | 3676 std::string(), controller.GetBrowserContext())); |
3930 EXPECT_EQ(0U, restored_entry->root_node()->children.size()); | 3677 EXPECT_EQ(0U, restored_entry->root_node()->children.size()); |
3931 restored_entry->SetPageState(entry2->GetPageState()); | 3678 restored_entry->SetPageState(entry2->GetPageState()); |
3932 | 3679 |
3933 // Verify subframe entries if they're enabled (e.g. in --site-per-process). | 3680 // The entry should have a FrameNavigationEntry for the b.com subframe. |
3934 if (SiteIsolationPolicy::UseSubframeNavigationEntries()) { | 3681 EXPECT_EQ(main_url_a, restored_entry->root_node()->frame_entry->url()); |
3935 // The entry should have a FrameNavigationEntry for the b.com subframe. | 3682 ASSERT_EQ(1U, restored_entry->root_node()->children.size()); |
3936 EXPECT_EQ(main_url_a, restored_entry->root_node()->frame_entry->url()); | 3683 EXPECT_EQ(frame_url_b, |
3937 ASSERT_EQ(1U, restored_entry->root_node()->children.size()); | 3684 restored_entry->root_node()->children[0]->frame_entry->url()); |
3938 EXPECT_EQ(frame_url_b, | |
3939 restored_entry->root_node()->children[0]->frame_entry->url()); | |
3940 } else { | |
3941 // There are no subframe FrameNavigationEntries by default. | |
3942 EXPECT_EQ(0U, restored_entry->root_node()->children.size()); | |
3943 } | |
3944 | 3685 |
3945 // 5. Restore the new entry in a new tab and verify the correct URLs load. | 3686 // 5. Restore the new entry in a new tab and verify the correct URLs load. |
3946 std::vector<std::unique_ptr<NavigationEntry>> entries; | 3687 std::vector<std::unique_ptr<NavigationEntry>> entries; |
3947 entries.push_back(std::move(restored_entry)); | 3688 entries.push_back(std::move(restored_entry)); |
3948 Shell* new_shell = Shell::CreateNewWindow( | 3689 Shell* new_shell = Shell::CreateNewWindow( |
3949 controller.GetBrowserContext(), GURL::EmptyGURL(), nullptr, gfx::Size()); | 3690 controller.GetBrowserContext(), GURL::EmptyGURL(), nullptr, gfx::Size()); |
3950 FrameTreeNode* new_root = | 3691 FrameTreeNode* new_root = |
3951 static_cast<WebContentsImpl*>(new_shell->web_contents()) | 3692 static_cast<WebContentsImpl*>(new_shell->web_contents()) |
3952 ->GetFrameTree() | 3693 ->GetFrameTree() |
3953 ->root(); | 3694 ->root(); |
3954 NavigationControllerImpl& new_controller = | 3695 NavigationControllerImpl& new_controller = |
3955 static_cast<NavigationControllerImpl&>( | 3696 static_cast<NavigationControllerImpl&>( |
3956 new_shell->web_contents()->GetController()); | 3697 new_shell->web_contents()->GetController()); |
3957 new_controller.Restore(entries.size() - 1, | 3698 new_controller.Restore(entries.size() - 1, |
3958 RestoreType::LAST_SESSION_EXITED_CLEANLY, &entries); | 3699 RestoreType::LAST_SESSION_EXITED_CLEANLY, &entries); |
3959 ASSERT_EQ(0u, entries.size()); | 3700 ASSERT_EQ(0u, entries.size()); |
3960 { | 3701 { |
3961 TestNavigationObserver restore_observer(new_shell->web_contents()); | 3702 TestNavigationObserver restore_observer(new_shell->web_contents()); |
3962 new_controller.LoadIfNecessary(); | 3703 new_controller.LoadIfNecessary(); |
3963 restore_observer.Wait(); | 3704 restore_observer.Wait(); |
3964 } | 3705 } |
3965 ASSERT_EQ(1U, new_root->child_count()); | 3706 ASSERT_EQ(1U, new_root->child_count()); |
3966 EXPECT_EQ(main_url_a, new_root->current_url()); | 3707 EXPECT_EQ(main_url_a, new_root->current_url()); |
3967 EXPECT_EQ(frame_url_b, new_root->child_at(0)->current_url()); | 3708 EXPECT_EQ(frame_url_b, new_root->child_at(0)->current_url()); |
3968 | 3709 |
3969 EXPECT_EQ(1, new_controller.GetEntryCount()); | 3710 EXPECT_EQ(1, new_controller.GetEntryCount()); |
3970 EXPECT_EQ(0, new_controller.GetLastCommittedEntryIndex()); | 3711 EXPECT_EQ(0, new_controller.GetLastCommittedEntryIndex()); |
3971 NavigationEntryImpl* new_entry = new_controller.GetLastCommittedEntry(); | 3712 NavigationEntryImpl* new_entry = new_controller.GetLastCommittedEntry(); |
3972 | 3713 |
3973 // Verify subframe entries if they're enabled (e.g. in --site-per-process). | 3714 // The entry should have a FrameNavigationEntry for the b.com subframe. |
3974 if (SiteIsolationPolicy::UseSubframeNavigationEntries()) { | 3715 EXPECT_EQ(main_url_a, new_entry->root_node()->frame_entry->url()); |
3975 // The entry should have a FrameNavigationEntry for the b.com subframe. | 3716 ASSERT_EQ(1U, new_entry->root_node()->children.size()); |
3976 EXPECT_EQ(main_url_a, new_entry->root_node()->frame_entry->url()); | 3717 EXPECT_EQ(frame_url_b, |
3977 ASSERT_EQ(1U, new_entry->root_node()->children.size()); | 3718 new_entry->root_node()->children[0]->frame_entry->url()); |
3978 EXPECT_EQ(frame_url_b, | |
3979 new_entry->root_node()->children[0]->frame_entry->url()); | |
3980 } else { | |
3981 // There are no subframe FrameNavigationEntries by default. | |
3982 EXPECT_EQ(0U, new_entry->root_node()->children.size()); | |
3983 } | |
3984 } | 3719 } |
3985 | 3720 |
3986 // Verify that we can finish loading a page on restore if the PageState is | 3721 // Verify that we can finish loading a page on restore if the PageState is |
3987 // missing subframes. See https://crbug.com/638088. | 3722 // missing subframes. See https://crbug.com/638088. |
3988 IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest, | 3723 IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest, |
3989 FrameNavigationEntry_RestoreViaPartialPageState) { | 3724 FrameNavigationEntry_RestoreViaPartialPageState) { |
3990 GURL main_url(embedded_test_server()->GetURL( | 3725 GURL main_url(embedded_test_server()->GetURL( |
3991 "a.com", "/navigation_controller/inject_into_blank_iframe.html")); | 3726 "a.com", "/navigation_controller/inject_into_blank_iframe.html")); |
3992 GURL blank_url(url::kAboutBlankURL); | 3727 GURL blank_url(url::kAboutBlankURL); |
3993 NavigationControllerImpl& controller = | 3728 NavigationControllerImpl& controller = |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4025 restore_observer.Wait(); | 3760 restore_observer.Wait(); |
4026 } | 3761 } |
4027 ASSERT_EQ(1U, root->child_count()); | 3762 ASSERT_EQ(1U, root->child_count()); |
4028 EXPECT_EQ(main_url, root->current_url()); | 3763 EXPECT_EQ(main_url, root->current_url()); |
4029 EXPECT_EQ(blank_url, root->child_at(0)->current_url()); | 3764 EXPECT_EQ(blank_url, root->child_at(0)->current_url()); |
4030 | 3765 |
4031 EXPECT_EQ(1, controller.GetEntryCount()); | 3766 EXPECT_EQ(1, controller.GetEntryCount()); |
4032 EXPECT_EQ(0, controller.GetLastCommittedEntryIndex()); | 3767 EXPECT_EQ(0, controller.GetLastCommittedEntryIndex()); |
4033 NavigationEntryImpl* new_entry = controller.GetLastCommittedEntry(); | 3768 NavigationEntryImpl* new_entry = controller.GetLastCommittedEntry(); |
4034 | 3769 |
4035 // Verify subframe entries if they're enabled (e.g. in --site-per-process). | 3770 // The entry should have a FrameNavigationEntry for the blank subframe. |
4036 if (SiteIsolationPolicy::UseSubframeNavigationEntries()) { | 3771 EXPECT_EQ(main_url, new_entry->root_node()->frame_entry->url()); |
4037 // The entry should have a FrameNavigationEntry for the blank subframe. | 3772 ASSERT_EQ(1U, new_entry->root_node()->children.size()); |
4038 EXPECT_EQ(main_url, new_entry->root_node()->frame_entry->url()); | 3773 EXPECT_EQ(blank_url, new_entry->root_node()->children[0]->frame_entry->url()); |
4039 ASSERT_EQ(1U, new_entry->root_node()->children.size()); | |
4040 EXPECT_EQ(blank_url, | |
4041 new_entry->root_node()->children[0]->frame_entry->url()); | |
4042 } else { | |
4043 EXPECT_EQ(0U, new_entry->root_node()->children.size()); | |
4044 } | |
4045 | 3774 |
4046 // Verify that the parent was able to script the iframe. | 3775 // Verify that the parent was able to script the iframe. |
4047 std::string expected_text("Injected text"); | 3776 std::string expected_text("Injected text"); |
4048 { | 3777 { |
4049 std::string value; | 3778 std::string value; |
4050 EXPECT_TRUE(ExecuteScriptAndExtractString( | 3779 EXPECT_TRUE(ExecuteScriptAndExtractString( |
4051 root->child_at(0), | 3780 root->child_at(0), |
4052 "domAutomationController.send(document.body.innerHTML)", &value)); | 3781 "domAutomationController.send(document.body.innerHTML)", &value)); |
4053 EXPECT_EQ(expected_text, value); | 3782 EXPECT_EQ(expected_text, value); |
4054 } | 3783 } |
(...skipping 16 matching lines...) Expand all Loading... | |
4071 ->GetFrameTree() | 3800 ->GetFrameTree() |
4072 ->root(); | 3801 ->root(); |
4073 SiteInstance* main_site_instance = | 3802 SiteInstance* main_site_instance = |
4074 root->current_frame_host()->GetSiteInstance(); | 3803 root->current_frame_host()->GetSiteInstance(); |
4075 | 3804 |
4076 // The main frame defaults to an empty name. | 3805 // The main frame defaults to an empty name. |
4077 FrameNavigationEntry* frame_entry = | 3806 FrameNavigationEntry* frame_entry = |
4078 controller.GetLastCommittedEntry()->GetFrameEntry(root); | 3807 controller.GetLastCommittedEntry()->GetFrameEntry(root); |
4079 EXPECT_EQ("", frame_entry->frame_unique_name()); | 3808 EXPECT_EQ("", frame_entry->frame_unique_name()); |
4080 | 3809 |
4081 // Test subframe unique names only if enabled, e.g. in --site-per-process. | |
4082 if (!SiteIsolationPolicy::UseSubframeNavigationEntries()) | |
4083 return; | |
4084 | |
4085 // 2. Add an unnamed subframe, which does an AUTO_SUBFRAME navigation. | 3810 // 2. Add an unnamed subframe, which does an AUTO_SUBFRAME navigation. |
4086 { | 3811 { |
4087 LoadCommittedCapturer capturer(shell()->web_contents()); | 3812 LoadCommittedCapturer capturer(shell()->web_contents()); |
4088 std::string script = "var iframe = document.createElement('iframe');" | 3813 std::string script = "var iframe = document.createElement('iframe');" |
4089 "iframe.src = '" + url.spec() + "';" | 3814 "iframe.src = '" + url.spec() + "';" |
4090 "document.body.appendChild(iframe);"; | 3815 "document.body.appendChild(iframe);"; |
4091 EXPECT_TRUE(ExecuteScript(root, script)); | 3816 EXPECT_TRUE(ExecuteScript(root, script)); |
4092 capturer.Wait(); | 3817 capturer.Wait(); |
4093 EXPECT_TRUE(ui::PageTransitionTypeIncludingQualifiersIs( | 3818 EXPECT_TRUE(ui::PageTransitionTypeIncludingQualifiersIs( |
4094 capturer.transition_type(), ui::PAGE_TRANSITION_AUTO_SUBFRAME)); | 3819 capturer.transition_type(), ui::PAGE_TRANSITION_AUTO_SUBFRAME)); |
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4314 capturer.Wait(); | 4039 capturer.Wait(); |
4315 EXPECT_TRUE(ui::PageTransitionTypeIncludingQualifiersIs( | 4040 EXPECT_TRUE(ui::PageTransitionTypeIncludingQualifiersIs( |
4316 capturer.transition_type(), ui::PAGE_TRANSITION_AUTO_SUBFRAME)); | 4041 capturer.transition_type(), ui::PAGE_TRANSITION_AUTO_SUBFRAME)); |
4317 } | 4042 } |
4318 | 4043 |
4319 FrameTreeNode* subframe = root->child_at(0); | 4044 FrameTreeNode* subframe = root->child_at(0); |
4320 if (AreAllSitesIsolatedForTesting()) { | 4045 if (AreAllSitesIsolatedForTesting()) { |
4321 EXPECT_NE(main_site_instance, | 4046 EXPECT_NE(main_site_instance, |
4322 subframe->current_frame_host()->GetSiteInstance()); | 4047 subframe->current_frame_host()->GetSiteInstance()); |
4323 } | 4048 } |
4324 if (SiteIsolationPolicy::UseSubframeNavigationEntries()) { | 4049 FrameNavigationEntry* subframe_entry = |
4325 FrameNavigationEntry* subframe_entry = | 4050 controller.GetLastCommittedEntry()->GetFrameEntry(subframe); |
4326 controller.GetLastCommittedEntry()->GetFrameEntry(subframe); | 4051 EXPECT_EQ(frame_url, subframe_entry->url()); |
4327 EXPECT_EQ(frame_url, subframe_entry->url()); | |
4328 } | |
4329 | 4052 |
4330 // 3. Reload the main frame. | 4053 // 3. Reload the main frame. |
4331 { | 4054 { |
4332 FrameNavigateParamsCapturer capturer(root); | 4055 FrameNavigateParamsCapturer capturer(root); |
4333 controller.Reload(ReloadType::NORMAL, false); | 4056 controller.Reload(ReloadType::NORMAL, false); |
4334 capturer.Wait(); | 4057 capturer.Wait(); |
4335 EXPECT_TRUE(ui::PageTransitionTypeIncludingQualifiersIs( | 4058 EXPECT_TRUE(ui::PageTransitionTypeIncludingQualifiersIs( |
4336 capturer.params().transition, ui::PAGE_TRANSITION_RELOAD)); | 4059 capturer.params().transition, ui::PAGE_TRANSITION_RELOAD)); |
4337 EXPECT_EQ(NAVIGATION_TYPE_EXISTING_PAGE, capturer.details().type); | 4060 EXPECT_EQ(NAVIGATION_TYPE_EXISTING_PAGE, capturer.details().type); |
4338 EXPECT_FALSE(capturer.details().is_in_page); | 4061 EXPECT_FALSE(capturer.details().is_in_page); |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4380 EXPECT_TRUE(ExecuteScript(root, script)); | 4103 EXPECT_TRUE(ExecuteScript(root, script)); |
4381 EXPECT_TRUE(WaitForLoadStop(shell()->web_contents())); | 4104 EXPECT_TRUE(WaitForLoadStop(shell()->web_contents())); |
4382 | 4105 |
4383 frame_entry = controller.GetLastCommittedEntry()->GetFrameEntry(root); | 4106 frame_entry = controller.GetLastCommittedEntry()->GetFrameEntry(root); |
4384 int64_t isn_2 = frame_entry->item_sequence_number(); | 4107 int64_t isn_2 = frame_entry->item_sequence_number(); |
4385 int64_t dsn_2 = frame_entry->document_sequence_number(); | 4108 int64_t dsn_2 = frame_entry->document_sequence_number(); |
4386 EXPECT_NE(-1, isn_2); | 4109 EXPECT_NE(-1, isn_2); |
4387 EXPECT_NE(isn_1, isn_2); | 4110 EXPECT_NE(isn_1, isn_2); |
4388 EXPECT_EQ(dsn_1, dsn_2); | 4111 EXPECT_EQ(dsn_1, dsn_2); |
4389 | 4112 |
4390 // Test subframe sequence numbers only if enabled, e.g. in --site-per-process. | |
4391 if (!SiteIsolationPolicy::UseSubframeNavigationEntries()) | |
4392 return; | |
4393 | |
4394 // 3. Add a subframe, which does an AUTO_SUBFRAME navigation. | 4113 // 3. Add a subframe, which does an AUTO_SUBFRAME navigation. |
4395 { | 4114 { |
4396 LoadCommittedCapturer capturer(shell()->web_contents()); | 4115 LoadCommittedCapturer capturer(shell()->web_contents()); |
4397 std::string add_script = "var iframe = document.createElement('iframe');" | 4116 std::string add_script = "var iframe = document.createElement('iframe');" |
4398 "iframe.src = '" + url.spec() + "';" | 4117 "iframe.src = '" + url.spec() + "';" |
4399 "document.body.appendChild(iframe);"; | 4118 "document.body.appendChild(iframe);"; |
4400 EXPECT_TRUE(ExecuteScript(root, add_script)); | 4119 EXPECT_TRUE(ExecuteScript(root, add_script)); |
4401 capturer.Wait(); | 4120 capturer.Wait(); |
4402 EXPECT_TRUE(ui::PageTransitionTypeIncludingQualifiersIs( | 4121 EXPECT_TRUE(ui::PageTransitionTypeIncludingQualifiersIs( |
4403 capturer.transition_type(), ui::PAGE_TRANSITION_AUTO_SUBFRAME)); | 4122 capturer.transition_type(), ui::PAGE_TRANSITION_AUTO_SUBFRAME)); |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4470 | 4189 |
4471 // Navigate to a page with an redirecting iframe. | 4190 // Navigate to a page with an redirecting iframe. |
4472 EXPECT_TRUE(NavigateToURL(shell(), main_url)); | 4191 EXPECT_TRUE(NavigateToURL(shell(), main_url)); |
4473 | 4192 |
4474 // Check that the main frame redirect chain contains only one url. | 4193 // Check that the main frame redirect chain contains only one url. |
4475 EXPECT_EQ(1, controller.GetEntryCount()); | 4194 EXPECT_EQ(1, controller.GetEntryCount()); |
4476 NavigationEntryImpl* entry = controller.GetLastCommittedEntry(); | 4195 NavigationEntryImpl* entry = controller.GetLastCommittedEntry(); |
4477 EXPECT_EQ(entry->GetRedirectChain().size(), 1u); | 4196 EXPECT_EQ(entry->GetRedirectChain().size(), 1u); |
4478 EXPECT_EQ(entry->GetRedirectChain()[0], main_url); | 4197 EXPECT_EQ(entry->GetRedirectChain()[0], main_url); |
4479 | 4198 |
4480 // Verify subframe entries if they're enabled (e.g. in --site-per-process). | 4199 // Check that the FrameNavigationEntry's redirect chain contains 2 urls. |
4481 if (SiteIsolationPolicy::UseSubframeNavigationEntries()) { | 4200 ASSERT_EQ(1U, entry->root_node()->children.size()); |
4482 // Check that the FrameNavigationEntry's redirect chain contains 2 urls. | 4201 FrameNavigationEntry* frame_entry = |
4483 ASSERT_EQ(1U, entry->root_node()->children.size()); | 4202 entry->root_node()->children[0]->frame_entry.get(); |
4484 FrameNavigationEntry* frame_entry = | 4203 EXPECT_EQ(frame_entry->redirect_chain().size(), 2u); |
4485 entry->root_node()->children[0]->frame_entry.get(); | 4204 EXPECT_EQ(frame_entry->redirect_chain()[0], iframe_redirect_url); |
4486 EXPECT_EQ(frame_entry->redirect_chain().size(), 2u); | 4205 EXPECT_EQ(frame_entry->redirect_chain()[1], iframe_final_url); |
4487 EXPECT_EQ(frame_entry->redirect_chain()[0], iframe_redirect_url); | |
4488 EXPECT_EQ(frame_entry->redirect_chain()[1], iframe_final_url); | |
4489 } | |
4490 } | 4206 } |
4491 | 4207 |
4492 // Verifies that FrameNavigationEntry's redirect chain is created and stored on | 4208 // Verifies that FrameNavigationEntry's redirect chain is created and stored on |
4493 // the right subframe (NEW_SUBFRAME navigation). | 4209 // the right subframe (NEW_SUBFRAME navigation). |
4494 IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest, | 4210 IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest, |
4495 FrameNavigationEntry_NewSubFrameRedirectChain) { | 4211 FrameNavigationEntry_NewSubFrameRedirectChain) { |
4496 const NavigationControllerImpl& controller = | 4212 const NavigationControllerImpl& controller = |
4497 static_cast<const NavigationControllerImpl&>( | 4213 static_cast<const NavigationControllerImpl&>( |
4498 shell()->web_contents()->GetController()); | 4214 shell()->web_contents()->GetController()); |
4499 FrameTreeNode* root = static_cast<WebContentsImpl*>(shell()->web_contents()) | 4215 FrameTreeNode* root = static_cast<WebContentsImpl*>(shell()->web_contents()) |
(...skipping 11 matching lines...) Expand all Loading... | |
4511 GURL frame_redirect_url( | 4227 GURL frame_redirect_url( |
4512 embedded_test_server()->GetURL("/server-redirect?/simple_page.html")); | 4228 embedded_test_server()->GetURL("/server-redirect?/simple_page.html")); |
4513 NavigateFrameToURL(root->child_at(0), frame_redirect_url); | 4229 NavigateFrameToURL(root->child_at(0), frame_redirect_url); |
4514 | 4230 |
4515 // Check that the main frame redirect chain contains only the main_url. | 4231 // Check that the main frame redirect chain contains only the main_url. |
4516 EXPECT_EQ(2, controller.GetEntryCount()); | 4232 EXPECT_EQ(2, controller.GetEntryCount()); |
4517 NavigationEntryImpl* entry = controller.GetLastCommittedEntry(); | 4233 NavigationEntryImpl* entry = controller.GetLastCommittedEntry(); |
4518 EXPECT_EQ(entry->GetRedirectChain().size(), 1u); | 4234 EXPECT_EQ(entry->GetRedirectChain().size(), 1u); |
4519 EXPECT_EQ(entry->GetRedirectChain()[0], main_url); | 4235 EXPECT_EQ(entry->GetRedirectChain()[0], main_url); |
4520 | 4236 |
4521 // Verify subframe entries if they're enabled (e.g. in --site-per-process). | 4237 // Check that the FrameNavigationEntry's redirect chain contains 2 urls. |
4522 if (SiteIsolationPolicy::UseSubframeNavigationEntries()) { | 4238 ASSERT_EQ(1U, entry->root_node()->children.size()); |
4523 // Check that the FrameNavigationEntry's redirect chain contains 2 urls. | 4239 FrameNavigationEntry* frame_entry = |
4524 ASSERT_EQ(1U, entry->root_node()->children.size()); | 4240 entry->root_node()->children[0]->frame_entry.get(); |
4525 FrameNavigationEntry* frame_entry = | 4241 EXPECT_EQ(frame_entry->redirect_chain().size(), 2u); |
4526 entry->root_node()->children[0]->frame_entry.get(); | 4242 EXPECT_EQ(frame_entry->redirect_chain()[0], frame_redirect_url); |
4527 EXPECT_EQ(frame_entry->redirect_chain().size(), 2u); | 4243 EXPECT_EQ(frame_entry->redirect_chain()[1], frame_final_url); |
4528 EXPECT_EQ(frame_entry->redirect_chain()[0], frame_redirect_url); | |
4529 EXPECT_EQ(frame_entry->redirect_chain()[1], frame_final_url); | |
4530 } | |
4531 } | 4244 } |
4532 | 4245 |
4533 // Support a set of tests that isolate only a subset of sites with | 4246 // Support a set of tests that isolate only a subset of sites with |
4534 // out-of-process iframes (OOPIFs). | 4247 // out-of-process iframes (OOPIFs). |
4535 class NavigationControllerOopifBrowserTest | 4248 class NavigationControllerOopifBrowserTest |
4536 : public NavigationControllerBrowserTest { | 4249 : public NavigationControllerBrowserTest { |
4537 public: | 4250 public: |
4538 NavigationControllerOopifBrowserTest() {} | 4251 NavigationControllerOopifBrowserTest() {} |
4539 | 4252 |
4540 void SetUpCommandLine(base::CommandLine* command_line) override { | 4253 void SetUpCommandLine(base::CommandLine* command_line) override { |
(...skipping 721 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
5262 EXPECT_TRUE(root->current_frame_host()->IsRenderFrameLive()); | 4975 EXPECT_TRUE(root->current_frame_host()->IsRenderFrameLive()); |
5263 | 4976 |
5264 // TODO(creis): We should probably go back to frame_url here instead of the | 4977 // TODO(creis): We should probably go back to frame_url here instead of the |
5265 // initial blank page. That might require updating all relevant NavEntries to | 4978 // initial blank page. That might require updating all relevant NavEntries to |
5266 // know what the first committed URL is, so that we really elide the initial | 4979 // know what the first committed URL is, so that we really elide the initial |
5267 // blank page from history. | 4980 // blank page from history. |
5268 // | 4981 // |
5269 // TODO(creis): This actually goes to frame_url in some cases when subframe | 4982 // TODO(creis): This actually goes to frame_url in some cases when subframe |
5270 // FrameNavigationEntries are enabled, due to a mismatch between PageState and | 4983 // FrameNavigationEntries are enabled, due to a mismatch between PageState and |
5271 // the entry's URL. That should be fixed in https://crbug.com/617239. | 4984 // the entry's URL. That should be fixed in https://crbug.com/617239. |
5272 if (!SiteIsolationPolicy::UseSubframeNavigationEntries()) | 4985 if (!SiteIsolationPolicy::UseSubframeNavigationEntries()) |
Charlie Reis
2017/01/04 18:42:09
I left 3 of these in place, since they require a b
| |
5273 EXPECT_EQ(blank_url, frame->current_url()); | 4986 EXPECT_EQ(blank_url, frame->current_url()); |
5274 } | 4987 } |
5275 | 4988 |
5276 // This test is similar to "BackToAboutBlankIframe" above, except that a | 4989 // This test is similar to "BackToAboutBlankIframe" above, except that a |
5277 // fragment navigation is used rather than pushState (both create an in-page | 4990 // fragment navigation is used rather than pushState (both create an in-page |
5278 // navigation, so we need to test both), and an initial 'src' is given to the | 4991 // navigation, so we need to test both), and an initial 'src' is given to the |
5279 // iframe to test proper restoration in that case. | 4992 // iframe to test proper restoration in that case. |
5280 IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest, | 4993 IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest, |
5281 BackToIframeWithContent) { | 4994 BackToIframeWithContent) { |
5282 GURL links_url(embedded_test_server()->GetURL( | 4995 GURL links_url(embedded_test_server()->GetURL( |
(...skipping 779 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
6062 ->current_frame_host() | 5775 ->current_frame_host() |
6063 ->GetSiteInstance() | 5776 ->GetSiteInstance() |
6064 ->GetSiteURL()); | 5777 ->GetSiteURL()); |
6065 } | 5778 } |
6066 } | 5779 } |
6067 | 5780 |
6068 // Tests that when using FrameNavigationEntries, knowledge of POST navigations | 5781 // Tests that when using FrameNavigationEntries, knowledge of POST navigations |
6069 // is recorded on a subframe level. | 5782 // is recorded on a subframe level. |
6070 IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest, | 5783 IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest, |
6071 PostInSubframe) { | 5784 PostInSubframe) { |
6072 if (!SiteIsolationPolicy::UseSubframeNavigationEntries()) | |
6073 return; | |
6074 | |
6075 GURL page_with_form_url = embedded_test_server()->GetURL( | 5785 GURL page_with_form_url = embedded_test_server()->GetURL( |
6076 "/navigation_controller/subframe_form.html"); | 5786 "/navigation_controller/subframe_form.html"); |
6077 EXPECT_TRUE(NavigateToURL(shell(), page_with_form_url)); | 5787 EXPECT_TRUE(NavigateToURL(shell(), page_with_form_url)); |
6078 | 5788 |
6079 NavigationControllerImpl& controller = static_cast<NavigationControllerImpl&>( | 5789 NavigationControllerImpl& controller = static_cast<NavigationControllerImpl&>( |
6080 shell()->web_contents()->GetController()); | 5790 shell()->web_contents()->GetController()); |
6081 FrameTreeNode* root = static_cast<WebContentsImpl*>(shell()->web_contents()) | 5791 FrameTreeNode* root = static_cast<WebContentsImpl*>(shell()->web_contents()) |
6082 ->GetFrameTree() | 5792 ->GetFrameTree() |
6083 ->root(); | 5793 ->root(); |
6084 FrameTreeNode* frame = root->child_at(0); | 5794 FrameTreeNode* frame = root->child_at(0); |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
6177 EXPECT_EQ(2U, root->child_at(0)->child_count()); | 5887 EXPECT_EQ(2U, root->child_at(0)->child_count()); |
6178 | 5888 |
6179 NavigationEntryImpl* entry = controller.GetLastCommittedEntry(); | 5889 NavigationEntryImpl* entry = controller.GetLastCommittedEntry(); |
6180 | 5890 |
6181 // Verify only the parts of the NavigationEntry affected by this test. | 5891 // Verify only the parts of the NavigationEntry affected by this test. |
6182 { | 5892 { |
6183 // * Main frame has 3 subframes. | 5893 // * Main frame has 3 subframes. |
6184 FrameNavigationEntry* root_entry = entry->GetFrameEntry(root); | 5894 FrameNavigationEntry* root_entry = entry->GetFrameEntry(root); |
6185 EXPECT_NE(nullptr, root_entry); | 5895 EXPECT_NE(nullptr, root_entry); |
6186 EXPECT_EQ("", root_entry->frame_unique_name()); | 5896 EXPECT_EQ("", root_entry->frame_unique_name()); |
6187 if (SiteIsolationPolicy::UseSubframeNavigationEntries()) { | 5897 EXPECT_EQ(3U, entry->root_node()->children.size()); |
6188 EXPECT_EQ(3U, entry->root_node()->children.size()); | |
6189 | 5898 |
6190 // * The first child of the main frame is named and has two more children. | 5899 // * The first child of the main frame is named and has two more children. |
6191 FrameTreeNode* frame = root->child_at(0); | 5900 FrameTreeNode* frame = root->child_at(0); |
6192 FrameNavigationEntry* frame_entry = entry->GetFrameEntry(frame); | 5901 FrameNavigationEntry* frame_entry = entry->GetFrameEntry(frame); |
6193 EXPECT_NE(nullptr, frame_entry); | 5902 EXPECT_NE(nullptr, frame_entry); |
6194 EXPECT_EQ("1-1-name", frame_entry->frame_unique_name()); | 5903 EXPECT_EQ("1-1-name", frame_entry->frame_unique_name()); |
6195 EXPECT_EQ(2U, entry->root_node()->children[0]->children.size()); | 5904 EXPECT_EQ(2U, entry->root_node()->children[0]->children.size()); |
6196 } | |
6197 } | 5905 } |
6198 | 5906 |
6199 // Removing the first child of the main frame should remove the corresponding | 5907 // Removing the first child of the main frame should remove the corresponding |
6200 // FrameTreeNode. | 5908 // FrameTreeNode. |
6201 EXPECT_TRUE(ExecuteScript(root, kRemoveFrameScript)); | 5909 EXPECT_TRUE(ExecuteScript(root, kRemoveFrameScript)); |
6202 EXPECT_EQ(2U, root->child_count()); | 5910 EXPECT_EQ(2U, root->child_count()); |
6203 | 5911 |
6204 // However, the FrameNavigationEntry objects for the frame that was removed | 5912 // However, the FrameNavigationEntry objects for the frame that was removed |
6205 // should still be around. | 5913 // should still be around. |
6206 { | 5914 { |
6207 FrameNavigationEntry* root_entry = entry->GetFrameEntry(root); | 5915 FrameNavigationEntry* root_entry = entry->GetFrameEntry(root); |
6208 EXPECT_NE(nullptr, root_entry); | 5916 EXPECT_NE(nullptr, root_entry); |
6209 if (SiteIsolationPolicy::UseSubframeNavigationEntries()) { | 5917 EXPECT_EQ(3U, entry->root_node()->children.size()); |
6210 EXPECT_EQ(3U, entry->root_node()->children.size()); | 5918 EXPECT_EQ(2U, entry->root_node()->children[0]->children.size()); |
6211 EXPECT_EQ(2U, entry->root_node()->children[0]->children.size()); | |
6212 } | |
6213 } | 5919 } |
6214 | 5920 |
6215 // Now, insert a frame with the same name as the previously removed one | 5921 // Now, insert a frame with the same name as the previously removed one |
6216 // at a different layer of the frame tree. | 5922 // at a different layer of the frame tree. |
6217 FrameTreeNode* subframe = root->child_at(1)->child_at(1)->child_at(0); | 5923 FrameTreeNode* subframe = root->child_at(1)->child_at(1)->child_at(0); |
6218 EXPECT_EQ(2U, root->child_at(1)->child_count()); | 5924 EXPECT_EQ(2U, root->child_at(1)->child_count()); |
6219 EXPECT_EQ(0U, subframe->child_count()); | 5925 EXPECT_EQ(0U, subframe->child_count()); |
6220 std::string add_matching_name_frame_script = | 5926 std::string add_matching_name_frame_script = |
6221 "var f = document.createElement('iframe');" | 5927 "var f = document.createElement('iframe');" |
6222 "f.name = '1-1-name';" | 5928 "f.name = '1-1-name';" |
6223 "document.body.appendChild(f);"; | 5929 "document.body.appendChild(f);"; |
6224 EXPECT_TRUE(ExecuteScript(subframe, add_matching_name_frame_script)); | 5930 EXPECT_TRUE(ExecuteScript(subframe, add_matching_name_frame_script)); |
6225 EXPECT_EQ(1U, subframe->child_count()); | 5931 EXPECT_EQ(1U, subframe->child_count()); |
6226 | 5932 |
6227 // Verify that the FrameNavigationEntry for the original frame is now gone. | 5933 // Verify that the FrameNavigationEntry for the original frame is now gone. |
6228 { | 5934 { |
6229 FrameNavigationEntry* root_entry = entry->GetFrameEntry(root); | 5935 FrameNavigationEntry* root_entry = entry->GetFrameEntry(root); |
6230 EXPECT_NE(nullptr, root_entry); | 5936 EXPECT_NE(nullptr, root_entry); |
6231 if (SiteIsolationPolicy::UseSubframeNavigationEntries()) { | 5937 EXPECT_EQ(2U, entry->root_node()->children.size()); |
6232 EXPECT_EQ(2U, entry->root_node()->children.size()); | |
6233 } | |
6234 } | 5938 } |
6235 } | 5939 } |
6236 | 5940 |
6237 // Tests that sending a PageState update from a named subframe does not get | 5941 // Tests that sending a PageState update from a named subframe does not get |
6238 // incorrectly set on previously existing FrameNavigationEntry for the same | 5942 // incorrectly set on previously existing FrameNavigationEntry for the same |
6239 // name. It is similar to EnsureFrameNavigationEntriesClearedOnMismatch, but | 5943 // name. It is similar to EnsureFrameNavigationEntriesClearedOnMismatch, but |
6240 // doesn't navigate the iframes to real URLs when added to the DOM. | 5944 // doesn't navigate the iframes to real URLs when added to the DOM. |
6241 // See https://crbug.com/628677. | 5945 // See https://crbug.com/628677. |
6242 IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest, | 5946 IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest, |
6243 EnsureFrameNavigationEntriesClearedOnMismatchNoSrc) { | 5947 EnsureFrameNavigationEntriesClearedOnMismatchNoSrc) { |
6244 WebContentsImpl* web_contents = | 5948 WebContentsImpl* web_contents = |
6245 static_cast<WebContentsImpl*>(shell()->web_contents()); | 5949 static_cast<WebContentsImpl*>(shell()->web_contents()); |
6246 FrameTreeNode* root = web_contents->GetFrameTree()->root(); | 5950 FrameTreeNode* root = web_contents->GetFrameTree()->root(); |
6247 | 5951 |
6248 GURL start_url(embedded_test_server()->GetURL("/title1.html")); | 5952 GURL start_url(embedded_test_server()->GetURL("/title1.html")); |
6249 EXPECT_TRUE(NavigateToURL(shell(), start_url)); | 5953 EXPECT_TRUE(NavigateToURL(shell(), start_url)); |
6250 NavigationEntryImpl* nav_entry = | 5954 NavigationEntryImpl* nav_entry = |
6251 web_contents->GetController().GetLastCommittedEntry(); | 5955 web_contents->GetController().GetLastCommittedEntry(); |
6252 | 5956 |
6253 EXPECT_TRUE(ExecuteScript(root, kAddNamedFrameScript)); | 5957 EXPECT_TRUE(ExecuteScript(root, kAddNamedFrameScript)); |
6254 EXPECT_EQ(1U, root->child_count()); | 5958 EXPECT_EQ(1U, root->child_count()); |
6255 EXPECT_EQ("foo-frame-name", root->child_at(0)->frame_name()); | 5959 EXPECT_EQ("foo-frame-name", root->child_at(0)->frame_name()); |
6256 | 5960 |
6257 EXPECT_TRUE(ExecuteScript(root, kRemoveFrameScript)); | 5961 EXPECT_TRUE(ExecuteScript(root, kRemoveFrameScript)); |
6258 EXPECT_EQ(0U, root->child_count()); | 5962 EXPECT_EQ(0U, root->child_count()); |
6259 | 5963 |
6260 // When a frame is removed from the page, the corresponding | 5964 // When a frame is removed from the page, the corresponding |
6261 // FrameNavigationEntry is not removed. This is done intentionally to support | 5965 // FrameNavigationEntry is not removed. This is done intentionally to support |
6262 // back-forward navigations in subframes and more intuitive UX on tab restore. | 5966 // back-forward navigations in subframes and more intuitive UX on tab restore. |
6263 if (SiteIsolationPolicy::UseSubframeNavigationEntries()) { | 5967 EXPECT_EQ(1U, nav_entry->root_node()->children.size()); |
6264 EXPECT_EQ(1U, nav_entry->root_node()->children.size()); | 5968 FrameNavigationEntry* frame_entry = |
6265 FrameNavigationEntry* frame_entry = | 5969 nav_entry->root_node()->children[0]->frame_entry.get(); |
6266 nav_entry->root_node()->children[0]->frame_entry.get(); | 5970 EXPECT_EQ("foo-frame-name", frame_entry->frame_unique_name()); |
6267 EXPECT_EQ("foo-frame-name", frame_entry->frame_unique_name()); | |
6268 } | |
6269 | 5971 |
6270 EXPECT_TRUE(ExecuteScript(root, kAddFrameScript)); | 5972 EXPECT_TRUE(ExecuteScript(root, kAddFrameScript)); |
6271 EXPECT_EQ(1U, root->child_count()); | 5973 EXPECT_EQ(1U, root->child_count()); |
6272 EXPECT_NE("foo-frame-name", root->child_at(0)->frame_name()); | 5974 EXPECT_NE("foo-frame-name", root->child_at(0)->frame_name()); |
6273 | 5975 |
6274 // Add a nested frame with the previously used name. | 5976 // Add a nested frame with the previously used name. |
6275 EXPECT_TRUE(ExecuteScript(root->child_at(0), kAddNamedFrameScript)); | 5977 EXPECT_TRUE(ExecuteScript(root->child_at(0), kAddNamedFrameScript)); |
6276 EXPECT_EQ(1U, root->child_at(0)->child_count()); | 5978 EXPECT_EQ(1U, root->child_at(0)->child_count()); |
6277 EXPECT_EQ("foo-frame-name", root->child_at(0)->child_at(0)->frame_name()); | 5979 EXPECT_EQ("foo-frame-name", root->child_at(0)->child_at(0)->frame_name()); |
6278 | 5980 |
6279 if (SiteIsolationPolicy::UseSubframeNavigationEntries()) { | 5981 EXPECT_EQ(1U, nav_entry->root_node()->children.size()); |
6280 EXPECT_EQ(1U, nav_entry->root_node()->children.size()); | |
6281 | 5982 |
6282 NavigationEntryImpl::TreeNode* tree_node = | 5983 NavigationEntryImpl::TreeNode* tree_node = |
6283 nav_entry->root_node()->children[0]; | 5984 nav_entry->root_node()->children[0]; |
6284 EXPECT_EQ(1U, tree_node->children.size()); | 5985 EXPECT_EQ(1U, tree_node->children.size()); |
6285 | 5986 |
6286 tree_node = tree_node->children[0]; | 5987 tree_node = tree_node->children[0]; |
6287 EXPECT_EQ(0U, tree_node->children.size()); | 5988 EXPECT_EQ(0U, tree_node->children.size()); |
6288 EXPECT_EQ("foo-frame-name", tree_node->frame_entry->frame_unique_name()); | 5989 EXPECT_EQ("foo-frame-name", tree_node->frame_entry->frame_unique_name()); |
6289 } | |
6290 | 5990 |
6291 EXPECT_TRUE(ExecuteScript(root->child_at(0), kRemoveFrameScript)); | 5991 EXPECT_TRUE(ExecuteScript(root->child_at(0), kRemoveFrameScript)); |
6292 EXPECT_EQ(0U, root->child_at(0)->child_count()); | 5992 EXPECT_EQ(0U, root->child_at(0)->child_count()); |
6293 } | 5993 } |
6294 | 5994 |
6295 // This test ensures that the comparison of tree position between a | 5995 // This test ensures that the comparison of tree position between a |
6296 // FrameTreeNode and FrameNavigationEntry works correctly for matching | 5996 // FrameTreeNode and FrameNavigationEntry works correctly for matching |
6297 // first-level frames. | 5997 // first-level frames. |
6298 IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest, | 5998 IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest, |
6299 EnsureFirstLevelFrameNavigationEntriesMatch) { | 5999 EnsureFirstLevelFrameNavigationEntriesMatch) { |
6300 WebContentsImpl* web_contents = | 6000 WebContentsImpl* web_contents = |
6301 static_cast<WebContentsImpl*>(shell()->web_contents()); | 6001 static_cast<WebContentsImpl*>(shell()->web_contents()); |
6302 FrameTreeNode* root = web_contents->GetFrameTree()->root(); | 6002 FrameTreeNode* root = web_contents->GetFrameTree()->root(); |
6303 NavigationEntryImpl::TreeNode* tree_node = nullptr; | 6003 NavigationEntryImpl::TreeNode* tree_node = nullptr; |
6304 | 6004 |
6305 GURL start_url(embedded_test_server()->GetURL("/title1.html")); | 6005 GURL start_url(embedded_test_server()->GetURL("/title1.html")); |
6306 EXPECT_TRUE(NavigateToURL(shell(), start_url)); | 6006 EXPECT_TRUE(NavigateToURL(shell(), start_url)); |
6307 NavigationEntryImpl* nav_entry = | 6007 NavigationEntryImpl* nav_entry = |
6308 web_contents->GetController().GetLastCommittedEntry(); | 6008 web_contents->GetController().GetLastCommittedEntry(); |
6309 | 6009 |
6310 // Add, then remove a named frame. It will create a FrameNavigationEntry | 6010 // Add, then remove a named frame. It will create a FrameNavigationEntry |
6311 // for the name and leave it around. | 6011 // for the name and leave it around. |
6312 EXPECT_TRUE(ExecuteScript(root, kAddNamedFrameScript)); | 6012 EXPECT_TRUE(ExecuteScript(root, kAddNamedFrameScript)); |
6313 EXPECT_EQ(1U, root->child_count()); | 6013 EXPECT_EQ(1U, root->child_count()); |
6314 if (SiteIsolationPolicy::UseSubframeNavigationEntries()) { | 6014 EXPECT_EQ(1U, nav_entry->root_node()->children.size()); |
6315 EXPECT_EQ(1U, nav_entry->root_node()->children.size()); | 6015 tree_node = nav_entry->root_node()->children[0]; |
6316 tree_node = nav_entry->root_node()->children[0]; | |
6317 } | |
6318 | 6016 |
6319 EXPECT_TRUE(ExecuteScript(root, kRemoveFrameScript)); | 6017 EXPECT_TRUE(ExecuteScript(root, kRemoveFrameScript)); |
6320 EXPECT_EQ(0U, root->child_count()); | 6018 EXPECT_EQ(0U, root->child_count()); |
6321 if (SiteIsolationPolicy::UseSubframeNavigationEntries()) | 6019 EXPECT_EQ(1U, nav_entry->root_node()->children.size()); |
6322 EXPECT_EQ(1U, nav_entry->root_node()->children.size()); | |
6323 | 6020 |
6324 // Add another frame with the same name as before. The matching logic | 6021 // Add another frame with the same name as before. The matching logic |
6325 // should consider them the same and result in the FrameNavigationEntry | 6022 // should consider them the same and result in the FrameNavigationEntry |
6326 // being reused. | 6023 // being reused. |
6327 EXPECT_TRUE(ExecuteScript(root, kAddNamedFrameScript)); | 6024 EXPECT_TRUE(ExecuteScript(root, kAddNamedFrameScript)); |
6328 EXPECT_EQ(1U, root->child_count()); | 6025 EXPECT_EQ(1U, root->child_count()); |
6329 if (SiteIsolationPolicy::UseSubframeNavigationEntries()) { | 6026 EXPECT_EQ(1U, nav_entry->root_node()->children.size()); |
6330 EXPECT_EQ(1U, nav_entry->root_node()->children.size()); | 6027 EXPECT_EQ(tree_node, nav_entry->root_node()->children[0]); |
6331 EXPECT_EQ(tree_node, nav_entry->root_node()->children[0]); | |
6332 } | |
6333 | 6028 |
6334 EXPECT_TRUE(ExecuteScript(root, kRemoveFrameScript)); | 6029 EXPECT_TRUE(ExecuteScript(root, kRemoveFrameScript)); |
6335 EXPECT_EQ(0U, root->child_count()); | 6030 EXPECT_EQ(0U, root->child_count()); |
6336 } | 6031 } |
6337 | 6032 |
6338 // Test that navigations classified as SAME_PAGE properly update all the | 6033 // Test that navigations classified as SAME_PAGE properly update all the |
6339 // members of FrameNavigationEntry. If not, it is possible to get a mismatch | 6034 // members of FrameNavigationEntry. If not, it is possible to get a mismatch |
6340 // between the origin and URL of a document as seen in | 6035 // between the origin and URL of a document as seen in |
6341 // https://crbug.com/630103. | 6036 // https://crbug.com/630103. |
6342 IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest, | 6037 IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest, |
(...skipping 427 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
6770 | 6465 |
6771 controller.Reload(ReloadType::NORMAL, false); | 6466 controller.Reload(ReloadType::NORMAL, false); |
6772 EXPECT_TRUE(WaitForLoadStop(shell()->web_contents())); | 6467 EXPECT_TRUE(WaitForLoadStop(shell()->web_contents())); |
6773 histogram.ExpectTotalCount(kReloadToReloadMetricName, 4); | 6468 histogram.ExpectTotalCount(kReloadToReloadMetricName, 4); |
6774 histogram.ExpectTotalCount(kReloadMainResourceToReloadMetricName, 3); | 6469 histogram.ExpectTotalCount(kReloadMainResourceToReloadMetricName, 3); |
6775 } | 6470 } |
6776 | 6471 |
6777 // Check that the referrer is stored inside FrameNavigationEntry for subframes. | 6472 // Check that the referrer is stored inside FrameNavigationEntry for subframes. |
6778 IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest, | 6473 IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest, |
6779 RefererStoredForSubFrame) { | 6474 RefererStoredForSubFrame) { |
6780 if (!SiteIsolationPolicy::UseSubframeNavigationEntries()) | |
6781 return; | |
6782 | |
6783 const NavigationControllerImpl& controller = | 6475 const NavigationControllerImpl& controller = |
6784 static_cast<const NavigationControllerImpl&>( | 6476 static_cast<const NavigationControllerImpl&>( |
6785 shell()->web_contents()->GetController()); | 6477 shell()->web_contents()->GetController()); |
6786 | 6478 |
6787 GURL url_simple(embedded_test_server()->GetURL( | 6479 GURL url_simple(embedded_test_server()->GetURL( |
6788 "/navigation_controller/page_with_iframe_simple.html")); | 6480 "/navigation_controller/page_with_iframe_simple.html")); |
6789 GURL url_redirect(embedded_test_server()->GetURL( | 6481 GURL url_redirect(embedded_test_server()->GetURL( |
6790 "/navigation_controller/page_with_iframe_redirect.html")); | 6482 "/navigation_controller/page_with_iframe_redirect.html")); |
6791 | 6483 |
6792 // Run this test twice: with and without a redirection. | 6484 // Run this test twice: with and without a redirection. |
(...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
7034 NavigationHandleCommitObserver handle_observer(shell()->web_contents(), | 6726 NavigationHandleCommitObserver handle_observer(shell()->web_contents(), |
7035 kFragmentURL); | 6727 kFragmentURL); |
7036 EXPECT_TRUE(NavigateToURL(shell(), kFragmentURL)); | 6728 EXPECT_TRUE(NavigateToURL(shell(), kFragmentURL)); |
7037 | 6729 |
7038 EXPECT_TRUE(handle_observer.has_committed()); | 6730 EXPECT_TRUE(handle_observer.has_committed()); |
7039 EXPECT_TRUE(handle_observer.was_same_page()); | 6731 EXPECT_TRUE(handle_observer.was_same_page()); |
7040 EXPECT_FALSE(handle_observer.was_renderer_initiated()); | 6732 EXPECT_FALSE(handle_observer.was_renderer_initiated()); |
7041 } | 6733 } |
7042 | 6734 |
7043 } // namespace content | 6735 } // namespace content |
OLD | NEW |