| OLD | NEW |
| 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 "base/command_line.h" | 5 #include "base/command_line.h" |
| 6 #include "base/strings/stringprintf.h" | 6 #include "base/strings/stringprintf.h" |
| 7 #include "base/strings/utf_string_conversions.h" | 7 #include "base/strings/utf_string_conversions.h" |
| 8 #include "content/browser/frame_host/frame_tree.h" | 8 #include "content/browser/frame_host/frame_tree.h" |
| 9 #include "content/browser/renderer_host/render_view_host_impl.h" | 9 #include "content/browser/renderer_host/render_view_host_impl.h" |
| 10 #include "content/browser/web_contents/web_contents_impl.h" | 10 #include "content/browser/web_contents/web_contents_impl.h" |
| (...skipping 13 matching lines...) Expand all Loading... |
| 24 #include "content/test/content_browser_test_utils.h" | 24 #include "content/test/content_browser_test_utils.h" |
| 25 #include "net/base/escape.h" | 25 #include "net/base/escape.h" |
| 26 #include "net/dns/mock_host_resolver.h" | 26 #include "net/dns/mock_host_resolver.h" |
| 27 | 27 |
| 28 namespace content { | 28 namespace content { |
| 29 | 29 |
| 30 class SitePerProcessWebContentsObserver: public WebContentsObserver { | 30 class SitePerProcessWebContentsObserver: public WebContentsObserver { |
| 31 public: | 31 public: |
| 32 explicit SitePerProcessWebContentsObserver(WebContents* web_contents) | 32 explicit SitePerProcessWebContentsObserver(WebContents* web_contents) |
| 33 : WebContentsObserver(web_contents), | 33 : WebContentsObserver(web_contents), |
| 34 navigation_succeeded_(true) {} | 34 navigation_succeeded_(false) {} |
| 35 virtual ~SitePerProcessWebContentsObserver() {} | 35 virtual ~SitePerProcessWebContentsObserver() {} |
| 36 | 36 |
| 37 virtual void DidStartProvisionalLoadForFrame( |
| 38 int64 frame_id, |
| 39 int64 parent_frame_id, |
| 40 bool is_main_frame, |
| 41 const GURL& validated_url, |
| 42 bool is_error_page, |
| 43 bool is_iframe_srcdoc, |
| 44 RenderViewHost* render_view_host) OVERRIDE { |
| 45 navigation_succeeded_ = false; |
| 46 } |
| 47 |
| 37 virtual void DidFailProvisionalLoad( | 48 virtual void DidFailProvisionalLoad( |
| 38 int64 frame_id, | 49 int64 frame_id, |
| 39 const base::string16& frame_unique_name, | 50 const base::string16& frame_unique_name, |
| 40 bool is_main_frame, | 51 bool is_main_frame, |
| 41 const GURL& validated_url, | 52 const GURL& validated_url, |
| 42 int error_code, | 53 int error_code, |
| 43 const base::string16& error_description, | 54 const base::string16& error_description, |
| 44 RenderViewHost* render_view_host) OVERRIDE { | 55 RenderViewHost* render_view_host) OVERRIDE { |
| 45 navigation_url_ = validated_url; | 56 navigation_url_ = validated_url; |
| 46 navigation_succeeded_ = false; | 57 navigation_succeeded_ = false; |
| (...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 177 bool result = ExecuteScript(window->web_contents(), script); | 188 bool result = ExecuteScript(window->web_contents(), script); |
| 178 EXPECT_TRUE(result); | 189 EXPECT_TRUE(result); |
| 179 load_observer.Wait(); | 190 load_observer.Wait(); |
| 180 } | 191 } |
| 181 | 192 |
| 182 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { | 193 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { |
| 183 command_line->AppendSwitch(switches::kSitePerProcess); | 194 command_line->AppendSwitch(switches::kSitePerProcess); |
| 184 } | 195 } |
| 185 }; | 196 }; |
| 186 | 197 |
| 187 // TODO(nasko): Disable this test until out-of-process iframes is ready and the | 198 // Ensure that we can complete a cross-process subframe navigation. |
| 188 // security checks are back in place. | 199 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, CrossSiteIframe) { |
| 189 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, DISABLED_CrossSiteIframe) { | |
| 190 ASSERT_TRUE(test_server()->Start()); | 200 ASSERT_TRUE(test_server()->Start()); |
| 191 net::SpawnedTestServer https_server( | 201 net::SpawnedTestServer https_server( |
| 192 net::SpawnedTestServer::TYPE_HTTPS, | 202 net::SpawnedTestServer::TYPE_HTTPS, |
| 193 net::SpawnedTestServer::kLocalhost, | 203 net::SpawnedTestServer::kLocalhost, |
| 194 base::FilePath(FILE_PATH_LITERAL("content/test/data"))); | 204 base::FilePath(FILE_PATH_LITERAL("content/test/data"))); |
| 195 ASSERT_TRUE(https_server.Start()); | 205 ASSERT_TRUE(https_server.Start()); |
| 196 GURL main_url(test_server()->GetURL("files/site_per_process_main.html")); | 206 GURL main_url(test_server()->GetURL("files/site_per_process_main.html")); |
| 197 | 207 |
| 198 NavigateToURL(shell(), main_url); | 208 NavigateToURL(shell(), main_url); |
| 199 | 209 |
| 200 SitePerProcessWebContentsObserver observer(shell()->web_contents()); | 210 SitePerProcessWebContentsObserver observer(shell()->web_contents()); |
| 201 { | |
| 202 // Load same-site page into Iframe. | |
| 203 GURL http_url(test_server()->GetURL("files/title1.html")); | |
| 204 EXPECT_TRUE(NavigateIframeToURL(shell(), http_url, "test")); | |
| 205 EXPECT_EQ(observer.navigation_url(), http_url); | |
| 206 EXPECT_TRUE(observer.navigation_succeeded()); | |
| 207 } | |
| 208 | 211 |
| 209 { | 212 // Load same-site page into iframe. |
| 210 // Load cross-site page into Iframe. | 213 GURL http_url(test_server()->GetURL("files/title1.html")); |
| 211 GURL https_url(https_server.GetURL("files/title1.html")); | 214 EXPECT_TRUE(NavigateIframeToURL(shell(), http_url, "test")); |
| 212 EXPECT_TRUE(NavigateIframeToURL(shell(), https_url, "test")); | 215 EXPECT_EQ(observer.navigation_url(), http_url); |
| 213 EXPECT_EQ(observer.navigation_url(), https_url); | 216 EXPECT_TRUE(observer.navigation_succeeded()); |
| 214 EXPECT_FALSE(observer.navigation_succeeded()); | 217 |
| 215 } | 218 // Load cross-site page into iframe. |
| 219 GURL https_url(https_server.GetURL("files/title1.html")); |
| 220 EXPECT_TRUE(NavigateIframeToURL(shell(), https_url, "test")); |
| 221 EXPECT_EQ(observer.navigation_url(), https_url); |
| 222 EXPECT_TRUE(observer.navigation_succeeded()); |
| 223 |
| 224 // Ensure that we have created a new process for the subframe. |
| 225 FrameTreeNode* root = |
| 226 static_cast<WebContentsImpl*>(shell()->web_contents())-> |
| 227 GetFrameTree()->root(); |
| 228 ASSERT_EQ(1U, root->child_count()); |
| 229 FrameTreeNode* child = root->child_at(0); |
| 230 EXPECT_NE(shell()->web_contents()->GetRenderViewHost(), |
| 231 child->current_frame_host()->render_view_host()); |
| 232 EXPECT_NE(shell()->web_contents()->GetSiteInstance(), |
| 233 child->current_frame_host()->render_view_host()->GetSiteInstance()); |
| 234 EXPECT_NE(shell()->web_contents()->GetRenderProcessHost(), |
| 235 child->current_frame_host()->GetProcess()); |
| 216 } | 236 } |
| 217 | 237 |
| 218 // TODO(nasko): Disable this test until out-of-process iframes is ready and the | 238 // TODO(nasko): Disable this test until out-of-process iframes is ready and the |
| 219 // security checks are back in place. | 239 // security checks are back in place. |
| 220 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, | 240 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, |
| 221 DISABLED_CrossSiteIframeRedirectOnce) { | 241 DISABLED_CrossSiteIframeRedirectOnce) { |
| 222 ASSERT_TRUE(test_server()->Start()); | 242 ASSERT_TRUE(test_server()->Start()); |
| 223 net::SpawnedTestServer https_server( | 243 net::SpawnedTestServer https_server( |
| 224 net::SpawnedTestServer::TYPE_HTTPS, | 244 net::SpawnedTestServer::TYPE_HTTPS, |
| 225 net::SpawnedTestServer::kLocalhost, | 245 net::SpawnedTestServer::kLocalhost, |
| (...skipping 489 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 715 // There should be two history entries. url2b should have replaced url1. url2b | 735 // There should be two history entries. url2b should have replaced url1. url2b |
| 716 // should not have replaced url3b. | 736 // should not have replaced url3b. |
| 717 EXPECT_TRUE(controller.GetPendingEntry() == NULL); | 737 EXPECT_TRUE(controller.GetPendingEntry() == NULL); |
| 718 EXPECT_EQ(2, controller.GetEntryCount()); | 738 EXPECT_EQ(2, controller.GetEntryCount()); |
| 719 EXPECT_EQ(1, controller.GetCurrentEntryIndex()); | 739 EXPECT_EQ(1, controller.GetCurrentEntryIndex()); |
| 720 EXPECT_EQ(url2b, controller.GetEntryAtIndex(0)->GetURL()); | 740 EXPECT_EQ(url2b, controller.GetEntryAtIndex(0)->GetURL()); |
| 721 EXPECT_EQ(url3b, controller.GetEntryAtIndex(1)->GetURL()); | 741 EXPECT_EQ(url3b, controller.GetEntryAtIndex(1)->GetURL()); |
| 722 } | 742 } |
| 723 | 743 |
| 724 } // namespace content | 744 } // namespace content |
| OLD | NEW |