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

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

Issue 404613005: Start using RenderFrameProxyHost objects. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Compile fix Created 6 years, 4 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 | Annotate | Revision Log
OLDNEW
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/command_line.h"
5 #include "content/browser/frame_host/frame_tree.h" 6 #include "content/browser/frame_host/frame_tree.h"
6 #include "content/browser/frame_host/frame_tree_node.h" 7 #include "content/browser/frame_host/frame_tree_node.h"
7 #include "content/browser/renderer_host/render_view_host_impl.h" 8 #include "content/browser/renderer_host/render_view_host_impl.h"
8 #include "content/browser/web_contents/web_contents_impl.h" 9 #include "content/browser/web_contents/web_contents_impl.h"
9 #include "content/public/browser/notification_service.h" 10 #include "content/public/browser/notification_service.h"
10 #include "content/public/browser/notification_types.h" 11 #include "content/public/browser/notification_types.h"
12 #include "content/public/common/content_switches.h"
11 #include "content/public/common/url_constants.h" 13 #include "content/public/common/url_constants.h"
12 #include "content/public/test/browser_test_utils.h" 14 #include "content/public/test/browser_test_utils.h"
13 #include "content/public/test/content_browser_test.h" 15 #include "content/public/test/content_browser_test.h"
14 #include "content/public/test/content_browser_test_utils.h" 16 #include "content/public/test/content_browser_test_utils.h"
15 #include "content/public/test/test_navigation_observer.h" 17 #include "content/public/test/test_navigation_observer.h"
16 #include "content/public/test/test_utils.h" 18 #include "content/public/test/test_utils.h"
17 #include "content/shell/browser/shell.h" 19 #include "content/shell/browser/shell.h"
20 #include "content/test/content_browser_test_utils_internal.h"
18 #include "net/dns/mock_host_resolver.h" 21 #include "net/dns/mock_host_resolver.h"
19 22
20 namespace content { 23 namespace content {
21 24
22 class FrameTreeBrowserTest : public ContentBrowserTest { 25 class FrameTreeBrowserTest : public ContentBrowserTest {
23 public: 26 public:
24 FrameTreeBrowserTest() {} 27 FrameTreeBrowserTest() {}
25 28
26 private: 29 private:
27 DISALLOW_COPY_AND_ASSIGN(FrameTreeBrowserTest); 30 DISALLOW_COPY_AND_ASSIGN(FrameTreeBrowserTest);
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
148 // Navigate to a new URL. We use LoadURL because NavigateToURL will try to 151 // Navigate to a new URL. We use LoadURL because NavigateToURL will try to
149 // wait for the previous navigation to stop. 152 // wait for the previous navigation to stop.
150 TestNavigationObserver tab_observer(wc, 1); 153 TestNavigationObserver tab_observer(wc, 1);
151 shell()->LoadURL(base_url.Resolve("blank.html")); 154 shell()->LoadURL(base_url.Resolve("blank.html"));
152 tab_observer.Wait(); 155 tab_observer.Wait();
153 156
154 // The frame tree should now be cleared. 157 // The frame tree should now be cleared.
155 EXPECT_EQ(0UL, root->child_count()); 158 EXPECT_EQ(0UL, root->child_count());
156 } 159 }
157 160
161 class CrossProcessFrameTreeBrowserTest : public ContentBrowserTest {
162 public:
163 CrossProcessFrameTreeBrowserTest() {}
164
165 virtual void SetUpCommandLine(base::CommandLine* command_line) OVERRIDE {
166 command_line->AppendSwitch(switches::kSitePerProcess);
167 }
168
169 private:
170 DISALLOW_COPY_AND_ASSIGN(CrossProcessFrameTreeBrowserTest);
171 };
172
173 // Ensure that we can complete a cross-process subframe navigation.
174 IN_PROC_BROWSER_TEST_F(CrossProcessFrameTreeBrowserTest,
175 CreateCrossProcessSubframeProxies) {
176 host_resolver()->AddRule("*", "127.0.0.1");
177 ASSERT_TRUE(test_server()->Start());
178 GURL main_url(test_server()->GetURL("files/site_per_process_main.html"));
179 NavigateToURL(shell(), main_url);
180
181 // It is safe to obtain the root frame tree node here, as it doesn't change.
182 FrameTreeNode* root = static_cast<WebContentsImpl*>(shell()->web_contents())
183 ->GetFrameTree()->root();
184
185 // Load same-site page into iframe.
186 GURL http_url(test_server()->GetURL("files/title1.html"));
187 NavigateFrameToURL(root->child_at(0), http_url);
188
189 // These must stay in scope with replace_host.
190 GURL::Replacements replace_host;
191 std::string foo_com("foo.com");
192
193 // Load cross-site page into iframe.
194 GURL cross_site_url(test_server()->GetURL("files/title2.html"));
195 replace_host.SetHostStr(foo_com);
196 cross_site_url = cross_site_url.ReplaceComponents(replace_host);
197 NavigateFrameToURL(root->child_at(0), cross_site_url);
198
199 // Ensure that we have created a new process for the subframe.
200 ASSERT_EQ(1U, root->child_count());
201 FrameTreeNode* child = root->child_at(0);
202 SiteInstance* site_instance = child->current_frame_host()->GetSiteInstance();
203 RenderViewHost* rvh = child->current_frame_host()->render_view_host();
204 RenderProcessHost* rph = child->current_frame_host()->GetProcess();
205
206 EXPECT_NE(shell()->web_contents()->GetRenderViewHost(), rvh);
207 EXPECT_NE(shell()->web_contents()->GetSiteInstance(), site_instance);
208 EXPECT_NE(shell()->web_contents()->GetRenderProcessHost(), rph);
209
210 // Ensure that the root node has a proxy for the child node's SiteInstance.
211 EXPECT_TRUE(root->render_manager()->proxy_hosts_[site_instance->GetId()]);
Charlie Reis 2014/07/28 19:24:28 Nasko mentioned we should have a proxy in the subf
kenrb 2014/07/28 21:07:20 Done.
212 }
213
158 } // namespace content 214 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698