OLD | NEW |
---|---|
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 <set> | 5 #include <set> |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/json/json_reader.h" | 8 #include "base/json/json_reader.h" |
9 #include "base/memory/ref_counted.h" | 9 #include "base/memory/ref_counted.h" |
10 #include "base/path_service.h" | 10 #include "base/path_service.h" |
(...skipping 1788 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1799 RenderFrameHostDestructionObserver rfh_observer(root->current_frame_host()); | 1799 RenderFrameHostDestructionObserver rfh_observer(root->current_frame_host()); |
1800 NavigateToURL(shell(), cross_site_url); | 1800 NavigateToURL(shell(), cross_site_url); |
1801 rfh_observer.Wait(); | 1801 rfh_observer.Wait(); |
1802 | 1802 |
1803 EXPECT_NE(orig_site_instance_id, | 1803 EXPECT_NE(orig_site_instance_id, |
1804 root->current_frame_host()->GetSiteInstance()->GetId()); | 1804 root->current_frame_host()->GetSiteInstance()->GetId()); |
1805 EXPECT_FALSE(RenderFrameHost::FromID(initial_process_id, initial_rfh_id)); | 1805 EXPECT_FALSE(RenderFrameHost::FromID(initial_process_id, initial_rfh_id)); |
1806 EXPECT_FALSE(RenderViewHost::FromID(initial_process_id, initial_rvh_id)); | 1806 EXPECT_FALSE(RenderViewHost::FromID(initial_process_id, initial_rvh_id)); |
1807 } | 1807 } |
1808 | 1808 |
1809 // This class ensures that all RenderFrameCreated callbacks have processes with | |
1810 // IPC channels. | |
1811 class RenderFrameCreatedHasConnectionObserver : public WebContentsObserver { | |
1812 public: | |
1813 explicit RenderFrameCreatedHasConnectionObserver(WebContents* web_contents) | |
1814 : WebContentsObserver(web_contents) {} | |
1815 ~RenderFrameCreatedHasConnectionObserver() override {} | |
1816 | |
1817 private: | |
1818 // WebContentsObserver implementation: | |
1819 void RenderFrameCreated(RenderFrameHost* render_frame_host) override { | |
1820 EXPECT_TRUE(render_frame_host->GetProcess()->HasConnection()); | |
1821 EXPECT_TRUE(static_cast<RenderFrameHostImpl*>(render_frame_host) | |
1822 ->IsRenderFrameLive()); | |
ncarter (slow)
2015/06/04 18:20:46
Rather than opening up WebContentsObserver so that
| |
1823 } | |
1824 }; | |
1825 | |
1826 // This class installs the RenderFrameCreatedHasConnectionObserver when the | |
1827 // new WebContents is created. | |
1828 class InstallRFCObserver : public WebContentsAddedObserver { | |
1829 public: | |
1830 InstallRFCObserver() : rfco_(nullptr) {} | |
1831 ~InstallRFCObserver() override { delete rfco_; } | |
1832 | |
1833 private: | |
1834 void WebContentsCreated(WebContents* web_contents) override { | |
1835 rfco_ = new RenderFrameCreatedHasConnectionObserver(web_contents); | |
1836 | |
1837 WebContentsAddedObserver::WebContentsCreated(web_contents); | |
1838 } | |
1839 | |
1840 RenderFrameCreatedHasConnectionObserver* rfco_; | |
1841 }; | |
1842 | |
1843 // Following a cross-site link with rel=noreferrer and target=_blank should | |
1844 // fire RenderFrameCreated only after the process is created. | |
1845 IN_PROC_BROWSER_TEST_F(RenderFrameHostManagerTest, | |
1846 RenderFrameCreatedWithRelNoreferrerAndTargetBlank) { | |
1847 StartServer(); | |
1848 | |
1849 // Load a page with links that open in a new window. | |
1850 std::string replacement_path; | |
1851 ASSERT_TRUE(GetFilePathWithHostAndPortReplacement( | |
1852 "files/click-noreferrer-links.html", | |
1853 foo_host_port_, | |
1854 &replacement_path)); | |
1855 NavigateToURL(shell(), test_server()->GetURL(replacement_path)); | |
1856 | |
1857 // Test clicking a rel=noreferrer + target=blank link. | |
1858 InstallRFCObserver web_contents_observer; | |
1859 bool success = false; | |
1860 EXPECT_TRUE(ExecuteScriptAndExtractBool( | |
1861 shell()->web_contents(), | |
1862 "window.domAutomationController.send(clickNoRefTargetBlankLink());", | |
1863 &success)); | |
1864 EXPECT_TRUE(success); | |
1865 | |
1866 // Wait for the WebContents to be created. | |
1867 WebContentsImpl* new_web_contents = | |
1868 static_cast<WebContentsImpl*>(web_contents_observer.GetWebContents()); | |
1869 | |
1870 // Wait for the cross-site transition in the new tab to finish. | |
1871 WaitForLoadStop(new_web_contents); | |
1872 EXPECT_EQ("/files/title2.html", new_web_contents->GetVisibleURL().path()); | |
1873 } | |
1874 | |
1809 } // namespace content | 1875 } // namespace content |
OLD | NEW |