Chromium Code Reviews| 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/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 Loading... | |
| 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, VerifyProxyCreation) { | |
|
Charlie Reis
2014/07/24 22:36:29
nit: VerifyProxyCreation makes it sound like a net
kenrb
2014/07/25 23:42:05
I've changed the test name but left the class name
| |
| 175 host_resolver()->AddRule("*", "127.0.0.1"); | |
| 176 ASSERT_TRUE(test_server()->Start()); | |
| 177 GURL main_url(test_server()->GetURL("files/site_per_process_main.html")); | |
| 178 NavigateToURL(shell(), main_url); | |
| 179 | |
| 180 // It is safe to obtain the root frame tree node here, as it doesn't change. | |
| 181 FrameTreeNode* root = static_cast<WebContentsImpl*>(shell()->web_contents()) | |
| 182 ->GetFrameTree()->root(); | |
| 183 | |
| 184 // Load same-site page into iframe. | |
| 185 GURL http_url(test_server()->GetURL("files/title1.html")); | |
| 186 NavigateFrameToURL(root->child_at(0), http_url); | |
| 187 | |
| 188 // These must stay in scope with replace_host. | |
| 189 GURL::Replacements replace_host; | |
| 190 std::string foo_com("foo.com"); | |
| 191 | |
| 192 // Load cross-site page into iframe. | |
| 193 GURL cross_site_url(test_server()->GetURL("files/title2.html")); | |
| 194 replace_host.SetHostStr(foo_com); | |
| 195 cross_site_url = cross_site_url.ReplaceComponents(replace_host); | |
| 196 NavigateFrameToURL(root->child_at(0), cross_site_url); | |
| 197 | |
| 198 // Ensure that we have created a new process for the subframe. | |
| 199 ASSERT_EQ(1U, root->child_count()); | |
| 200 FrameTreeNode* child = root->child_at(0); | |
| 201 SiteInstance* site_instance = child->current_frame_host()->GetSiteInstance(); | |
| 202 RenderViewHost* rvh = child->current_frame_host()->render_view_host(); | |
| 203 RenderProcessHost* rph = child->current_frame_host()->GetProcess(); | |
| 204 | |
| 205 EXPECT_NE(shell()->web_contents()->GetRenderViewHost(), rvh); | |
| 206 EXPECT_NE(shell()->web_contents()->GetSiteInstance(), site_instance); | |
| 207 EXPECT_NE(shell()->web_contents()->GetRenderProcessHost(), rph); | |
| 208 | |
| 209 // Ensure that the root node has a proxy for the child node's SiteInstance. | |
| 210 EXPECT_TRUE(root->render_manager()->proxy_hosts_[site_instance->GetId()]); | |
|
Charlie Reis
2014/07/24 22:36:29
Are we creating the proxy in the subframe for the
nasko
2014/07/25 07:13:20
That should be created by the virtue of cross-proc
| |
| 211 } | |
| 212 | |
| 158 } // namespace content | 213 } // namespace content |
| OLD | NEW |