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 "base/bind.h" | 5 #include "base/bind.h" |
6 #include "base/strings/stringprintf.h" | 6 #include "base/strings/stringprintf.h" |
7 #include "base/strings/utf_string_conversions.h" | 7 #include "base/strings/utf_string_conversions.h" |
8 #include "content/browser/frame_host/frame_navigation_entry.h" | 8 #include "content/browser/frame_host/frame_navigation_entry.h" |
9 #include "content/browser/frame_host/frame_tree.h" | 9 #include "content/browser/frame_host/frame_tree.h" |
10 #include "content/browser/frame_host/navigation_controller_impl.h" | 10 #include "content/browser/frame_host/navigation_controller_impl.h" |
(...skipping 1674 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1685 EXPECT_EQ( | 1685 EXPECT_EQ( |
1686 " Site A ------------ proxies for B\n" | 1686 " Site A ------------ proxies for B\n" |
1687 " |--Site A ------- proxies for B\n" | 1687 " |--Site A ------- proxies for B\n" |
1688 " +--Site B ------- proxies for A\n" | 1688 " +--Site B ------- proxies for A\n" |
1689 "Where A = http://127.0.0.1/\n" | 1689 "Where A = http://127.0.0.1/\n" |
1690 " B = http://baz.com/", | 1690 " B = http://baz.com/", |
1691 visualizer.DepictFrameTree(root)); | 1691 visualizer.DepictFrameTree(root)); |
1692 } | 1692 } |
1693 } | 1693 } |
1694 | 1694 |
| 1695 // Ensure that we don't crash when navigating subframes after in-page |
| 1696 // navigations. See https://crbug.com/522193. |
| 1697 IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest, |
| 1698 FrameNavigationEntry_SubframeAfterInPage) { |
| 1699 // 1. Start on a page with a subframe. |
| 1700 GURL main_url(embedded_test_server()->GetURL( |
| 1701 "/navigation_controller/page_with_iframe.html")); |
| 1702 NavigateToURL(shell(), main_url); |
| 1703 FrameTreeNode* root = |
| 1704 static_cast<WebContentsImpl*>(shell()->web_contents())-> |
| 1705 GetFrameTree()->root(); |
| 1706 |
| 1707 ASSERT_EQ(1U, root->child_count()); |
| 1708 ASSERT_NE(nullptr, root->child_at(0)); |
| 1709 |
| 1710 // Navigate to a real page in the subframe, so that the next navigation will |
| 1711 // be MANUAL_SUBFRAME. |
| 1712 GURL subframe_url(embedded_test_server()->GetURL( |
| 1713 "/navigation_controller/simple_page_1.html")); |
| 1714 { |
| 1715 LoadCommittedCapturer capturer(root->child_at(0)); |
| 1716 NavigateFrameToURL(root->child_at(0), subframe_url); |
| 1717 capturer.Wait(); |
| 1718 EXPECT_EQ(ui::PAGE_TRANSITION_AUTO_SUBFRAME, capturer.transition_type()); |
| 1719 } |
| 1720 |
| 1721 // 2. In-page navigation in the main frame. |
| 1722 std::string push_script = "history.pushState({}, 'page 2', 'page_2.html')"; |
| 1723 EXPECT_TRUE(content::ExecuteScript(root->current_frame_host(), push_script)); |
| 1724 EXPECT_TRUE(WaitForLoadStop(shell()->web_contents())); |
| 1725 |
| 1726 // TODO(creis): Verify subframe entries. https://crbug.com/522193. |
| 1727 |
| 1728 // 3. Add a nested subframe. |
| 1729 { |
| 1730 LoadCommittedCapturer capturer(shell()->web_contents()); |
| 1731 std::string script = "var iframe = document.createElement('iframe');" |
| 1732 "iframe.src = '" + subframe_url.spec() + "';" |
| 1733 "document.body.appendChild(iframe);"; |
| 1734 EXPECT_TRUE(content::ExecuteScript(root->child_at(0)->current_frame_host(), |
| 1735 script)); |
| 1736 capturer.Wait(); |
| 1737 EXPECT_EQ(ui::PAGE_TRANSITION_AUTO_SUBFRAME, capturer.transition_type()); |
| 1738 } |
| 1739 |
| 1740 // TODO(creis): Verify subframe entries. https://crbug.com/522193. |
| 1741 } |
| 1742 |
1695 // Verify the tree of FrameNavigationEntries after back/forward navigations in a | 1743 // Verify the tree of FrameNavigationEntries after back/forward navigations in a |
1696 // cross-site subframe. | 1744 // cross-site subframe. |
1697 IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest, | 1745 IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest, |
1698 FrameNavigationEntry_SubframeBackForward) { | 1746 FrameNavigationEntry_SubframeBackForward) { |
1699 GURL main_url(embedded_test_server()->GetURL( | 1747 GURL main_url(embedded_test_server()->GetURL( |
1700 "/navigation_controller/simple_page_1.html")); | 1748 "/navigation_controller/simple_page_1.html")); |
1701 NavigateToURL(shell(), main_url); | 1749 NavigateToURL(shell(), main_url); |
1702 const NavigationControllerImpl& controller = | 1750 const NavigationControllerImpl& controller = |
1703 static_cast<const NavigationControllerImpl&>( | 1751 static_cast<const NavigationControllerImpl&>( |
1704 shell()->web_contents()->GetController()); | 1752 shell()->web_contents()->GetController()); |
(...skipping 629 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2334 EXPECT_EQ(original_url, capturer.all_params()[1].url); | 2382 EXPECT_EQ(original_url, capturer.all_params()[1].url); |
2335 EXPECT_EQ(original_url, shell()->web_contents()->GetLastCommittedURL()); | 2383 EXPECT_EQ(original_url, shell()->web_contents()->GetLastCommittedURL()); |
2336 } | 2384 } |
2337 | 2385 |
2338 // Make sure the renderer is still alive. | 2386 // Make sure the renderer is still alive. |
2339 EXPECT_TRUE( | 2387 EXPECT_TRUE( |
2340 ExecuteScript(shell()->web_contents(), "console.log('Success');")); | 2388 ExecuteScript(shell()->web_contents(), "console.log('Success');")); |
2341 } | 2389 } |
2342 | 2390 |
2343 } // namespace content | 2391 } // namespace content |
OLD | NEW |