| Index: content/browser/site_per_process_browsertest.cc
|
| diff --git a/content/browser/site_per_process_browsertest.cc b/content/browser/site_per_process_browsertest.cc
|
| index cc7e1fa3948a836a8c42f627173aa4f04ed8ba6c..30829bb89cd2cb0b520939e8ea031e10bf70f0ce 100644
|
| --- a/content/browser/site_per_process_browsertest.cc
|
| +++ b/content/browser/site_per_process_browsertest.cc
|
| @@ -6,6 +6,7 @@
|
|
|
| #include "base/command_line.h"
|
| #include "base/strings/stringprintf.h"
|
| +#include "base/strings/utf_string_conversions.h"
|
| #include "content/browser/frame_host/cross_process_frame_connector.h"
|
| #include "content/browser/frame_host/frame_tree.h"
|
| #include "content/browser/frame_host/navigator.h"
|
| @@ -231,9 +232,11 @@ bool SitePerProcessBrowserTest::NavigateIframeToURL(Shell* window,
|
| NOTIFICATION_NAV_ENTRY_COMMITTED,
|
| Source<NavigationController>(
|
| &window->web_contents()->GetController()));
|
| - bool result = ExecuteScript(window->web_contents(), script);
|
| + if (!ExecuteScript(window->web_contents(), script))
|
| + return false;
|
| load_observer.Wait();
|
| - return result;
|
| +
|
| + return true;
|
| }
|
|
|
| void SitePerProcessBrowserTest::SetUpCommandLine(CommandLine* command_line) {
|
| @@ -868,4 +871,103 @@ IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, OriginReplication) {
|
| EXPECT_EQ(result + "/", main_url.GetOrigin().spec());
|
| }
|
|
|
| +// TODO(lfg): Merge the test below with NavigateRemoteFrame test.
|
| +// TODO(lfg): Disabled because this triggers http://crbug.com/433012, and since
|
| +// the renderer process crashes, it causes the title watcher to never return.
|
| +// Alternatively, this could also be fixed if we could use NavigateIframeToURL
|
| +// and classified the navigation as MANUAL_SUBFRAME (http://crbug.com/441863) or
|
| +// if we waited for DidStopLoading (currently broken -- see comment in
|
| +// NavigateIframeToURL).
|
| +IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest,
|
| + DISABLED_NavigateRemoteToDataURL) {
|
| + GURL main_url(embedded_test_server()->GetURL("/site_per_process_main.html"));
|
| + NavigateToURL(shell(), main_url);
|
| +
|
| + // It is safe to obtain the root frame tree node here, as it doesn't change.
|
| + FrameTreeNode* root = static_cast<WebContentsImpl*>(shell()->web_contents())
|
| + ->GetFrameTree()
|
| + ->root();
|
| +
|
| + SitePerProcessWebContentsObserver observer(shell()->web_contents());
|
| +
|
| + // Load cross-site page into iframe.
|
| + GURL url = embedded_test_server()->GetURL("foo.com", "/title1.html");
|
| + NavigateFrameToURL(root->child_at(0), url);
|
| + EXPECT_TRUE(observer.navigation_succeeded());
|
| + EXPECT_EQ(url, observer.navigation_url());
|
| +
|
| + // Ensure that we have created a new process for the subframe.
|
| + EXPECT_NE(shell()->web_contents()->GetSiteInstance(),
|
| + root->child_at(0)->current_frame_host()->GetSiteInstance());
|
| +
|
| + // Navigate iframe to a data URL. The navigation happens from a script in the
|
| + // parent frame, so the data URL should be committed in the same SiteInstance
|
| + // as the parent frame.
|
| + GURL data_url("data:text/html,dataurl");
|
| + std::string script = base::StringPrintf(
|
| + "setTimeout(function() {"
|
| + "var iframe = document.getElementById('test');"
|
| + "iframe.onload = function() { document.title = 'LOADED'; };"
|
| + "iframe.src=\"%s\";"
|
| + "},0);",
|
| + data_url.spec().c_str());
|
| + base::string16 passed_string(base::UTF8ToUTF16("LOADED"));
|
| + TitleWatcher title_watcher(shell()->web_contents(), passed_string);
|
| + EXPECT_TRUE(ExecuteScript(shell()->web_contents(), script));
|
| + EXPECT_EQ(title_watcher.WaitAndGetTitle(), passed_string);
|
| + EXPECT_TRUE(observer.navigation_succeeded());
|
| + EXPECT_EQ(data_url, observer.navigation_url());
|
| +
|
| + // Ensure that we have navigated using the top level process.
|
| + EXPECT_EQ(shell()->web_contents()->GetSiteInstance(),
|
| + root->child_at(0)->current_frame_host()->GetSiteInstance());
|
| +}
|
| +
|
| +// TODO(lfg): Merge the test below with NavigateRemoteFrame test.
|
| +// Disabled due to the same reason as NavigateRemoteToDataURL.
|
| +IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest,
|
| + DISABLED_NavigateRemoteToBlankURL) {
|
| + GURL main_url(embedded_test_server()->GetURL("/site_per_process_main.html"));
|
| + NavigateToURL(shell(), main_url);
|
| +
|
| + // It is safe to obtain the root frame tree node here, as it doesn't change.
|
| + FrameTreeNode* root = static_cast<WebContentsImpl*>(shell()->web_contents())
|
| + ->GetFrameTree()
|
| + ->root();
|
| +
|
| + SitePerProcessWebContentsObserver observer(shell()->web_contents());
|
| +
|
| + // Load cross-site page into iframe.
|
| + GURL url = embedded_test_server()->GetURL("foo.com", "/title1.html");
|
| + NavigateFrameToURL(root->child_at(0), url);
|
| + EXPECT_TRUE(observer.navigation_succeeded());
|
| + EXPECT_EQ(url, observer.navigation_url());
|
| +
|
| + // Ensure that we have created a new process for the subframe.
|
| + EXPECT_NE(shell()->web_contents()->GetSiteInstance(),
|
| + root->child_at(0)->current_frame_host()->GetSiteInstance());
|
| +
|
| + // Navigate iframe to about:blank. The navigation happens from a script in the
|
| + // parent frame, so it should be committed in the same SiteInstance as the
|
| + // parent frame.
|
| + GURL about_blank_url("about:blank");
|
| + std::string script = base::StringPrintf(
|
| + "setTimeout(function() {"
|
| + "var iframe = document.getElementById('test');"
|
| + "iframe.onload = function() { document.title = 'LOADED'; };"
|
| + "iframe.src=\"%s\";"
|
| + "},0);",
|
| + about_blank_url.spec().c_str());
|
| + base::string16 passed_string(base::UTF8ToUTF16("LOADED"));
|
| + TitleWatcher title_watcher(shell()->web_contents(), passed_string);
|
| + EXPECT_TRUE(ExecuteScript(shell()->web_contents(), script));
|
| + EXPECT_EQ(title_watcher.WaitAndGetTitle(), passed_string);
|
| + EXPECT_TRUE(observer.navigation_succeeded());
|
| + EXPECT_EQ(about_blank_url, observer.navigation_url());
|
| +
|
| + // Ensure that we have navigated using the top level process.
|
| + EXPECT_EQ(shell()->web_contents()->GetSiteInstance(),
|
| + root->child_at(0)->current_frame_host()->GetSiteInstance());
|
| +}
|
| +
|
| } // namespace content
|
|
|