Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1131)

Side by Side Diff: content/browser/frame_host/render_frame_host_manager_browsertest.cc

Issue 1149883003: Revert of Add tests to ensure no RFH/RVH objects leak on cross-process navigation (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | content/browser/site_per_process_browsertest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 17 matching lines...) Expand all
28 #include "content/public/common/page_state.h" 28 #include "content/public/common/page_state.h"
29 #include "content/public/common/url_constants.h" 29 #include "content/public/common/url_constants.h"
30 #include "content/public/test/browser_test_utils.h" 30 #include "content/public/test/browser_test_utils.h"
31 #include "content/public/test/content_browser_test.h" 31 #include "content/public/test/content_browser_test.h"
32 #include "content/public/test/content_browser_test_utils.h" 32 #include "content/public/test/content_browser_test_utils.h"
33 #include "content/public/test/test_navigation_observer.h" 33 #include "content/public/test/test_navigation_observer.h"
34 #include "content/public/test/test_utils.h" 34 #include "content/public/test/test_utils.h"
35 #include "content/shell/browser/shell.h" 35 #include "content/shell/browser/shell.h"
36 #include "net/base/net_util.h" 36 #include "net/base/net_util.h"
37 #include "net/dns/mock_host_resolver.h" 37 #include "net/dns/mock_host_resolver.h"
38 #include "net/test/embedded_test_server/embedded_test_server.h"
39 #include "net/test/spawned_test_server/spawned_test_server.h" 38 #include "net/test/spawned_test_server/spawned_test_server.h"
40 39
41 using base::ASCIIToUTF16; 40 using base::ASCIIToUTF16;
42 41
43 namespace content { 42 namespace content {
44 43
45 namespace { 44 namespace {
46 45
47 const char kOpenUrlViaClickTargetFunc[] = 46 const char kOpenUrlViaClickTargetFunc[] =
48 "(function(url) {\n" 47 "(function(url) {\n"
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
81 80
82 void StartServer() { 81 void StartServer() {
83 // Support multiple sites on the test server. 82 // Support multiple sites on the test server.
84 host_resolver()->AddRule("*", "127.0.0.1"); 83 host_resolver()->AddRule("*", "127.0.0.1");
85 ASSERT_TRUE(test_server()->Start()); 84 ASSERT_TRUE(test_server()->Start());
86 85
87 foo_host_port_ = test_server()->host_port_pair(); 86 foo_host_port_ = test_server()->host_port_pair();
88 foo_host_port_.set_host(foo_com_); 87 foo_host_port_.set_host(foo_com_);
89 } 88 }
90 89
91 void StartEmbeddedServer() {
92 // Support multiple sites on the embedded test server.
93 host_resolver()->AddRule("*", "127.0.0.1");
94 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady());
95 SetupCrossSiteRedirector(embedded_test_server());
96 }
97
98 // Returns a URL on foo.com with the given path. 90 // Returns a URL on foo.com with the given path.
99 GURL GetCrossSiteURL(const std::string& path) { 91 GURL GetCrossSiteURL(const std::string& path) {
100 GURL cross_site_url(test_server()->GetURL(path)); 92 GURL cross_site_url(test_server()->GetURL(path));
101 return cross_site_url.ReplaceComponents(replace_host_); 93 return cross_site_url.ReplaceComponents(replace_host_);
102 } 94 }
103 95
104 protected: 96 protected:
105 std::string foo_com_; 97 std::string foo_com_;
106 GURL::Replacements replace_host_; 98 GURL::Replacements replace_host_;
107 net::HostPortPair foo_host_port_; 99 net::HostPortPair foo_host_port_;
(...skipping 1615 matching lines...) Expand 10 before | Expand all | Expand 10 after
1723 shell()->web_contents()->GetController().GoBack(); 1715 shell()->web_contents()->GetController().GoBack();
1724 back_nav_load_observer.Wait(); 1716 back_nav_load_observer.Wait();
1725 EXPECT_NE(process_id, 1717 EXPECT_NE(process_id,
1726 shell()->web_contents()->GetRenderProcessHost()->GetID()); 1718 shell()->web_contents()->GetRenderProcessHost()->GetID());
1727 1719
1728 // Ensure that the file access still exists in the new process ID. 1720 // Ensure that the file access still exists in the new process ID.
1729 EXPECT_TRUE(ChildProcessSecurityPolicyImpl::GetInstance()->CanReadFile( 1721 EXPECT_TRUE(ChildProcessSecurityPolicyImpl::GetInstance()->CanReadFile(
1730 shell()->web_contents()->GetRenderProcessHost()->GetID(), file)); 1722 shell()->web_contents()->GetRenderProcessHost()->GetID(), file));
1731 } 1723 }
1732 1724
1733 // Ensures that no RenderFrameHost/RenderViewHost objects are leaked when
1734 // doing a simple cross-process navigation.
1735 IN_PROC_BROWSER_TEST_F(RenderFrameHostManagerTest,
1736 CleanupOnCrossProcessNavigation) {
1737 StartEmbeddedServer();
1738
1739 // Do an initial navigation and capture objects we expect to be cleaned up
1740 // on cross-process navigation.
1741 GURL start_url = embedded_test_server()->GetURL("/title1.html");
1742 NavigateToURL(shell(), start_url);
1743
1744 FrameTreeNode* root = static_cast<WebContentsImpl*>(shell()->web_contents())
1745 ->GetFrameTree()
1746 ->root();
1747 SiteInstance* orig_site = root->current_frame_host()->GetSiteInstance();
1748 int initial_process_id = orig_site->GetProcess()->GetID();
1749 int initial_rfh_id = root->current_frame_host()->GetRoutingID();
1750 int initial_rvh_id =
1751 root->current_frame_host()->render_view_host()->GetRoutingID();
1752
1753 // Navigate cross-process and ensure that cleanup is performed as expected.
1754 GURL cross_site_url =
1755 embedded_test_server()->GetURL("foo.com", "/title2.html");
1756 NavigateToURL(shell(), cross_site_url);
1757
1758 EXPECT_NE(orig_site, root->current_frame_host()->GetSiteInstance());
1759 EXPECT_FALSE(RenderFrameHost::FromID(initial_process_id, initial_rfh_id));
1760 EXPECT_FALSE(RenderViewHost::FromID(initial_process_id, initial_rvh_id));
1761 }
1762
1763 } // namespace content 1725 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | content/browser/site_per_process_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698