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

Side by Side Diff: content/browser/site_per_process_browsertest.cc

Issue 1074843002: Fix RenderFrameProxyHost leak. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@lucasfix
Patch Set: Add comment suggested by Charlie Created 5 years, 8 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 | « content/browser/site_per_process_browsertest.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/browser/site_per_process_browsertest.h" 5 #include "content/browser/site_per_process_browsertest.h"
6 6
7 #include <algorithm>
8 #include <vector>
9
7 #include "base/command_line.h" 10 #include "base/command_line.h"
8 #include "base/strings/stringprintf.h" 11 #include "base/strings/stringprintf.h"
9 #include "base/strings/utf_string_conversions.h" 12 #include "base/strings/utf_string_conversions.h"
10 #include "content/browser/frame_host/cross_process_frame_connector.h" 13 #include "content/browser/frame_host/cross_process_frame_connector.h"
11 #include "content/browser/frame_host/frame_tree.h" 14 #include "content/browser/frame_host/frame_tree.h"
12 #include "content/browser/frame_host/navigator.h" 15 #include "content/browser/frame_host/navigator.h"
13 #include "content/browser/frame_host/render_frame_proxy_host.h" 16 #include "content/browser/frame_host/render_frame_proxy_host.h"
14 #include "content/browser/frame_host/render_widget_host_view_child_frame.h" 17 #include "content/browser/frame_host/render_widget_host_view_child_frame.h"
15 #include "content/browser/renderer_host/render_view_host_impl.h" 18 #include "content/browser/renderer_host/render_view_host_impl.h"
16 #include "content/browser/web_contents/web_contents_impl.h" 19 #include "content/browser/web_contents/web_contents_impl.h"
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
159 } 162 }
160 } 163 }
161 164
162 // 165 //
163 // SitePerProcessBrowserTest 166 // SitePerProcessBrowserTest
164 // 167 //
165 168
166 SitePerProcessBrowserTest::SitePerProcessBrowserTest() { 169 SitePerProcessBrowserTest::SitePerProcessBrowserTest() {
167 }; 170 };
168 171
172 // static
173 std::string SitePerProcessBrowserTest::DumpProxyHostSiteInstances(
174 FrameTreeNode* node) {
175 std::vector<std::string> sites;
176 for (auto& entry_pair : node->render_manager()->proxy_hosts_) {
177 sites.push_back(entry_pair.second->GetSiteInstance()->GetSiteURL().spec());
178 }
179 std::sort(sites.begin(), sites.end());
180 std::string result;
181 for (auto& site : sites) {
182 if (!result.empty())
183 result.append("\n");
184 result.append(site);
185 }
186 return result;
187 }
188
169 void SitePerProcessBrowserTest::StartFrameAtDataURL() { 189 void SitePerProcessBrowserTest::StartFrameAtDataURL() {
170 std::string data_url_script = 190 std::string data_url_script =
171 "var iframes = document.getElementById('test');iframes.src=" 191 "var iframes = document.getElementById('test');iframes.src="
172 "'data:text/html,dataurl';"; 192 "'data:text/html,dataurl';";
173 ASSERT_TRUE(ExecuteScript(shell()->web_contents(), data_url_script)); 193 ASSERT_TRUE(ExecuteScript(shell()->web_contents(), data_url_script));
174 } 194 }
175 195
176 void SitePerProcessBrowserTest::SetUpCommandLine( 196 void SitePerProcessBrowserTest::SetUpCommandLine(
177 base::CommandLine* command_line) { 197 base::CommandLine* command_line) {
178 command_line->AppendSwitch(switches::kSitePerProcess); 198 command_line->AppendSwitch(switches::kSitePerProcess);
(...skipping 1720 matching lines...) Expand 10 before | Expand all | Expand 10 after
1899 "window.domAutomationController.send(window.receivedMessages);", 1919 "window.domAutomationController.send(window.receivedMessages);",
1900 &subframe1_received_messages)); 1920 &subframe1_received_messages));
1901 EXPECT_EQ(1, subframe1_received_messages); 1921 EXPECT_EQ(1, subframe1_received_messages);
1902 EXPECT_TRUE(ExecuteScriptAndExtractInt( 1922 EXPECT_TRUE(ExecuteScriptAndExtractInt(
1903 root->child_at(1)->current_frame_host(), 1923 root->child_at(1)->current_frame_host(),
1904 "window.domAutomationController.send(window.receivedMessages);", 1924 "window.domAutomationController.send(window.receivedMessages);",
1905 &subframe2_received_messages)); 1925 &subframe2_received_messages));
1906 EXPECT_EQ(2, subframe2_received_messages); 1926 EXPECT_EQ(2, subframe2_received_messages);
1907 } 1927 }
1908 1928
1929 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, RFPHDestruction) {
1930 GURL main_url(embedded_test_server()->GetURL("/site_per_process_main.html"));
1931 NavigateToURL(shell(), main_url);
1932
1933 // It is safe to obtain the root frame tree node here, as it doesn't change.
1934 FrameTreeNode* root = static_cast<WebContentsImpl*>(shell()->web_contents())
1935 ->GetFrameTree()
1936 ->root();
1937
1938 TestNavigationObserver observer(shell()->web_contents());
1939
1940 // Load cross-site page into iframe.
1941 FrameTreeNode* child = root->child_at(0);
1942 GURL url = embedded_test_server()->GetURL("foo.com", "/title2.html");
1943 NavigateFrameToURL(root->child_at(0), url);
1944 EXPECT_TRUE(observer.last_navigation_succeeded());
1945 EXPECT_EQ(url, observer.last_navigation_url());
1946 EXPECT_EQ("http://foo.com/", DumpProxyHostSiteInstances(root));
1947
1948 // Load another cross-site page.
1949 url = embedded_test_server()->GetURL("bar.com", "/title3.html");
1950 NavigateIframeToURL(shell()->web_contents(), "test", url);
1951 EXPECT_TRUE(observer.last_navigation_succeeded());
1952 EXPECT_EQ(url, observer.last_navigation_url());
1953 EXPECT_EQ("http://bar.com/", DumpProxyHostSiteInstances(root));
1954
1955 // Navigate back to the parent's origin.
1956 url = embedded_test_server()->GetURL("/title1.html");
1957 NavigateFrameToURL(child, url);
1958 EXPECT_EQ(url, observer.last_navigation_url());
1959 EXPECT_TRUE(observer.last_navigation_succeeded());
1960 EXPECT_EQ("", DumpProxyHostSiteInstances(root));
1961 }
1962
1909 } // namespace content 1963 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/site_per_process_browsertest.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698